Skip to content

Commit 372ea21

Browse files
Update comment around propagateDeletion (redis#12687)
Fix some outdated comments and add comment for moduleNotifyKeyspaceEvent we added in redis#11084 since it seems a bit implicit. --------- Co-authored-by: Oran Agra <oran@redislabs.com>
1 parent 3fac869 commit 372ea21

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/cluster.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7558,6 +7558,9 @@ unsigned int delKeysInSlot(unsigned int hashslot) {
75587558
dbDelete(&server.db[0], key);
75597559
propagateDeletion(&server.db[0], key, server.lazyfree_lazy_server_del);
75607560
signalModifiedKey(NULL, &server.db[0], key);
7561+
/* The keys are not actually logically deleted from the database, just moved to another node.
7562+
* The modules needs to know that these keys are no longer available locally, so just send the
7563+
* keyspace notification to the modules, but not to clients. */
75617564
moduleNotifyKeyspaceEvent(NOTIFY_GENERIC, "del", key, server.db[0].id);
75627565
postExecutionUnitOperations();
75637566
decrRefCount(key);

src/db.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,23 +2012,24 @@ void deleteExpiredKeyAndPropagate(redisDb *db, robj *keyobj) {
20122012
server.stat_expiredkeys++;
20132013
}
20142014

2015-
/* Propagate expires into slaves and the AOF file.
2016-
* When a key expires in the master, a DEL operation for this key is sent
2017-
* to all the slaves and the AOF file if enabled.
2018-
*
2019-
* This way the key expiry is centralized in one place, and since both
2020-
* AOF and the master->slave link guarantee operation ordering, everything
2021-
* will be consistent even if we allow write operations against expiring
2015+
/* Propagate an implicit key deletion into replicas and the AOF file.
2016+
* When a key was deleted in the master by eviction, expiration or a similar
2017+
* mechanism a DEL/UNLINK operation for this key is sent
2018+
* to all the replicas and the AOF file if enabled.
2019+
*
2020+
* This way the key deletion is centralized in one place, and since both
2021+
* AOF and the replication link guarantee operation ordering, everything
2022+
* will be consistent even if we allow write operations against deleted
20222023
* keys.
20232024
*
20242025
* This function may be called from:
20252026
* 1. Within call(): Example: Lazy-expire on key access.
20262027
* In this case the caller doesn't have to do anything
20272028
* because call() handles server.also_propagate(); or
2028-
* 2. Outside of call(): Example: Active-expire, eviction.
2029+
* 2. Outside of call(): Example: Active-expire, eviction, slot ownership changed.
20292030
* In this the caller must remember to call
20302031
* postExecutionUnitOperations, preferably just after a
2031-
* single deletion batch, so that DELs will NOT be wrapped
2032+
* single deletion batch, so that DEL/UNLINK will NOT be wrapped
20322033
* in MULTI/EXEC */
20332034
void propagateDeletion(redisDb *db, robj *key, int lazy) {
20342035
robj *argv[2];
@@ -2038,7 +2039,7 @@ void propagateDeletion(redisDb *db, robj *key, int lazy) {
20382039
incrRefCount(argv[0]);
20392040
incrRefCount(argv[1]);
20402041

2041-
/* If the master decided to expire a key we must propagate it to replicas no matter what..
2042+
/* If the master decided to delete a key we must propagate it to replicas no matter what.
20422043
* Even if module executed a command without asking for propagation. */
20432044
int prev_replication_allowed = server.replication_allowed;
20442045
server.replication_allowed = 1;

0 commit comments

Comments
 (0)