This commit is contained in:
Alexander Tokmakov 2022-02-04 00:40:17 +03:00
parent fe30e0f162
commit 6a646b413e
2 changed files with 14 additions and 4 deletions

View File

@ -35,18 +35,28 @@ public:
class FunctionTransactionLatestSnapshot : public FunctionConstantBase<FunctionTransactionLatestSnapshot, UInt64, DataTypeUInt64>
{
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<FunctionTransactionLatestSnapshot>(context); }
explicit FunctionTransactionLatestSnapshot(ContextPtr context) : FunctionConstantBase(TransactionLog::instance().getLatestSnapshot(), context->isDistributed()) {}
explicit FunctionTransactionLatestSnapshot(ContextPtr context) : FunctionConstantBase(getLatestSnapshot(context), context->isDistributed()) {}
};
class FunctionTransactionOldestSnapshot : public FunctionConstantBase<FunctionTransactionOldestSnapshot, UInt64, DataTypeUInt64>
{
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<FunctionTransactionOldestSnapshot>(context); }
explicit FunctionTransactionOldestSnapshot(ContextPtr context) : FunctionConstantBase(TransactionLog::instance().getOldestSnapshot(), context->isDistributed()) {}
explicit FunctionTransactionOldestSnapshot(ContextPtr context) : FunctionConstantBase(getOldestSnapshot(context), context->isDistributed()) {}
};
}

View File

@ -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))