Skip to content

Commit 14936b2

Browse files
correct snapshot for immediate writing (#9711)
1 parent 75d5458 commit 14936b2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ydb/core/tx/columnshard/blobs_action/transaction/tx_write.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ bool TTxWrite::CommitOneBlob(TTransactionContext& txc, const NOlap::TWideSeriali
2323
auto userData = batch.BuildInsertionUserData(*Self);
2424
TBlobGroupSelector dsGroupSelector(Self->Info());
2525
NOlap::TDbWrapper dbTable(txc.DB, &dsGroupSelector);
26-
NOlap::TCommittedData commitData(userData, Self->GetLastPlannedSnapshot(), Self->Generation(), writeId);
26+
AFL_VERIFY(CommitSnapshot);
27+
NOlap::TCommittedData commitData(userData, *CommitSnapshot, Self->Generation(), writeId);
2728
if (Self->TablesManager.HasTable(userData->GetPathId())) {
2829
auto counters = Self->InsertTable->CommitEphemeral(dbTable, std::move(commitData));
2930
Self->Counters.GetTabletCounters()->OnWriteCommitted(counters);
@@ -33,6 +34,7 @@ bool TTxWrite::CommitOneBlob(TTransactionContext& txc, const NOlap::TWideSeriali
3334
}
3435

3536
bool TTxWrite::Execute(TTransactionContext& txc, const TActorContext&) {
37+
CommitSnapshot = NOlap::TSnapshot::MaxForPlanStep(Self->GetOutdatedStep());
3638
TMemoryProfileGuard mpg("TTxWrite::Execute");
3739
NActors::TLogContextGuard logGuard =
3840
NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD_BLOBS)("tablet_id", Self->TabletID())("tx_state", "execute");
@@ -160,7 +162,8 @@ void TTxWrite::Complete(const TActorContext& ctx) {
160162
}
161163
if (op->GetBehaviour() == EOperationBehaviour::NoTxWrite) {
162164
Self->OperationsManager->AddTemporaryTxLink(op->GetLockId());
163-
Self->OperationsManager->CommitTransactionOnComplete(*Self, op->GetLockId(), Self->GetLastTxSnapshot());
165+
AFL_VERIFY(CommitSnapshot);
166+
Self->OperationsManager->CommitTransactionOnComplete(*Self, op->GetLockId(), *CommitSnapshot);
164167
}
165168
}
166169
Self->Counters.GetCSCounters().OnWriteTxComplete(now - writeMeta.GetWriteStartInstant());

ydb/core/tx/columnshard/blobs_action/transaction/tx_write.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class TTxWrite : public NTabletFlatExecutor::TTransactionBase<TColumnShard> {
1919
private:
2020
TEvPrivate::TEvWriteBlobsResult::TPtr PutBlobResult;
2121
const ui32 TabletTxNo;
22+
std::optional<NOlap::TSnapshot> CommitSnapshot;
2223

2324
bool CommitOneBlob(TTransactionContext& txc, const NOlap::TWideSerializedBatch& batch, const TInsertWriteId writeId);
2425
bool InsertOneBlob(TTransactionContext& txc, const NOlap::TWideSerializedBatch& batch, const TInsertWriteId writeId);

0 commit comments

Comments
 (0)