mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
feat(journal): Introduce basic journal support. (#211)
1. No entries data is written into a journal yet. 2. Introduced a state machine to start and stop journal using a new auxillary command "dfly". 3. string_family currently calls an universal command Journal::RecordEntry that should save the current key/value of that entry. Please note that we won't use it for all the operations because for some it's more efficient to record the action itself than the final value. 4. no locking information is recorded yet so atomicity of multi-key operations is not preserved for now. Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
05eb323a0d
commit
3bbdb8e4b1
26 changed files with 978 additions and 388 deletions
|
@ -11,6 +11,8 @@
|
|||
#include "server/command_registry.h"
|
||||
#include "server/db_slice.h"
|
||||
#include "server/engine_shard_set.h"
|
||||
#include "server/journal/journal.h"
|
||||
#include "server/server_state.h"
|
||||
|
||||
namespace dfly {
|
||||
|
||||
|
@ -334,9 +336,14 @@ bool Transaction::RunInShard(EngineShard* shard) {
|
|||
|
||||
/*************************************************************************/
|
||||
// Actually running the callback.
|
||||
// If you change the logic here, also please change the logic
|
||||
try {
|
||||
// if transaction is suspended (blocked in watched queue), then it's a noop.
|
||||
OpStatus status = was_suspended ? OpStatus::OK : cb_(this, shard);
|
||||
OpStatus status = OpStatus::OK;
|
||||
|
||||
if (!was_suspended) {
|
||||
status = cb_(this, shard);
|
||||
}
|
||||
|
||||
if (unique_shard_cnt_ == 1) {
|
||||
cb_ = nullptr; // We can do it because only a single thread runs the callback.
|
||||
|
@ -467,6 +474,13 @@ void Transaction::ScheduleInternal() {
|
|||
VLOG(2) << "Scheduled " << DebugId()
|
||||
<< " OutOfOrder: " << bool(coordinator_state_ & COORD_OOO)
|
||||
<< " num_shards: " << num_shards;
|
||||
|
||||
if (mode == IntentLock::EXCLUSIVE) {
|
||||
journal::Journal* j = ServerState::tlocal()->journal();
|
||||
// TODO: we may want to pass custom command name into journal.
|
||||
if (j && j->SchedStartTx(txid_, 0, num_shards)) {
|
||||
}
|
||||
}
|
||||
coordinator_state_ |= COORD_SCHED;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue