From acf3495eb823df8d1f358b1fe59b759fcc49666f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Sun, 28 Nov 2021 10:26:28 +0100 Subject: Sort out the mess around writable replicas and lookupKeyRead/Write (#9572) Writable replicas now no longer use the values of expired keys. Expired keys are deleted when lookupKeyWrite() is used, even on a writable replica. Previously, writable replicas could use the value of an expired key in write commands such as INCR, SUNIONSTORE, etc.. This commit also sorts out the mess around the functions lookupKeyRead() and lookupKeyWrite() so they now indicate what we intend to do with the key and are not affected by the command calling them. Multi-key commands like SUNIONSTORE, ZUNIONSTORE, COPY and SORT with the store option now use lookupKeyRead() for the keys they're reading from (which will not allow reading from logically expired keys). This commit also fixes a bug where PFCOUNT could return a value of an expired key. Test modules commands have their readonly and write flags updated to correctly reflect their lookups for reading or writing. Modules are not required to correctly reflect this in their command flags, but this change is made for consistency since the tests serve as usage examples. Fixes #6842. Fixes #7475. --- tests/modules/stream.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/modules/stream.c') diff --git a/tests/modules/stream.c b/tests/modules/stream.c index b82568b94..65762a399 100644 --- a/tests/modules/stream.c +++ b/tests/modules/stream.c @@ -238,19 +238,19 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) if (RedisModule_Init(ctx, "stream", 1, REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx, "stream.add", stream_add, "", + if (RedisModule_CreateCommand(ctx, "stream.add", stream_add, "write", 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx, "stream.addn", stream_addn, "", + if (RedisModule_CreateCommand(ctx, "stream.addn", stream_addn, "write", 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx, "stream.delete", stream_delete, "", + if (RedisModule_CreateCommand(ctx, "stream.delete", stream_delete, "write", 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx, "stream.range", stream_range, "", + if (RedisModule_CreateCommand(ctx, "stream.range", stream_range, "write", 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; - if (RedisModule_CreateCommand(ctx, "stream.trim", stream_trim, "", + if (RedisModule_CreateCommand(ctx, "stream.trim", stream_trim, "write", 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; -- cgit v1.2.1