diff options
author | Cheahuychou Mao <mao.cheahuychou@gmail.com> | 2023-02-16 19:11:40 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-16 22:45:36 +0000 |
commit | f4050044d6521d3d4f4b5873addd7a9b234df1a7 (patch) | |
tree | f29f6214bec7664e0f7dc0f96ba9451af9250c58 /src | |
parent | 23b3dd8f1a4346905ff7d8181f824d71c715ab65 (diff) | |
download | mongo-f4050044d6521d3d4f4b5873addd7a9b234df1a7.tar.gz |
SERVER-73938 Make sure chunk migration can handle a retryable internal transaction whose oplog entries have been truncated
(cherry picked from commit b9f6d6beb02df55ede1276222a56279e7b2d48f2)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/s/session_catalog_migration_source.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/db/s/session_catalog_migration_source.cpp b/src/mongo/db/s/session_catalog_migration_source.cpp index e6ddaf5151c..704e57ea8c5 100644 --- a/src/mongo/db/s/session_catalog_migration_source.cpp +++ b/src/mongo/db/s/session_catalog_migration_source.cpp @@ -50,6 +50,7 @@ #include "mongo/db/transaction_history_iterator.h" #include "mongo/db/transaction_participant.h" #include "mongo/db/write_concern.h" +#include "mongo/logv2/redaction.h" #include "mongo/platform/random.h" #include "mongo/s/catalog/type_chunk.h" #include "mongo/s/shard_key_pattern.h" @@ -483,11 +484,23 @@ bool SessionCatalogMigrationSource::_handleWriteHistory(WithLock lk, OperationCo // oplog entries derived from it to the oplog buffer. if (isInternalSessionForRetryableWrite(*nextOplog->getSessionId())) { - invariant(nextOplog->getCommandType() == repl::OplogEntry::CommandType::kApplyOps); - // Derive retryable write oplog entries from this retryable internal transaction - // applyOps oplog entry, and add them to the oplog buffer. - _extractOplogEntriesForInternalTransactionForRetryableWrite( - lk, *nextOplog, &_unprocessedOplogBuffer); + if (nextOplog->getCommandType() == repl::OplogEntry::CommandType::kApplyOps) { + // Derive retryable write oplog entries from this retryable internal transaction + // applyOps oplog entry, and add them to the oplog buffer. + _extractOplogEntriesForInternalTransactionForRetryableWrite( + lk, *nextOplog, &_unprocessedOplogBuffer); + } else { + tassert(7393800, + str::stream() << "Found an oplog entry for a retrayble internal " + "transaction with an unexpected type" + << redact(nextOplog->toBSONForLogging()), + nextOplog->getOpType() == repl::OpTypeEnum::kNoop); + if (!nextOplog->getStatementIds().empty() && + !shouldSkipOplogEntry(nextOplog.value(), _keyPattern, _chunkRange)) { + _unprocessedOplogBuffer.emplace_back(*nextOplog); + } + } + continue; } |