Skip to content

test(redis): deflake Misskey/BullMQ compat tests on CI#779

Merged
bootjp merged 1 commit into
mainfrom
fix/redis-compat-test-flakes
May 17, 2026
Merged

test(redis): deflake Misskey/BullMQ compat tests on CI#779
bootjp merged 1 commit into
mainfrom
fix/redis-compat-test-flakes

Conversation

@bootjp
Copy link
Copy Markdown
Owner

@bootjp bootjp commented May 17, 2026

Summary

Two compat tests under adapter/ flaked intermittently on ubuntu-latest CI in recent PRs (#755, #762). Both are timing races against tight TTLs / block timeouts that slip past on slow CI runners under -race. This PR widens the windows. No production code or semantics change.

TestRedis_MisskeyConnectionCompatibility

SET ... PX 200 NX × 2 — when the gap between the two consecutive Raft-replicated SETs exceeded 200ms, the first key expired before the second SET, the NX took effect, and the require.ErrorIs(redis.Nil) assertion failed.

Fix: PX 200 → PX 2000 (10× safety margin). The downstream time.Sleep(1100ms) + Get-nil expiry check is unaffected — that path tests the EX 1 timer set later, which is a separate TTL.

TestRedis_BullMQDirectCommands

XRead Block: time.Second and BZPopMin(ctx, time.Second, ...) — when the producing XAdd / ZAdd Raft commit took longer than ~900ms, the blocking read timed out with redis.Nil and the test failed with "received nil error" rather than the expected result.

Fix: Block / timeout 1s → 5s; outer select deadline 2s → 6s.

Self-review

  • Data loss: N/A (test-only change).
  • Concurrency / distributed failures: N/A (no production code paths touched).
  • Performance: Tests take slightly longer in the worst-case timeout, but pass faster than before in the common case (no flake retries).
  • Data consistency: N/A (no semantics changed; only TTL / block timeout values).
  • Test coverage: Both tests retain identical assertions. Verified with -count=3 -race locally.

Test plan

  • go test -race -run 'TestRedis_MisskeyConnectionCompatibility|TestRedis_BullMQDirectCommands' -count=3 ./adapter/ → pass
  • CI green on ubuntu-latest

Summary by CodeRabbit

  • Tests
    • Increased timeout durations for Redis stream and sorted-set operations to improve test reliability on slower CI environments.
    • Adjusted Redis lock test TTL values to reduce timing-related test flakiness.

Review Change Stack

Two compat tests flaked intermittently on ubuntu-latest:

  - `TestRedis_MisskeyConnectionCompatibility`
    The two consecutive `SET ... PX 200 NX` calls at line 28 and
    line 32 race against the 200ms TTL: when the gap between the
    two RPCs slipped past 200ms (slow CI scheduling + Raft commit
    latency under -race), the first key expired before the second
    SET, the NX took effect, and the `require.ErrorIs(redis.Nil)`
    assertion failed. PX bumped to 2000ms (10× safety margin).
    The downstream `time.Sleep(1100 * time.Millisecond)` + Get-nil
    assertion is unaffected because that path tests the EX 1
    timer set at line 35, which is a separate TTL.

  - `TestRedis_BullMQDirectCommands`
    The `XRead` and `BZPopMin` blocking calls used `Block: 1s` /
    `BZPopMin(ctx, time.Second, ...)`. When the producing XAdd /
    ZAdd Raft commit took longer than ~900ms (the window left
    after the 100ms `time.Sleep` synchronization barrier), the
    blocking read timed out with `redis.Nil` and the test failed
    with "received nil error" rather than the expected XStream /
    ZWithKey result. Block / timeout bumped to 5s, and the outer
    `select` deadline bumped from 2s to 6s to keep it bounded by
    the inner block.

These are timing-window adjustments only — no production code or
semantics change, no fail-closed / error-handling change. Caller
audit not applicable.

Verified locally with:
  GOCACHE=$(pwd)/.cache go test -race \
    -run 'TestRedis_MisskeyConnectionCompatibility|TestRedis_BullMQDirectCommands' \
    -count=3 ./adapter/
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d39dcd08-87be-4cfe-944d-4103ea4cd6a0

📥 Commits

Reviewing files that changed from the base of the PR and between e9b015c and 6161c24.

📒 Files selected for processing (2)
  • adapter/redis_bullmq_compat_test.go
  • adapter/redis_misskey_compat_test.go

📝 Walkthrough

Walkthrough

This PR increases timeout parameters in two Redis compatibility tests to prevent flakiness on slow CI. redis_bullmq_compat_test.go extends XRead and BZPopMin blocking durations from 1s to 5s with matching watchdog increases. redis_misskey_compat_test.go extends lock TTL from 200ms to 2000ms. No control flow or assertions change.

Changes

Test timeout resilience on slow CI

Layer / File(s) Summary
Redis stream and sorted-set blocking resilience
adapter/redis_bullmq_compat_test.go
XRead block duration and timeout watchdog increased from 1s/2s to 5s/6s; BZPopMin block duration and timeout watchdog similarly increased from 1s/2s to 5s/6s to allow blocking operations more time for entries to become visible on slow CI.
Misskey lock TTL resilience
adapter/redis_misskey_compat_test.go
Redis SET with PX TTL increased from 200ms to 2000ms for two consecutive NX operations, with updated comments explaining the longer TTL prevents expiry race conditions during subsequent assertions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Five seconds now, not just one,
Redis waits for reads to run—
No more races, no more shame,
CI stability's the game!
Two whole seconds for the lock,
Tick-tock, tick-tock! ⏰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing flaky Redis compatibility tests on CI by adjusting timeouts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/redis-compat-test-flakes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request increases various timeouts and TTL values in the Redis compatibility tests to prevent flaky failures on slow CI runners. Specifically, it extends the blocking duration for XRead and BZPopMin commands, increases the test case timeouts, and raises the TTL for SET ... NX operations to ensure Raft-replicated commands do not race against expiry. I have no feedback to provide.

@bootjp bootjp merged commit f0a18fe into main May 17, 2026
10 checks passed
@bootjp bootjp deleted the fix/redis-compat-test-flakes branch May 17, 2026 14:21
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.

1 participant