Skip to content

Isolate Redis blocking replay workers - #1142

Merged
bootjp merged 2 commits into
mainfrom
feature/redis-blocking-replay-isolation
Jul 22, 2026
Merged

Isolate Redis blocking replay workers#1142
bootjp merged 2 commits into
mainfrom
feature/redis-blocking-replay-isolation

Conversation

@bootjp

@bootjpbootjp commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Author: bootjp

Summary

  • add a dedicated async queue and worker limit for mutating blocking-command secondary replays
  • derive blocking replay concurrency from unused secondary backend pool capacity
  • keep BZPOP replay misses visible as command miss metrics without counting them as secondary write failures

Verification

  • go test ./proxy -count=1
  • go test ./cmd/redis-proxy -count=1
  • golangci-lint run ./proxy ./cmd/redis-proxy --timeout=5m

Risk

  • limits normal secondary writes plus blocking replay workers to the secondary backend pool so long blocking replays do not starve producer writes

Summary by CodeRabbit

  • 新機能

    • セカンダリへのブロッキングコマンド再生に、同時実行数とキュー容量の設定を追加しました。
    • ブロッキング再生を通常の書き込み処理から分離し、通常処理のワーカーを圧迫しないよう改善しました。
    • 再生を無効化した場合は、セカンダリへの送信を停止できます。
  • 改善

    • 設定値の妥当性検証を強化し、実行プール容量を超える設定を防止します。
    • 再生結果や再試行、ミスのメトリクスとエラー記録を整理しました。

@coderabbitai

coderabbitaiBot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83157d2d-592a-468f-8676-a353ee06ae3d

📥 Commits

Reviewing files that changed from the base of the PR and between e4ba106 and 9e00844.

📒 Files selected for processing (6)
  • cmd/redis-proxy/main.go
  • cmd/redis-proxy/main_test.go
  • proxy/async_queue.go
  • proxy/config.go
  • proxy/dualwrite.go
  • proxy/proxy_test.go

📝 Walkthrough

Walkthrough

Secondary blocking replay に専用の設定、容量検証、セマフォ、キュー、ディスパッチャを追加し、Blocking コマンドの replay 経路と positive integer replay の結果処理を更新しています。

Changes

Blocking replay の分離実行

Layer / File(s)Summary
Runtime オプションと容量導出
cmd/redis-proxy/main.go, cmd/redis-proxy/main_test.go, proxy/config.go
Blocking replay の CLI 設定、ProxyConfig フィールド、非負値検証、write との合計容量検証、既定同時実行数の導出を追加しています。
専用キューとディスパッチャ
proxy/dualwrite.go, proxy/async_queue.go
Blocking replay 用のセマフォ・キュー・容量計算を追加し、容量がある場合のみ専用ディスパッチャを起動します。
Blocking コマンドのリプレイ経路
proxy/dualwrite.go, proxy/proxy_test.go
Mutating blocking command の replay を専用経路へ切り替え、通常 write worker の分離、無効化時の動作、既存 replay 条件をテストしています。
Positive integer replay の結果処理
proxy/dualwrite.go, proxy/proxy_test.go
結果判定とリトライ処理をヘルパへ分離し、no_effect を通常の secondary write error と区別してメトリクスへ反映します。

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant Client
participant DualWriter
participant blockingReplayQueue
participant Secondary
Client->>DualWriter: Blocking command
DualWriter->>blockingReplayQueue: goBlockingReplay で replay を投入
blockingReplayQueue->>Secondary: 専用 dispatcher が replay 実行
Secondary-->>DualWriter: replay 結果
DualWriter-->>Client: Blocking 結果
Loading

Possibly related PRs

  • bootjp/elastickv#531: Secondary write の失敗記録・メトリクス処理に関連します。
  • bootjp/elastickv#1134: Secondary replay のオプション検証と非同期キュー制御に関連します。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ Passedタイトルは Redis の blocking replay worker を分離するという PR の主目的を簡潔に表しています。
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@bootjp

Copy link
Copy Markdown
OwnerAuthor

@codex review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:a8fd7880c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadcmd/redis-proxy/main.go Outdated
Comment on lines +293 to +294
func defaultSecondaryBlockingReplayConcurrency(poolSize, writeConcurrency int) int {
return atLeastOne(poolSize - writeConcurrency)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow one-connection secondary pools to start

When the CLI is run in a dual-write mode with -elastickv-pool-size=1 (or elastickv-primary with -primary-pool-size=1), this default derives writeConcurrency=1 and blockingReplayConcurrency=1; validateSecondaryConcurrency then rejects the config because their sum exceeds the single secondary connection. Since 0 for -secondary-blocking-replay-concurrency means “derive” and negative values are rejected, there is no CLI value that disables the new blocking replay worker, so deployments that intentionally use a single secondary backend connection can no longer start.

Useful? React with 👍 / 👎.

@bootjp

Copy link
Copy Markdown
OwnerAuthor

Addressed the single-connection secondary pool case by deriving blocking replay concurrency to 0 when no secondary pool capacity remains after normal writes. Added tests for the disabled replay path.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit:9e00844e69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bootjp
bootjp merged commit cb92902 into mainJul 22, 2026
10 checks passed
@bootjp
bootjp deleted the feature/redis-blocking-replay-isolation branch July 22, 2026 14:34
Sign up for freeto 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

@bootjp