mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(server): handle running script load inside multi (#4074)
Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
75c961e7ed
commit
2d49a28c15
10 changed files with 123 additions and 78 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue