redict/tests/modules
Eduardo Semprebon 91d0c758e5
Replica keep serving data during repl-diskless-load=swapdb for better availability (#9323)
For diskless replication in swapdb mode, considering we already spend replica memory
having a backup of current db to restore in case of failure, we can have the following benefits
by instead swapping database only in case we succeeded in transferring db from master:

- Avoid `LOADING` response during failed and successful synchronization for cases where the
  replica is already up and running with data.
- Faster total time of diskless replication, because now we're moving from Transfer + Flush + Load
  time to Transfer + Load only. Flushing the tempDb is done asynchronously after swapping.
- This could be implemented also for disk replication with similar benefits if consumers are willing
  to spend the extra memory usage.

General notes:
- The concept of `backupDb` becomes `tempDb` for clarity.
- Async loading mode will only kick in if the replica is syncing from a master that has the same
  repl-id the one it had before. i.e. the data it's getting belongs to a different time of the same timeline. 
- New property in INFO: `async_loading` to differentiate from the blocking loading
- Slot to Key mapping is now a field of `redisDb` as it's more natural to access it from both server.db
  and the tempDb that is passed around.
- Because this is affecting replicas only, we assume that if they are not readonly and write commands
  during replication, they are lost after SYNC same way as before, but we're still denying CONFIG SET
  here anyways to avoid complications.

Considerations for review:
- We have many cases where server.loading flag is used and even though I tried my best, there may
  be cases where async_loading should be checked as well and cases where it shouldn't (would require
  very good understanding of whole code)
- Several places that had different behavior depending on the loading flag where actually meant to just
  handle commands coming from the AOF client differently than ones coming from real clients, changed
  to check CLIENT_ID_AOF instead.

**Additional for Release Notes**
- Bugfix - server.dirty was not incremented for any kind of diskless replication, as effect it wouldn't
  contribute on triggering next database SAVE
- New flag for RM_GetContextFlags module API: REDISMODULE_CTX_FLAGS_ASYNC_LOADING
- Deprecated RedisModuleEvent_ReplBackup. Starting from Redis 7.0, we don't fire this event.
  Instead, we have the new RedisModuleEvent_ReplAsyncLoad holding 3 sub-events: STARTED,
  ABORTED and COMPLETED.
- New module flag REDISMODULE_OPTIONS_HANDLE_REPL_ASYNC_LOAD for RedisModule_SetModuleOptions
  to allow modules to declare they support the diskless replication with async loading (when absent, we fall
  back to disk-based loading).

Co-authored-by: Eduardo Semprebon <edus@saxobank.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
2021-11-04 10:46:50 +02:00
..
aclcheck.c Adding ACL support for modules (#9309) 2021-09-23 08:52:56 +03:00
auth.c Fixed some documentation 2019-12-17 07:49:21 +00:00
basics.c fix valgrind issues with long double module test (#9709) 2021-11-01 13:41:35 +02:00
blockedclient.c Fix module blocked clients RESP version (#9634) 2021-10-21 14:01:10 +03:00
blockonbackground.c Fix memory leak due to missing freeCallback in blockonbackground moduleapi test (#9499) 2021-09-14 15:14:09 +03:00
blockonkeys.c Release clients blocked on module commands in cluster resharding and down state (#9483) 2021-10-19 11:50:37 +03:00
commandfilter.c Tests: fix commandfilter crash on alpine. (#9307) 2021-08-02 15:50:45 +03:00
datatype2.c Modify mem_usage2 module callback to enable to take sample_size argument (#9612) 2021-10-17 17:31:06 +03:00
datatype.c Modules: add RM_LoadDataTypeFromStringEncver (#9537) 2021-09-30 11:21:32 +03:00
defragtest.c Enhance mem_usage/free_effort/unlink/copy callbacks and add GetDbFromIO api. (#8999) 2021-06-16 09:45:49 +03:00
fork.c Moved RMAPI_FUNC_SUPPORTED location such that it will be visible to modules (#8037) 2020-11-09 10:46:23 +02:00
getkeys.c Replace deprecated REDISMODULE_POSTPONED_ARRAY_LEN in module tests and examples (#9677) 2021-10-25 12:00:43 +03:00
hash.c Modules: In RM_HashSet, add COUNT_ALL flag and set errno (#8446) 2021-02-15 11:40:05 +02:00
hooks.c Add Module API for version and compatibility checks (#7865) 2020-10-11 17:21:58 +03:00
infotest.c Escape unsafe field name characters in INFO. (#8492) 2021-02-15 17:08:53 +02:00
keyspace_events.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
keyspecs.c A better approach for COMMAND INFO for movablekeys commands (#8324) 2021-09-15 11:10:29 +03:00
list.c Modules: Add remaining list API functions (#8439) 2021-09-14 17:48:06 +03:00
Makefile Use 'gcc' instead of 'ld' to link test modules. (#9710) 2021-10-31 16:25:57 +02:00
misc.c Add RedisModule_KeyExists (#9600) 2021-10-18 22:21:19 +03:00
propagate.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
reply.c Add RM_ReplyWithBigNumber module API (#9639) 2021-10-25 11:31:20 +03:00
scan.c Replace deprecated REDISMODULE_POSTPONED_ARRAY_LEN in module tests and examples (#9677) 2021-10-25 12:00:43 +03:00
stream.c Replace deprecated REDISMODULE_POSTPONED_ARRAY_LEN in module tests and examples (#9677) 2021-10-25 12:00:43 +03:00
subcommands.c Treat subcommands as commands (#9504) 2021-10-20 11:52:57 +03:00
test_lazyfree.c Modules callbacks for lazy free effort, and unlink (#7912) 2020-11-16 10:34:04 +02:00
testrdb.c Replica keep serving data during repl-diskless-load=swapdb for better availability (#9323) 2021-11-04 10:46:50 +02:00
timer.c Add timer module API tests. (#8041) 2020-11-11 22:57:33 +02:00
zset.c RM_ZsetRem: Delete key if empty (#8453) 2021-02-05 19:54:01 +02:00