Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ea2e51c6
Commit
ea2e51c6
authored
Nov 04, 2017
by
zhaozhao.zz
Browse files
PSYNC2: persist cached_master's dbid inside the RDB
parent
93037f76
Changes
1
Show whitespace changes
Inline
Side-by-side
src/rdb.c
View file @
ea2e51c6
...
@@ -2054,11 +2054,25 @@ rdbSaveInfo *rdbPopulateSaveInfo(rdbSaveInfo *rsi) {
...
@@ -2054,11 +2054,25 @@ rdbSaveInfo *rdbPopulateSaveInfo(rdbSaveInfo *rsi) {
return rsi;
return rsi;
}
}
/* If the instance is a slave we need a connected master
in order to
/* If the instance is a slave we need a connected master
* fetch the currently selected DB. */
*
in order to
fetch the currently selected DB. */
if (server.master) {
if (server.master) {
rsi->repl_stream_db = server.master->db->id;
rsi->repl_stream_db = server.master->db->id;
return rsi;
return rsi;
}
}
/* It is useful to persist cached_master's db id inside RDB file.
* When a slave lost master's connection, server.master will be
* cached as server.cached_master, after that a slave can not
* increment the master_repl_offset because slave only apply data
* from connected master, so the cached_master can hold right
* replication info. But please note that this action is safe
* only after we fix the free backlog problem, because when a master
* turn to be a slave, it will use itself as the server.cached_master,
* that is dangerous if we didn't use a new replication ID after
* free backlog. */
if (server.cached_master) {
rsi->repl_stream_db = server.cached_master->db->id;
return rsi;
}
return NULL;
return NULL;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment