mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 09:55:45 +02:00
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:
parent
76edd0d027
commit
759631e9ed
1 changed files with 8 additions and 1 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue