fix(transaction): Fix namespace access (#3364)

Our area of attack during concurrent transaction access is the call to DisarmInShard and DisarmInShardWhen, which only access is_armed - an atomic varible. It is not safe to arbitrarily call GetNamespace() if we write to it in InitBase

Solution: Don't write to it post first initialization
This commit is contained in:
Vladislav 2024-07-23 11:25:04 +03:00 committed by GitHub
parent 76edd0d027
commit 759631e9ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -176,11 +176,18 @@ Transaction::~Transaction() {
void Transaction::InitBase(Namespace* ns, DbIndex dbid, CmdArgList args) {
global_ = false;
namespace_ = ns;
db_index_ = dbid;
full_args_ = args;
local_result_ = OpStatus::OK;
stats_.coordinator_index = ProactorBase::me() ? ProactorBase::me()->GetPoolIndex() : kInvalidSid;
// Namespace is read by poll execution, so it can't be changed on the fly
if (IsScheduled()) {
DCHECK_EQ(namespace_, ns);
} else {
DCHECK(namespace_ == nullptr || namespace_ == ns);
namespace_ = ns;
}
}
void Transaction::InitGlobal() {