diff options
author | Nikita Vasilev <ns-vasilev@ydb.tech> | 2024-11-13 16:08:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-13 16:08:37 +0300 |
commit | ee51155da394b56a8e3329d25a514422e5da7bc3 (patch) | |
tree | 09b3cf45728f52f1a58d00fe4699172e03e062b9 | |
parent | 7d51c2b807c57d8ed232ea4305dba859d9bc0686 (diff) | |
download | ydb-ee51155da394b56a8e3329d25a514422e5da7bc3.tar.gz |
Don't recreate snapshots in transaction (#11553)
-rw-r--r-- | ydb/core/kqp/common/kqp_tx.cpp | 6 | ||||
-rw-r--r-- | ydb/core/kqp/executer_actor/kqp_data_executer.cpp | 1 | ||||
-rw-r--r-- | ydb/core/kqp/runtime/kqp_read_actor.cpp | 4 |
3 files changed, 4 insertions, 7 deletions
diff --git a/ydb/core/kqp/common/kqp_tx.cpp b/ydb/core/kqp/common/kqp_tx.cpp index e2758eff627..4d9f7ab9057 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 8e0b2b666af..27b0b948409 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 @@ public: bool ForceAcquireSnapshot() const { const bool forceSnapshot = ( + !GetSnapshot().IsValid() && ReadOnlyTx && !ImmediateTx && !HasPersistentChannels && diff --git a/ydb/core/kqp/runtime/kqp_read_actor.cpp b/ydb/core/kqp/runtime/kqp_read_actor.cpp index 7e2ae5d8785..b30875968bf 100644 --- a/ydb/core/kqp/runtime/kqp_read_actor.cpp +++ b/ydb/core/kqp/runtime/kqp_read_actor.cpp @@ -598,8 +598,8 @@ public: 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; |