• Binbin's avatar
    Fix races in swapdb async_loading test (#11613) · 5f69ce0d
    Binbin authored
    
    
    There is a race in the test:
    ```
    *** [err]: Diskless load swapdb (async_loading): new database is exposed after swapping in tests/integration/replication.tcl
    Expected 'myvalue' to be equal to '' (context: type eval line 3 cmd {assert_equal [$replica GET mykey] ""} proc ::test)
    ```
    
    When doing `$replica GET mykey`, the replica is using the old database.
    The reason may be that when doing `master client kill type replica`,
    the replica did not yet realize it got disconnected from the master.
    So the check of master_link_status fails, and the replica did not
    finish the swapdb and the loading.
    
    In that case, i think the solution is to check the sync_full stat on
    the master and wait for it to get incremented from the previous value.
    i.e. the way to know that we're done with the full sync is not to check
    that our state is up (could be up if we check too early), but rather
    check that the sync_full counter got incremented.
    
    During the reviewing, we found another race, in Aborted testType,
    the `$master config set rdb-key-save-delay 10000` is done after we
    already initiated the disconnection, so there's a chance that the replica
    will attempt to reconnect before that call, in which case if we fork() before
    it, the config will not take effect. Move it to above the disconnection.
    Co-authored-by: default avatarOran Agra <oran@redislabs.com>
    5f69ce0d
replication.tcl 60 KB