Skip to content

Commit

Permalink
Introduce import-mode and client import-source (#205)
Browse files Browse the repository at this point in the history
This PR is for valkey-io/valkey#1185 and
valkey-io/valkey#1398.

---------

Signed-off-by: lvyanqi.lyq <[email protected]>
Signed-off-by: Viktor Söderqvist <[email protected]>
Co-authored-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
lyq2333 and zuiderkwast authored Jan 2, 2025
1 parent c2ef202 commit 7a4c92a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions commands/client-import-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
When the client sync data from a Redis-like server to Valkey using some sync tools like [RedisShake](https://github.com/tair-opensource/RedisShake), Valkey performs expiration and eviction as usual because it's a primary, which may cause data corruption. For example, the client calls `set key 1 ex 1` on the source server and this command is transferred to the destination server. Then the client calls `incr key` on the source server before the key expired, there will be a key on the source server with the value of 2. But when the command arrived at the destination server, the key may be expired and has deleted. So there will be a key on the destination server with the value of 1, which is inconsistent with the source server. Sync tools can solve this problem by setting `import-mode` config to `yes` and declaring their connections as `IMPORT-SOURCE`.

The `CLIENT IMPORT-SOURCE` command mark this client as an import source if import-mode is enabled and can visit expired keys. The following modes are available:

* `ON`. In this mode the client can visit expired keys.
* `OFF`. This is the default mode in which the client works as a normal client.

## Notes

The server needs to be configured with `import-mode yes` before marking a client connection as an import source.
1 change: 1 addition & 0 deletions commands/client-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ t: the client enabled keys tracking in order to perform client side caching
T: the client will not touch the LRU/LFU of the keys it accesses
R: the client tracking target client is invalid
B: the client enabled broadcast tracking mode
I: the client is an import source
```

The file descriptor events can be:
Expand Down

0 comments on commit 7a4c92a

Please sign in to comment.