fix(tests): resolve flaky data mismatch in kvrocks2redis consistency check - #3647
rishi919-rgb wants to merge 1 commit into
Conversation
|
Hi @rishi919-rgb, Thank you for your pull request. Please review our Contributing Guide. Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed. |
|
Hi @rishi919-rgb Please read the Contributing Guide and follow our AI usage guidelines. Thanks. |
|
Hi @jihuayu, Thanks for the reminder! I've reviewed the Contributing Guide thoroughly and am happy to clarify the rationale and details of this patch. I investigated issue #3153 reported by @git-hulk regarding the intermittent Here is what was identified and addressed:
All Python syntax checks and pre-commit workflows pass cleanly. Please let me know if you would like any adjustments to the timeout parameters or structure! |
…check - Introduce _wait_and_compare helper with adequate retry attempts (up to 3s) for asynchronous WAL replication to destination Redis - Fix NameError in compare_redis_data where undefined key was referenced instead of keys[0] - Apply retry logic to key_file comparison - Ensure user_key.log in populate-kvrocks.py is flushed after writes and closed on exit - Fixes apache#3153
fc4256d to
c452be8
Compare
|
I think you failed to clarify your AI usage and follow the AI policy. Closed. |
|
Hi @PragmaTwice @jihuayu, Apologies for the misunderstanding earlier — I did not intend to sidestep the policy. To clarify transparently in accordance with the Kvrocks AI Guidelines: I used an AI coding assistant to help analyze the test failure logs in issue #3153 and draft the initial patch. Following that, I personally inspected the test code ( I take full responsibility for this contribution and am committed to maintaining it and addressing any review feedback. If acceptable, could we please reopen this PR for review? Thank you for your guidance and patience. |
Fixes #3153.
Refs #3516.
Motivation
In CI test runs for
kvrocks2redis,check_consistency.pyperiodically fails with data mismatches such as:Because
kvrocks2redisasynchronously replays WAL batches to destination Redis, under heavily loaded CI runners, replication may take slightly longer than the previous 3 attempts (totaling ~0.3s). When this threshold is exceeded before the WAL entry is processed,dst_dataremainsNone(or stale), causing false-positive CI failures.Additionally:
compare_redis_data(key_file), line 89 previously raisedAssertionError(f"Data mismatch for key '{key}'...")wherekeywas undefined, resulting in aNameError: name 'key' is not defined.key_filecomparison had no retry mechanism.user_key.loginpopulate-kvrocks.pywas never flushed or closed.Solution
_wait_and_comparehelper incheck_consistency.pythat polls up to 30 attempts at 100ms intervals (up to 3.0s total timeout). It returns immediately as soon assrc_data == dst_data, so passing tests incur zero unnecessary delay while accommodating CI scheduling spikes._wait_and_comparein both_import_and_compareandcompare_redis_data(key_file).NameErrorincompare_redis_databy referencingkeys[0].user_key.loginpopulate-kvrocks.pyis flushed after writes and closed on script exit.