Skip to content

Commit

Permalink
correct snapshot for immediate writing (#9711)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Sep 25, 2024
1 parent 75d5458 commit 14936b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ydb/core/tx/columnshard/blobs_action/transaction/tx_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ bool TTxWrite::CommitOneBlob(TTransactionContext& txc, const NOlap::TWideSeriali
auto userData = batch.BuildInsertionUserData(*Self);
TBlobGroupSelector dsGroupSelector(Self->Info());
NOlap::TDbWrapper dbTable(txc.DB, &dsGroupSelector);
NOlap::TCommittedData commitData(userData, Self->GetLastPlannedSnapshot(), Self->Generation(), writeId);
AFL_VERIFY(CommitSnapshot);
NOlap::TCommittedData commitData(userData, *CommitSnapshot, Self->Generation(), writeId);
if (Self->TablesManager.HasTable(userData->GetPathId())) {
auto counters = Self->InsertTable->CommitEphemeral(dbTable, std::move(commitData));
Self->Counters.GetTabletCounters()->OnWriteCommitted(counters);
Expand All @@ -33,6 +34,7 @@ bool TTxWrite::CommitOneBlob(TTransactionContext& txc, const NOlap::TWideSeriali
}

bool TTxWrite::Execute(TTransactionContext& txc, const TActorContext&) {
CommitSnapshot = NOlap::TSnapshot::MaxForPlanStep(Self->GetOutdatedStep());
TMemoryProfileGuard mpg("TTxWrite::Execute");
NActors::TLogContextGuard logGuard =
NActors::TLogContextBuilder::Build(NKikimrServices::TX_COLUMNSHARD_BLOBS)("tablet_id", Self->TabletID())("tx_state", "execute");
Expand Down Expand Up @@ -160,7 +162,8 @@ void TTxWrite::Complete(const TActorContext& ctx) {
}
if (op->GetBehaviour() == EOperationBehaviour::NoTxWrite) {
Self->OperationsManager->AddTemporaryTxLink(op->GetLockId());
Self->OperationsManager->CommitTransactionOnComplete(*Self, op->GetLockId(), Self->GetLastTxSnapshot());
AFL_VERIFY(CommitSnapshot);
Self->OperationsManager->CommitTransactionOnComplete(*Self, op->GetLockId(), *CommitSnapshot);
}
}
Self->Counters.GetCSCounters().OnWriteTxComplete(now - writeMeta.GetWriteStartInstant());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TTxWrite : public NTabletFlatExecutor::TTransactionBase<TColumnShard> {
private:
TEvPrivate::TEvWriteBlobsResult::TPtr PutBlobResult;
const ui32 TabletTxNo;
std::optional<NOlap::TSnapshot> CommitSnapshot;

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

0 comments on commit 14936b2

Please sign in to comment.