Unverified Commit c22d3684 authored by Eduardo Semprebon's avatar Eduardo Semprebon Committed by GitHub
Browse files

Fix diskless load handling on broken EOF marker (#9752)

During diskless replication, the check for broken EOF mark is misplaced
and should be earlier. Now we do not swap db, we do proper cleanup and
correctly raise module events on this kind of failure.

This issue existed prior to #9323, but before, the side effect was not restoring
backup and not raising the correct module events on this failure.
parent 2ce29e03
...@@ -1963,11 +1963,24 @@ void readSyncBulkPayload(connection *conn) { ...@@ -1963,11 +1963,24 @@ void readSyncBulkPayload(connection *conn) {
connRecvTimeout(conn, server.repl_timeout*1000); connRecvTimeout(conn, server.repl_timeout*1000);
startLoading(server.repl_transfer_size, RDBFLAGS_REPLICATION, asyncLoading); startLoading(server.repl_transfer_size, RDBFLAGS_REPLICATION, asyncLoading);
int loadingFailed = 0;
if (rdbLoadRio(&rdb,RDBFLAGS_REPLICATION,&rsi,dbarray) != C_OK) { if (rdbLoadRio(&rdb,RDBFLAGS_REPLICATION,&rsi,dbarray) != C_OK) {
/* RDB loading failed. */ /* RDB loading failed. */
serverLog(LL_WARNING, serverLog(LL_WARNING,
"Failed trying to load the MASTER synchronization DB " "Failed trying to load the MASTER synchronization DB "
"from socket: %s", strerror(errno)); "from socket: %s", strerror(errno));
loadingFailed = 1;
} else if (usemark) {
/* Verify the end mark is correct. */
if (!rioRead(&rdb, buf, CONFIG_RUN_ID_SIZE) ||
memcmp(buf, eofmark, CONFIG_RUN_ID_SIZE) != 0)
{
serverLog(LL_WARNING, "Replication stream EOF marker is broken");
loadingFailed = 1;
}
}
if (loadingFailed) {
stopLoading(0); stopLoading(0);
cancelReplicationHandshake(1); cancelReplicationHandshake(1);
rioFreeConn(&rdb, NULL); rioFreeConn(&rdb, NULL);
...@@ -2013,19 +2026,6 @@ void readSyncBulkPayload(connection *conn) { ...@@ -2013,19 +2026,6 @@ void readSyncBulkPayload(connection *conn) {
/* Inform about db change, as replication was diskless and didn't cause a save. */ /* Inform about db change, as replication was diskless and didn't cause a save. */
server.dirty++; server.dirty++;
/* Verify the end mark is correct. */
if (usemark) {
if (!rioRead(&rdb,buf,CONFIG_RUN_ID_SIZE) ||
memcmp(buf,eofmark,CONFIG_RUN_ID_SIZE) != 0)
{
stopLoading(0);
serverLog(LL_WARNING,"Replication stream EOF marker is broken");
cancelReplicationHandshake(1);
rioFreeConn(&rdb, NULL);
return;
}
}
stopLoading(1); stopLoading(1);
/* Cleanup and restore the socket to the original state to continue /* Cleanup and restore the socket to the original state to continue
......
Markdown is supported
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