-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the support of the namespace replication (#1776)
Currently, Kvrocks won't propagate the namespace and token between master and slaves, and it may cause trouble if users add them in master but missing in slaves. So it would make this process easier if we could propagate the namespace/token as well. ## Design To implement this feature, we need to consider the following situations: - How to replicate namespaces between the master and slaves - How to be compatible with old versions **For the replication:** We now have the propagate column family to propagate commands between the master and slaves, so we can use it to replicate namespaces as well. The steps are like below: 1. Modify namespace/token in master(forbid changing in slaves) 2. Propagate the namespace event to notify slaves like the Lua script 3. Slaves replay namespace/token changes This works well for new instances, but what if there are different namespaces between the master and slaves in old instances? There are three possible conditions: 1. Namespace/token exists in master but NOT in slave 2. Namespace exists in slave but NOT in master 3. Namespace exists both in master and slave, but the token is different For condition 1, we can add the namespace/token to the slave as well. For condition 2, it makes sense to keep the namespace NOT existing in the master since data are from it, so we can remove the namespace/token. The most troublesome condition is 3 since users may have already used the token to access the data, changing the token would cause an invalid password error. **To make this simple, I prefer also overwriting the token.** And offer the configuration to allow users to enable or disable this feature, they MUST understand the risks before enabling. To be noticed, we don't expect to propagate the default namespace since it may affect the replication part, so we won't persist the default namespace. **For the compatible issue:** Currently, namespaces are kept in the configuration file, so we need to read from the rocksdb first(store in propagate column like Lua script) when starting: - If the key exists in rocksdb, load namespace/token from rocksdb and check if any namespace/token is inside the configuration file. If yes, refuse to start the server and ask users to remove them and add them via the `namespace add` command. - If the key does NOT exist in rocksdb, read namespace/token from the configuration file and write them into rocksdb. To be noticed, we need to add an empty value for the key even though no namespace/token. Users can only modify the namespace via command if this feature is enabled.
- Loading branch information
Showing
14 changed files
with
527 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.