Skip to content

Make get_version_of_previous_write ordering test less probabilistic - #8262

Open
Amaury Chamayou (achamayou) wants to merge 4 commits into
mainfrom
achamayou-fantastic-eureka
Open

Make get_version_of_previous_write ordering test less probabilistic#8262
Amaury Chamayou (achamayou) wants to merge 4 commits into
mainfrom
achamayou-fantastic-eureka

Conversation

@achamayou

Copy link
Copy Markdown
Member

Closes #6640

Replaces the fixed 64-thread / 100-writes-per-thread workload in the get_version_of_previous_write ordering unit test with a bounded, stop-on-first-conflict harness.

  • Worker threads synchronize startup via a ready/start atomic gate.
  • Workers repeatedly call point_at_previous_write (retrying on FAIL_CONFLICT until SUCCESS) until an atomic stop flag is set.
  • Main thread waits until conflict_count > 0 or a 5 second steady_clock deadline, then signals stop and joins workers.
  • A separate flag records whether the conflict was seen before the deadline.
  • last_write_version is now derived from kv_store.current_version() after joining.

Validated by building kv_test and running the test repeatedly; formatting/ascii/copyright checks pass. No changelog entry needed (test-only).

Replace the fixed 64x100 write workload in the "get_version_of_previous_write
ordering" unit test with a bounded, stop-on-first-conflict harness. Worker
threads start together via a ready/start gate, then repeatedly call
point_at_previous_write until an atomic stop flag is set. The main thread
waits until a conflict is observed or a 5 second steady_clock deadline
elapses, then signals stop and joins all workers. Whether the conflict was
seen before the deadline is recorded separately so a late conflict during
drain does not mask a timeout. last_write_version is now derived from
kv_store.current_version() after joining, since writes_per_thread no longer
exists.

Closes #6640

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 11:13
@achamayou
Amaury Chamayou (achamayou) requested a review from a team as a code owner September 2, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is test-only and the new bounded harness aligns with the linked issue’s intent; the remaining feedback is a minor robustness improvement in test assertion strictness.

Pull request overview

Updates the KV contention unit test for get_version_of_previous_write ordering to reduce probabilistic failures by replacing a fixed-workload stress pattern with a bounded “run until first conflict (or timeout)” harness.

Changes:

  • Replace fixed thread/write-count loop with worker threads that retry point_at_previous_write() until a shared stop flag is set.
  • Add a coordinated start gate so contention begins simultaneously across worker threads.
  • Cap runtime with a steady-clock deadline and derive last_write_version from kv_store.current_version() after joining workers.

Custom instructions used:

  • .github/copilot-instructions.md
File summaries
File Description
src/kv/test/kv_contention.cpp Refactors the ordering contention test to stop after observing the first conflict (or hitting a deadline), reducing flakiness while preserving post-run chain validation.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/kv/test/kv_contention.cpp
Stop the test at the primary timeout failure rather than continuing into assertions that assume a conflict occurred.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modify get_version_of_previous_write ordering unit test to be less probabilistic

2 participants