summaryrefslogtreecommitdiff
path: root/src/mongo/s/transaction_router.h
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2019-02-26 02:22:37 -0500
committerEsha Maharishi <esha.maharishi@mongodb.com>2019-03-13 19:10:21 -0400
commitcd44c20c13d2452c78d1131fdedebd3107ecffea (patch)
treed3ead92f0791203b61ec183ab56a86de511bacd4 /src/mongo/s/transaction_router.h
parent537ba4469fb872027a59b26344de28e715684679 (diff)
downloadmongo-cd44c20c13d2452c78d1131fdedebd3107ecffea.tar.gz
SERVER-39875 Make router process readOnly field in responses to transaction statements
Diffstat (limited to 'src/mongo/s/transaction_router.h')
-rw-r--r--src/mongo/s/transaction_router.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/s/transaction_router.h b/src/mongo/s/transaction_router.h
index 983ad8ba4d4..eb7f7c48874 100644
--- a/src/mongo/s/transaction_router.h
+++ b/src/mongo/s/transaction_router.h
@@ -72,6 +72,8 @@ public:
* the transaction that created it.
*/
struct Participant {
+ enum class ReadOnly { kUnset, kReadOnly, kNotReadOnly };
+
Participant(bool isCoordinator,
StmtId stmtIdCreatedAt,
SharedTransactionOptions sharedOptions);
@@ -84,6 +86,10 @@ public:
// True if the participant has been chosen as the coordinator for its transaction
const bool isCoordinator{false};
+ // Is updated to kReadOnly or kNotReadOnly based on the readOnly field in the participant's
+ // responses to statements.
+ ReadOnly readOnly{ReadOnly::kUnset};
+
// The highest statement id of the request during which this participant was created.
const StmtId stmtIdCreatedAt{kUninitializedStmtId};
@@ -156,6 +162,12 @@ public:
BSONObj attachTxnFieldsIfNeeded(const ShardId& shardId, const BSONObj& cmdObj);
/**
+ * Processes the transaction metadata in the response from the participant if the response
+ * indicates the operation succeeded.
+ */
+ void processParticipantResponse(const ShardId& shardId, const BSONObj& responseObj);
+
+ /**
* Returns true if the current transaction can retry on a stale version error from a contacted
* shard. This is always true except for an error received by a write that is not the first
* overall statement in the sharded transaction. This is because the entire command will be