make propogate_in_transaction thread local

This commit is contained in:
Malavan Sotheeswaran committed 2023-05-29 22:00:00 -07:00
1 parent 1a60b1854b
commit d795f4fc63
3 files changed
+10 -10

No files matched your search

+5 -5
View File
@@ -118,14 +118,14 @@ void discardCommand(client *c) {
void beforePropagateMulti() {
/* Propagating MULTI */
serverAssert(!g_pserver->propagate_in_transaction);
g_pserver->propagate_in_transaction = 1;
serverAssert(!serverTL->propagate_in_transaction);
serverTL->propagate_in_transaction = 1;
}
void afterPropagateExec() {
/* Propagating EXEC */
serverAssert(g_pserver->propagate_in_transaction == 1);
g_pserver->propagate_in_transaction = 0;
serverAssert(serverTL->propagate_in_transaction == 1);
serverTL->propagate_in_transaction = 0;
}
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
@@ -264,7 +264,7 @@ void execCommand(client *c) {
/* Make sure the EXEC command will be propagated as well if MULTI
* was already propagated. */
if (g_pserver->propagate_in_transaction) {
if (serverTL->propagate_in_transaction) {
int is_master = listLength(g_pserver->masters) == 0;
g_pserver->dirty++;
/* If inside the MULTI/EXEC block this instance was suddenly
+3 -4
View File
@@ -3945,7 +3945,6 @@ void initServer(void) {
g_pserver->pubsub_channels = dictCreate(&keylistDictType,NULL);
g_pserver->pubsub_patterns = dictCreate(&keylistDictType,NULL);
g_pserver->cronloops = 0;
g_pserver->propagate_in_transaction = 0;
g_pserver->client_pause_in_transaction = 0;
g_pserver->child_pid = -1;
g_pserver->child_type = CHILD_TYPE_NONE;
@@ -4320,7 +4319,7 @@ void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
* This way we'll deliver the MULTI/..../EXEC block as a whole and
* both the AOF and the replication link will have the same consistency
* and atomicity guarantees. */
if (serverTL->in_exec && !g_pserver->propagate_in_transaction)
if (serverTL->in_exec && !serverTL->propagate_in_transaction)
execCommandPropagateMulti(dbid);
/* This needs to be unreachable since the dataset should be fixed during
@@ -4735,13 +4734,13 @@ static int cmdHasMovableKeys(struct redisCommand *cmd) {
int processCommand(client *c, int callFlags) {
AssertCorrectThread(c);
serverAssert((callFlags & CMD_CALL_ASYNC) || GlobalLocksAcquired());
if (!g_pserver->lua_timedout && !(callFlags & CMD_CALL_ASYNC)) {
if (!g_pserver->lua_timedout) {
/* Both EXEC and EVAL call call() directly so there should be
* no way in_exec or in_eval or propagate_in_transaction is 1.
* That is unless lua_timedout, in which case client may run
* some commands. Also possible that some other thread set
* propagate_in_transaction if this is an async command. */
serverAssert(!g_pserver->propagate_in_transaction);
serverAssert(!serverTL->propagate_in_transaction);
serverAssert(!serverTL->in_exec);
serverAssert(!serverTL->in_eval);
}
+2 -1
View File
@@ -2197,6 +2197,8 @@ struct redisServerThreadVars {
bool modulesEnabledThisAeLoop = false; /* In this loop of aeMain, were modules enabled before
the thread went to sleep? */
bool disable_async_commands = false; /* this is only valid for one cycle of the AE loop and is reset in afterSleep */
int propagate_in_transaction = 0; /* Make sure we don't propagate nested MULTI/EXEC */
std::vector<client*> vecclientsProcess;
dictAsyncRehashCtl *rehashCtl = nullptr;
@@ -2302,7 +2304,6 @@ struct redisServer {
int sentinel_mode; /* True if this instance is a Sentinel. */
size_t initial_memory_usage; /* Bytes used after initialization. */
int always_show_logo; /* Show logo even for non-stdout logging. */
int propagate_in_transaction; /* Make sure we don't propagate nested MULTI/EXEC */
char *ignore_warnings; /* Config: warnings that should be ignored. */
int client_pause_in_transaction; /* Was a client pause executed during this Exec? */
pause_type client_pause_type; /* True if clients are currently paused */