Skip to content

Commit ee51155

Browse files
authored
Don't recreate snapshots in transaction (#11553)
1 parent 7d51c2b commit ee51155

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

ydb/core/kqp/common/kqp_tx.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikimrConfig
171171

172172
size_t readPhases = 0;
173173
bool hasEffects = false;
174-
bool hasSourceRead = false;
175174
bool hasStreamLookup = false;
176175
bool hasSinkWrite = false;
177176

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

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

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

214-
if ((hasSourceRead || hasStreamLookup) && hasSinkWrite) {
215-
return true;
216-
}
212+
YQL_ENSURE(!hasSinkWrite || hasEffects);
217213

218214
// We don't want snapshot when there are effects at the moment,
219215
// because it hurts performance when there are multiple single-shard

ydb/core/kqp/executer_actor/kqp_data_executer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ class TKqpDataExecuter : public TKqpExecuterBase<TKqpDataExecuter, EExecType::Da
191191

192192
bool ForceAcquireSnapshot() const {
193193
const bool forceSnapshot = (
194+
!GetSnapshot().IsValid() &&
194195
ReadOnlyTx &&
195196
!ImmediateTx &&
196197
!HasPersistentChannels &&

ydb/core/kqp/runtime/kqp_read_actor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ class TKqpReadActor : public TActorBootstrapped<TKqpReadActor>, public NYql::NDq
598598
PendingShards.PushBack(state.Release());
599599
return;
600600
}
601-
} else if (!Snapshot.IsValid() && !Settings->GetAllowInconsistentReads()) {
602-
return RuntimeError("Inconsistent reads after shards split", NDqProto::StatusIds::UNAVAILABLE);
601+
} else if (!Snapshot.IsValid() && !Settings->HasLockTxId() && !Settings->GetAllowInconsistentReads()) {
602+
return RuntimeError("Inconsistent reads without locks", NDqProto::StatusIds::UNAVAILABLE);
603603
}
604604

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

0 commit comments

Comments
 (0)