diff --git a/ydb/core/kqp/common/kqp_tx.cpp b/ydb/core/kqp/common/kqp_tx.cpp index 7dd9c26ef87c..36823acf9e5e 100644 --- a/ydb/core/kqp/common/kqp_tx.cpp +++ b/ydb/core/kqp/common/kqp_tx.cpp @@ -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; @@ -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()) { @@ -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 diff --git a/ydb/core/kqp/executer_actor/kqp_data_executer.cpp b/ydb/core/kqp/executer_actor/kqp_data_executer.cpp index bfdfcb2bcabc..b137d05e26b0 100644 --- a/ydb/core/kqp/executer_actor/kqp_data_executer.cpp +++ b/ydb/core/kqp/executer_actor/kqp_data_executer.cpp @@ -191,6 +191,7 @@ class TKqpDataExecuter : public TKqpExecuterBase, 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;