Commit cca825ae authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Make leases usable from standalone mode as well

parent 1219c40b
Pipeline #429040 passed with stages
in 28 minutes and 43 seconds
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ShardDirectory.hh" #include "ShardDirectory.hh"
#include "raft/RaftGroup.hh" #include "raft/RaftGroup.hh"
#include "raft/RaftDispatcher.hh" #include "raft/RaftDispatcher.hh"
#include "redis/LeaseFilter.hh"
#include "utils/ScopedAdder.hh" #include "utils/ScopedAdder.hh"
using namespace quarkdb; using namespace quarkdb;
...@@ -116,6 +117,21 @@ LinkStatus Shard::dispatch(Connection *conn, Transaction &transaction) { ...@@ -116,6 +117,21 @@ LinkStatus Shard::dispatch(Connection *conn, Transaction &transaction) {
return conn->raw(Formatter::multiply(Formatter::err("unavailable"), transaction.expectedResponses())); return conn->raw(Formatter::multiply(Formatter::err("unavailable"), transaction.expectedResponses()));
} }
// If this is standalone mode, do lease timestamp filtering here.
// Otherwise, RaftDispatcher will take care of it.
if(mode == Mode::standalone) {
ClockValue txTimestamp = stateMachine->getDynamicClock();
for(size_t i = 0; i < transaction.size(); i++) {
if(transaction[i].getCommand() == RedisCommand::LEASE_GET || transaction[i].getCommand() == RedisCommand::LEASE_ACQUIRE) {
// TODO(gbitzes): This is racy.. we should timestampt after getting a raft
// snapshot, but we need to refactor transactions a bit first.
LeaseFilter::transform(transaction[i], txTimestamp);
}
}
}
return dispatcher->dispatch(conn, transaction); return dispatcher->dispatch(conn, transaction);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment