<commit_before>start_server {} {
    set redis_host [srv 0 host]
    set redis_port [srv 0 port]

    r config set save "1 1"
    set load_handle0 [start_bg_complex_data $redis_host $redis_port 0 1000000]
    test {Detect write load to redis} {
        wait_for_condition 50 10000 {
            [r dbsize] > 1000
        } else {
            fail "Can't detect write load from background clients."
        }
    }
    r config set swap-debug-swapout-notify-delay 100

    for {set j 0} {$j < 10} {incr j} {
        test "check rdb generated by periodic bgsave round$j" {
            after 1000
            r debug reload nosave
            r ping
        }
    }

    r config set save ""

    for {set j 0} {$j < 10} {incr j} {
        test "check rdb generated by bgsave schedule round$j" {
            after 1000
            r bgrewriteaof
            r bgsave schedule
            waitForBgrewriteaof r
            after 120 ;# serverCron only schedule bgsave once in 100ms
            waitForBgsave r
            wait_for_condition 10 5000 {
                [s rdb_bgsave_in_progress] == 0
            } else {
                fail "Bgsave timeout."
            }
            r debug reload nosave<commit_msg>fix bgsave.tcl failed occasionally: bgsave inprogress.<commit_after>start_server {} {
    set redis_host [srv 0 host]
    set redis_port [srv 0 port]

    r config set save "1 1"
    set load_handle0 [start_bg_complex_data $redis_host $redis_port 0 1000000]
    test {Detect write load to redis} {
        wait_for_condition 50 10000 {
            [r dbsize] > 1000
        } else {
            fail "Can't detect write load from background clients."
        }
    }
    r config set swap-debug-swapout-notify-delay 100

    for {set j 0} {$j < 10} {incr j} {
        test "check rdb generated by periodic bgsave round$j" {
            after 1000
            r debug reload nosave
            r ping
        }
    }

    r config set save ""
    waitForBgsave r

    for {set j 0} {$j < 10} {incr j} {
        test "check rdb generated by bgsave schedule round$j" {
            after 1000
            r bgrewriteaof
            r bgsave schedule
            waitForBgrewriteaof r
            after 120 ;# serverCron only schedule bgsave once in 100ms
            waitForBgsave r
            wait_for_condition 10 5000 {
                [s rdb_bgsave_in_progress] == 0
            } else {
                fail "Bgsave timeout."
            }
            r debug reload nosave
{'fraction_non_alphanumeric': 0.06388107673764563, 'fraction_numerical': 0.043390920048212135, 'mean_word_length': 1.6377118644067796, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4020602', 'n_tokens_mistral': 863, 'n_tokens_neox': 736, 'n_words': 262}