From 6a646b413e890d12fa07be40e215d00573c29b80 Mon Sep 17 00:00:00 2001 From: Alexander Tokmakov Date: Fri, 4 Feb 2022 00:40:17 +0300 Subject: [PATCH] fix --- src/Functions/FunctionsTransactionCounters.cpp | 14 ++++++++++++-- src/Interpreters/TransactionVersionMetadata.cpp | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Functions/FunctionsTransactionCounters.cpp b/src/Functions/FunctionsTransactionCounters.cpp index f553d0a8be1..f2e9d3aa84b 100644 --- a/src/Functions/FunctionsTransactionCounters.cpp +++ b/src/Functions/FunctionsTransactionCounters.cpp @@ -35,18 +35,28 @@ public: class FunctionTransactionLatestSnapshot : public FunctionConstantBase { + static UInt64 getLatestSnapshot(ContextPtr context) + { + context->checkTransactionsAreAllowed(/* explicit_tcl_query */ true); + return TransactionLog::instance().getLatestSnapshot(); + } public: static constexpr auto name = "transactionLatestSnapshot"; static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } - explicit FunctionTransactionLatestSnapshot(ContextPtr context) : FunctionConstantBase(TransactionLog::instance().getLatestSnapshot(), context->isDistributed()) {} + explicit FunctionTransactionLatestSnapshot(ContextPtr context) : FunctionConstantBase(getLatestSnapshot(context), context->isDistributed()) {} }; class FunctionTransactionOldestSnapshot : public FunctionConstantBase { + static UInt64 getOldestSnapshot(ContextPtr context) + { + context->checkTransactionsAreAllowed(/* explicit_tcl_query */ true); + return TransactionLog::instance().getOldestSnapshot(); + } public: static constexpr auto name = "transactionOldestSnapshot"; static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } - explicit FunctionTransactionOldestSnapshot(ContextPtr context) : FunctionConstantBase(TransactionLog::instance().getOldestSnapshot(), context->isDistributed()) {} + explicit FunctionTransactionOldestSnapshot(ContextPtr context) : FunctionConstantBase(getOldestSnapshot(context), context->isDistributed()) {} }; } diff --git a/src/Interpreters/TransactionVersionMetadata.cpp b/src/Interpreters/TransactionVersionMetadata.cpp index b22683855ce..e80d08a1944 100644 --- a/src/Interpreters/TransactionVersionMetadata.cpp +++ b/src/Interpreters/TransactionVersionMetadata.cpp @@ -52,10 +52,10 @@ TransactionID VersionMetadata::getRemovalTID() const TIDHash max_lock = removal_tid_lock.load(); if (max_lock) { - if (auto txn = TransactionLog::instance().tryGetRunningTransaction(max_lock)) - return txn->tid; if (max_lock == Tx::PrehistoricTID.getHash()) return Tx::PrehistoricTID; + if (auto txn = TransactionLog::instance().tryGetRunningTransaction(max_lock)) + return txn->tid; } if (removal_csn.load(std::memory_order_relaxed))