-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic multi modes for MULTI/EXEC #796
Conversation
df0c63d
to
25045f4
Compare
I'll stop growing the PR on this state, currently it has
So far it seems to work with a single instance. The bad news is that currently replication tests pass only with the LOCK_INCR_GLOBAL mode (which was the default mode before) There is still some unresolved stuff and details, but you can take a look at it on a high level |
src/server/dragonfly_test.cc
Outdated
// TODO: We have no way of measuring now. | ||
// EXPECT_EQ(2, GetDebugInfo().shards_count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is:
- this info was set after InitByArgs inside dispatch
- We deduce the number of active shards only in the handler
So we probably need to update the debug info inside the handler itself?
@@ -1448,7 +1509,7 @@ void Service::RegisterCommands() { | |||
&EvalValidator) | |||
<< CI{"EVALSHA", CO::NOSCRIPT | CO::VARIADIC_KEYS, -3, 3, 3, 1}.MFUNC(EvalSha).SetValidator( | |||
&EvalValidator) | |||
<< CI{"EXEC", kExecMask, 1, 0, 0, 0}.MFUNC(Exec) | |||
<< CI{"EXEC", CO::LOADING | CO::NOSCRIPT, 1, 0, 0, 1}.MFUNC(Exec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, this is no longer GLOBAL by default
Second, the step is now 1. This is because some parts of tx rely on it for reading arguments. We virtually "append" arguments to EXEC to schedule it ahead for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we lock ahead
We read the keys from shard args based on their 'step'. If we schedule ahead with EXEC, then we store the keys inside the per-shard args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to add a comment about it here or where you do it
src/server/transaction.h
Outdated
struct PerShardCache { | ||
bool requested_active = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I added to schedule on shards without having the keys.
If this flag is set, the new ACTIVE flag is set as well even if there are no arguments.
TODO: need to add a comment about this
19a6958
to
1742104
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. I have not checked the correctness - it's almost impossible but I guess the tests are passing :)
@@ -1448,7 +1509,7 @@ void Service::RegisterCommands() { | |||
&EvalValidator) | |||
<< CI{"EVALSHA", CO::NOSCRIPT | CO::VARIADIC_KEYS, -3, 3, 3, 1}.MFUNC(EvalSha).SetValidator( | |||
&EvalValidator) | |||
<< CI{"EXEC", kExecMask, 1, 0, 0, 0}.MFUNC(Exec) | |||
<< CI{"EXEC", CO::LOADING | CO::NOSCRIPT, 1, 0, 0, 1}.MFUNC(Exec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where we do that?
I would like to squash these commits and then have a good commit message giving a summary of this change.
The motivation - for us to look at the commit a month from now and understand the logic. |
0923819
to
909ed05
Compare
This commit adds the notion of multi transaction modes that allow controlling the execution and locking behaviour of multi transactions. In general, there are four modes: - GLOBAL: all commands run within a global transaction. There is no need for recording locks. Lua scripts can theoretically run with undeclared keys. - LOCK_AHEAD: the transaction locks all keys ahead likewise to a regular transaction and schedules itself. - LOCK_INCREMENTAL: the transaction determines what shards it has keys in and schedules itself on those shards, but locks only when accessing a new key. This allows other transactions to run ooo alonside with a big multi-transaction that accesses a contended key only at its very end. - NON_ATOMIC: all commands run separately, no atomicity is provided, likewise to a pipeline This commit only adds support for the first 3 modes to EXEC commands. Signed-off-by: Vladislav Oleshko <[email protected]>
909ed05
to
d63fd68
Compare
This commit adds the notion of multi transaction modes that allow controlling the execution and
locking behaviour of multi transactions.
In general, there are four modes:
This commit only adds support for the first 3 modes to EXEC commands.
Signed-off-by: Vladislav Oleshko [email protected]