redict/tests/integration
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
..
aof-race.tcl TLS: Connections refactoring and TLS support. 2019-10-07 21:06:13 +03:00
aof.tcl Fix not waiting for data loading to complete in AOF tests (#9683) 2021-10-26 14:08:09 +03:00
block-repl.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
convert-ziplist-hash-on-load.tcl Replace all usage of ziplist with listpack for t_hash (#8887) 2021-08-10 09:18:49 +03:00
convert-ziplist-zset-on-load.tcl Replace all usage of ziplist with listpack for t_zset (#9366) 2021-09-09 18:18:53 +03:00
convert-zipmap-hash-on-load.tcl Replace all usage of ziplist with listpack for t_hash (#8887) 2021-08-10 09:18:49 +03:00
corrupt-dump-fuzzer.tcl corrupt-dump-fuzzer test, avoid creating junk keys (#9302) 2021-08-05 22:57:05 +03:00
corrupt-dump.tcl Add support for list type to store elements larger than 4GB (#9357) 2021-11-03 20:47:18 +02:00
dismiss-mem.tcl Use madvise(MADV_DONTNEED) to release memory to reduce COW (#8974) 2021-08-04 23:01:46 +03:00
failover.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
logging.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
psync2-master-restart.tcl Replication backlog and replicas use one global shared replication buffer (#9166) 2021-10-25 09:24:31 +03:00
psync2-pingoff.tcl Fix race condition in psync2-pingoff test (#9712) 2021-11-01 16:07:08 +02:00
psync2-reg.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
psync2.tcl Make sure execute SLAVEOF command in the right order in psync2 test. (#9316) 2021-08-05 11:26:09 +03:00
rdb.tcl Add support for list type to store elements larger than 4GB (#9357) 2021-11-03 20:47:18 +02:00
redis-benchmark.tcl Added URI support to redis-benchmark (cli and benchmark share the same uri-parsing methods) (#9314) 2021-09-14 19:45:06 +03:00
redis-cli.tcl redis-cli ASK redirect test: Add retry loop to fix timing issue (#9315) 2021-08-05 08:20:30 +03:00
replication-2.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
replication-3.tcl Allow master to replicate command longer than replica's query buffer limit (#9340) 2021-08-08 17:34:11 -07:00
replication-4.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
replication-buffer.tcl Fix timing issue in replication buffer test (#9697) 2021-10-29 08:04:12 +03:00
replication-psync.tcl Improve test suite to handle external servers better. (#9033) 2021-06-09 15:13:24 +03:00
replication.tcl Replica keep serving data during repl-diskless-load=swapdb for better availability (#9323) 2021-11-04 10:46:50 +02:00