summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/fle2_compact.cpp25
-rw-r--r--src/mongo/db/commands/fle_compact_test.cpp4
2 files changed, 16 insertions, 13 deletions
diff --git a/src/mongo/db/commands/fle2_compact.cpp b/src/mongo/db/commands/fle2_compact.cpp
index 3450efa6741..2d930e6b05c 100644
--- a/src/mongo/db/commands/fle2_compact.cpp
+++ b/src/mongo/db/commands/fle2_compact.cpp
@@ -153,7 +153,8 @@ void upsertNullDocument(FLEQueryInterface* queryImpl,
}
} else {
// insert the null doc; translate duplicate key error to a FLE contention error
- auto reply = uassertStatusOK(queryImpl->insertDocument(nss, newNullDoc, true));
+ StmtId stmtId = kUninitializedStmtId;
+ auto reply = uassertStatusOK(queryImpl->insertDocument(nss, newNullDoc, &stmtId, true));
checkWriteErrors(reply);
statsCtr.addInserts(1);
}
@@ -256,7 +257,9 @@ ESCPreCompactState prepareESCForCompaction(FLEQueryInterface* queryImpl,
// committed before the current compact transaction commits
auto placeholder = ESCCollection::generateCompactionPlaceholderDocument(
tagToken, valueToken, state.pos, state.count);
- auto insertReply = uassertStatusOK(queryImpl->insertDocument(nssEsc, placeholder, true));
+ StmtId stmtId = kUninitializedStmtId;
+ auto insertReply =
+ uassertStatusOK(queryImpl->insertDocument(nssEsc, placeholder, &stmtId, true));
checkWriteErrors(insertReply);
stats.addInserts(1);
@@ -332,7 +335,9 @@ ECCPreCompactState prepareECCForCompaction(FLEQueryInterface* queryImpl,
// committed before the current compact transaction commits
auto placeholder =
ECCCollection::generateCompactionDocument(tagToken, valueToken, state.pos);
- auto insertReply = uassertStatusOK(queryImpl->insertDocument(nssEcc, placeholder, true));
+ StmtId stmtId = kUninitializedStmtId;
+ auto insertReply =
+ uassertStatusOK(queryImpl->insertDocument(nssEcc, placeholder, &stmtId, true));
checkWriteErrors(insertReply);
stats.addInserts(1);
} else {
@@ -442,6 +447,7 @@ void compactOneFieldValuePair(FLEQueryInterface* queryImpl,
// PART 3
// A. compact the ECC
bool allEntriesDeleted = (escState.count == eccState.count);
+ StmtId stmtId = kUninitializedStmtId;
if (eccState.count != 0) {
bool hasNullDoc = (eccState.ipos > 1);
@@ -458,6 +464,7 @@ void compactOneFieldValuePair(FLEQueryInterface* queryImpl,
namespaces.eccNss,
ECCCollection::generateDocument(
eccTagToken, eccValueToken, eccState.pos + k, range.start, range.end),
+ &stmtId,
true));
checkWriteErrors(insertReply);
stats.addInserts(1);
@@ -527,10 +534,8 @@ CompactStats processFLECompact(OperationContext* opCtx,
auto argsBlock = std::tie(c, request, namespaces, ecocStats);
auto sharedBlock = std::make_shared<decltype(argsBlock)>(argsBlock);
- auto swResult = runInTxnWithRetry(
- opCtx,
- trun,
- [sharedBlock](const txn_api::TransactionClient& txnClient, ExecutorPtr txnExec) {
+ auto swResult = trun->runSyncNoThrow(
+ opCtx, [sharedBlock](const txn_api::TransactionClient& txnClient, ExecutorPtr txnExec) {
FLEQueryInterfaceImpl queryImpl(txnClient);
auto [c2, request2, namespaces2, ecocStats2] = *sharedBlock.get();
@@ -556,10 +561,8 @@ CompactStats processFLECompact(OperationContext* opCtx,
auto argsBlock = std::tie(ecocDoc, namespaces, escStats, eccStats);
auto sharedBlock = std::make_shared<decltype(argsBlock)>(argsBlock);
- auto swResult = runInTxnWithRetry(
- opCtx,
- trun,
- [sharedBlock](const txn_api::TransactionClient& txnClient, ExecutorPtr txnExec) {
+ auto swResult = trun->runSyncNoThrow(
+ opCtx, [sharedBlock](const txn_api::TransactionClient& txnClient, ExecutorPtr txnExec) {
FLEQueryInterfaceImpl queryImpl(txnClient);
auto [ecocDoc2, namespaces2, escStats2, eccStats2] = *sharedBlock.get();
diff --git a/src/mongo/db/commands/fle_compact_test.cpp b/src/mongo/db/commands/fle_compact_test.cpp
index 0112338facb..9ee23271cfd 100644
--- a/src/mongo/db/commands/fle_compact_test.cpp
+++ b/src/mongo/db/commands/fle_compact_test.cpp
@@ -395,8 +395,8 @@ void FleCompactTest::doSingleInsert(int id, BSONObj encryptedFieldsObj) {
auto efc =
generateEncryptedFieldConfig(encryptedFieldsObj.getFieldNames<std::set<std::string>>());
- uassertStatusOK(
- processInsert(_queryImpl.get(), _namespaces.edcNss, serverPayload, efc, result));
+ uassertStatusOK(processInsert(
+ _queryImpl.get(), _namespaces.edcNss, serverPayload, efc, kUninitializedTxnNumber, result));
}
void FleCompactTest::doSingleDelete(int id, BSONObj encryptedFieldsObj) {