Skip to content

Replace fixed timer waits with condition polling in two flaky async tests - #14042

Open
fbartho wants to merge 4 commits into
warpdotdev:masterfrom
fbartho:fb/13979-deflake-fixed-timer-waits
Open

fbartho wants to merge 4 commits into
warpdotdev:masterfrom
fbartho:fb/13979-deflake-fixed-timer-waits

Conversation

@fbartho

@fbartho fbartho commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #13979

Mechanism

Two tests used a fixed real-time Timer::after wait as their sole synchronization step before asserting on async state. Timer is a real OS-backed timer (async_io::Timer), not a virtual clock — under full-parallel suite load, the awaited async work can take longer than the fixed sleep budget even though the timer itself fires on schedule. That makes the failures load-sensitive and intermittent: they depend on contention at run time, not process-global state (unlike the sibling flake clusters #13972–#13975, which are all global-state races).

Correction to the ticket

The ticket names test_pending_metadata_update_with_polling at line 2601 — on current master that function contains no Timer::after; line 2601 is where its signature begins. The quoted 10s wait lives at line 2578 inside the immediately-preceding test, test_metadata_after_trash_item_failure, whose code matches the ticket's described mechanism and snippet exactly. This PR fixes that test. (Also noted on the issue.)

Changes

  • test_metadata_after_trash_item_failure (update_manager_tests.rs): the fixed 10s "wait for retries to exhaust" sleep is now wait_for_trashed_status_for_object(): a condition poll on metadata().trashed_ts wrapped in the repo's own with_timeout primitive with a named 30s Duration ceiling — the deadline is stated directly rather than encoded as an iteration count. Polling is the reachable primitive here: await_spawned_future resolves a single spawned hop and cannot follow the retry cascade (each backoff re-spawns a fresh future whose handle is discarded), and the model-update event at the clear site is callback-based with no awaitable bridge; the sibling helper wait_for_num_spawned_futures waits the same way.
  • test_cloud_pref_not_synced_when_current_value_not_syncable (cloud_preferences_syncer_tests.rs): removed a fixed 1s sleep immediately before await_spawned_futures(…), which already polls with a 5s ceiling; the awaited futures are spawned synchronously earlier in the test, so the extra fixed wait was redundant.

Stability evidence

  • test_metadata_after_trash_item_failure: 30/30 in a standalone loop (~3.6s each — the retry backoff itself still has to elapse; polling replaces only the fixed ceiling).
  • test_cloud_pref_not_synced_when_current_value_not_syncable: 30/30, ~0.14–0.53s each (faster now that the redundant wait is gone).
  • Full cargo nextest run -p warp: 5792/5792 passed.
  • cargo build -p warp --tests + cargo clippy -p warp --lib --tests: zero warnings.

Testing

  • I have manually tested my changes locally with ./script/run
    • Not applicable: the issue only applies to test builds.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Closes warpdotdev#13979

test_metadata_after_trash_item_failure and
test_cloud_pref_not_synced_when_current_value_not_syncable used a
fixed real-time Timer::after wait as their only synchronization
before asserting on async state. Under contended/parallel test runs,
the wall-clock time for the awaited work to actually complete can
exceed the fixed budget even though the retry backoff itself is
short, making both load-sensitive.

Replace the fixed 10s "wait for retries to exhaust" sleep in the
first test with a poll loop on trashed_ts, and drop the fixed 1s
sleep before the second test's existing await_spawned_futures poll
loop (which already retries for up to 5s).
@cla-bot cla-bot Bot added the cla-signed label Jul 20, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jul 20, 2026
The wait_for_trashed_status_for_object helper expressed its ceiling as
a fixed for _ in 0..300 iteration count, which encodes 30s only
indirectly and would drift if the per-iteration cost changed. Wrap the
poll in with_timeout(30s) so the ceiling is a stated Duration, and
name the ceiling and interval as constants.

The comment now states only facts: what is awaited, that the condition
cannot change until the retry backoff elapses, and that this async
stack exposes no awaitable model-update signal a test can subscribe to
(await_spawned_future resolves on a single spawned hop, not the
delayed-respawn retry cascade), so a bounded poll is the reachable
primitive.
@fbartho

fbartho commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Note: this is right on the bubble for me in terms of which approach is correct / best matches the style / concurrency practices in this repo. I don't love that it is a sleeping loop, but I think it's safer with this implementation.

I'd love to hear what a maintainer thinks about this approach.

@fbartho
fbartho marked this pull request as ready for review July 21, 2026 01:28
@warp-for-oss

warp-for-oss Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@fbartho

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13979, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

warp-for-oss[bot]
warp-for-oss Bot previously requested changes Jul 21, 2026

@warp-for-oss warp-for-oss Bot 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.

@fbartho

Every PR must be linked to a same-repo issue before Oz can review it.

This PR is linked to #13979, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.

See the contribution guidelines for the full readiness model.

Powered by Oz

@github-actions

Copy link
Copy Markdown
Contributor

Hi @fbartho — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity.

@fbartho

fbartho commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

(Just commenting so stale-bot doesn't think this is dead).

@seemeroland

Copy link
Copy Markdown
Contributor

/oz-review

@warp-for-oss

warp-for-oss Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

@seemeroland

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @seemeroland.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss
warp-for-oss Bot dismissed their stale review July 29, 2026 18:02

Oz no longer requests changes for this pull request after the latest automated review.

@warp-for-oss warp-for-oss Bot 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.

Overview

This PR replaces fixed timer sleeps in two async tests with condition-based waiting or an existing polling helper. The changes are test-only and preserve bounded waits while reducing load-sensitive flakiness.

Concerns

  • No blocking concerns found.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss
warp-for-oss Bot requested a review from seemeroland July 29, 2026 18:02

@seemeroland seemeroland 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.

Thank you!

@seemeroland
seemeroland enabled auto-merge (squash) July 29, 2026 23:25
@fbartho

fbartho commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@seemeroland the PR is approved, but I don't have a merge button, is that something you need to do? or what should I do to get this merged? Thanks!

@fbartho

fbartho commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@oss-maintainers — This was approved but not merged. Would you like anything else?

Wraps a multi-method chain in the trashed-status poll helper to satisfy cargo fmt.
auto-merge was automatically disabled September 11, 2026 00:52

Head branch was pushed to by a user without write access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

app tests: two async tests use fixed real-wall-clock Timer::after waits with no retry margin, and fail intermittently under full-parallel PR-gate load

2 participants