fix(server): handle running script load inside multi (#4074)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2024-11-10 09:34:40 +02:00 committed by GitHub
parent 75c961e7ed
commit 2d49a28c15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 123 additions and 78 deletions

View file

@ -47,6 +47,8 @@ using RdbTypeFreqMap = absl::flat_hash_map<unsigned, size_t>;
class CommandId;
class Transaction;
class EngineShard;
class ConnectionState;
class Interpreter;
struct LockTagOptions {
bool enabled = false;
@ -353,6 +355,29 @@ template <typename Mutex> class ABSL_SCOPED_LOCKABLE SharedLock {
bool is_locked_;
};
// Ensures availability of an interpreter for EVAL-like commands and it's automatic release.
// If it's part of MULTI, the preborrowed interpreter is returned, otherwise a new is acquired.
struct BorrowedInterpreter {
BorrowedInterpreter(Transaction* tx, ConnectionState* state);
~BorrowedInterpreter();
// Give up ownership of the interpreter, it must be returned manually.
Interpreter* Release() && {
DCHECK(owned_);
owned_ = false;
return interpreter_;
}
operator Interpreter*() {
return interpreter_;
}
private:
Interpreter* interpreter_ = nullptr;
bool owned_ = false;
};
extern size_t serialization_max_chunk_size;
} // namespace dfly