Skip to content

Commit

Permalink
Don't recreate snapshots in transaction (ydb-platform#11553)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikvas0 authored Nov 13, 2024
1 parent 7d51c2b commit ee51155
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 1 addition & 5 deletions ydb/core/kqp/common/kqp_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikimrConfig

size_t readPhases = 0;
bool hasEffects = false;
bool hasSourceRead = false;
bool hasStreamLookup = false;
bool hasSinkWrite = false;

Expand All @@ -191,7 +190,6 @@ bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikimrConfig
}

for (const auto &stage : tx.GetStages()) {
hasSourceRead |= !stage.GetSources().empty();
hasSinkWrite |= !stage.GetSinks().empty();

for (const auto &input : stage.GetInputs()) {
Expand All @@ -211,9 +209,7 @@ bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikimrConfig
return true;
}

if ((hasSourceRead || hasStreamLookup) && hasSinkWrite) {
return true;
}
YQL_ENSURE(!hasSinkWrite || hasEffects);

// We don't want snapshot when there are effects at the moment,
// because it hurts performance when there are multiple single-shard
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/executer_actor/kqp_data_executer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da

bool ForceAcquireSnapshot() const {
const bool forceSnapshot = (
!GetSnapshot().IsValid() &&
ReadOnlyTx &&
!ImmediateTx &&
!HasPersistentChannels &&
Expand Down
4 changes: 2 additions & 2 deletions ydb/core/kqp/runtime/kqp_read_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
PendingShards.PushBack(state.Release());
return;
}
} else if (!Snapshot.IsValid() && !Settings->GetAllowInconsistentReads()) {
return RuntimeError("Inconsistent reads after shards split", NDqProto::StatusIds::UNAVAILABLE);
} else if (!Snapshot.IsValid() && !Settings->HasLockTxId() && !Settings->GetAllowInconsistentReads()) {
return RuntimeError("Inconsistent reads without locks", NDqProto::StatusIds::UNAVAILABLE);
}

const auto& tr = *AppData()->TypeRegistry;
Expand Down

0 comments on commit ee51155

Please sign in to comment.