Skip to content

Commit

Permalink
Receipt of REPLCONF VERSION reply should be triggered by event (#1320)
Browse files Browse the repository at this point in the history
This add the missing return when repl_state change to RECEIVE_VERSION_REPLY,
this way we won’t be blocked if the primary doesn’t reply with REPLCONF
VERSION.

In practice i guess this is no likely to block in this context, reading
small responses are are likely to be received in one packet, so this
is just a cleanup (consistent with the previous state machine
processing).

Also update the state machine diagram to mention the VERSION reply.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin authored Nov 19, 2024
1 parent 3d0c834 commit 132798b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -3379,15 +3379,15 @@ void dualChannelSetupMainConnForPsync(connection *conn) {
* ┌────────▼──────────┐ │ │ │DUAL_CHANNEL_RECEIVE_ENDOFF│ │ │by the primary │
* │RECEIVE_IP_REPLY │ │ │ └───────┬───────────────────┘ │ ┌──▼────────────────┐ │
* └────────┬──────────┘ │ │ │$ENDOFF │ │RECEIVE_PSYNC_REPLY│ │
* │ │ │ ├─────────────────────────┘ └──┬────────────────┘ │
* │ │ │ │+CONTINUE │
* │ │ ┌───────▼───────────────┐ ┌──▼────────────────┐ │
* │ │ │DUAL_CHANNEL_RDB_LOAD │ │TRANSFER │ │
* │+OK │ │ ├─────────────────────────┘ └──┬────────────────┘ │
* ┌────────▼──────────┐ │ │ │ │+CONTINUE │
* │RECEIVE_CAPA_REPLY │ │ │ ┌───────▼───────────────┐ ┌──▼────────────────┐ │
* └────────┬──────────┘ │ │ │DUAL_CHANNEL_RDB_LOAD │ │TRANSFER │ │
* │+OK │ │ └───────┬───────────────┘ └─────┬─────────────┘ │
* ┌────────▼────────── │ │ │Done loading │ │
* │RECEIVE_CAPA_REPLY │ │ │ ┌───────▼───────────────┐ │ │
* └────────┬────────── │ │ │DUAL_CHANNEL_RDB_LOADED│ │ │
* │ │ │ └───────┬───────────────┘ │ │
* ┌────────▼─────────────┐ │ │ │Done loading │ │
* │RECEIVE_VERSION_REPLY │ │ │ ┌───────▼───────────────┐ │ │
* └────────┬─────────────┘ │ │ │DUAL_CHANNEL_RDB_LOADED│ │ │
* │+OK │ │ └───────┬───────────────┘ │ │
* ┌────────▼───┐ │ │ │ │ │
* │SEND_PSYNC │ │ │ │Replica loads local replication │ │
* └─┬──────────┘ │ │ │buffer into memory │ │
Expand Down Expand Up @@ -3589,6 +3589,7 @@ void syncWithPrimary(connection *conn) {
sdsfree(err);
err = NULL;
server.repl_state = REPL_STATE_RECEIVE_VERSION_REPLY;
return;
}

/* Receive VERSION reply. */
Expand Down

0 comments on commit 132798b

Please sign in to comment.