Skip to content

redis-proxy: raise ElasticKV connection budget#1154

Merged
bootjp merged 19 commits into
mainfrom
feature/redis-proxy-connection-budget
Jul 23, 2026
Merged

redis-proxy: raise ElasticKV connection budget#1154
bootjp merged 19 commits into
mainfrom
feature/redis-proxy-connection-budget

Conversation

@bootjp

@bootjp bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Raise the default ElasticKV redis-proxy command pool from 64 to 128.
  • Raise the ElasticKV Redis server per-peer default cap to cover two proxy replicas sharing one client IP plus PubSub/shadow headroom.
  • Update HA compose defaults, deployment docs, and tests so the proxy and server-side connection budgets stay aligned.

Root cause

When multiple redis-proxy replicas or dedicated PubSub connections share one client IP, the old server-side per-peer cap could be exhausted. ElasticKV then rejected new Redis connections, which surfaced to the proxy/client side as connection resets and async secondary drops under load.

Validation

  • go test ./proxy ./cmd/redis-proxy -count=1
  • go test ./adapter -run 'TestRedisPeerLimiter|TestRedisLeaderClientPool|TestRedisBlockingLeaderClientUsesDedicatedBudgetedPool' -count=1
  • go test ./... -run '^$'
  • golangci-lint run ./proxy ./cmd/redis-proxy ./adapter --timeout=5m

Summary by CodeRabbit

  • 機能改善
    • Redisプロキシのデフォルト接続プールサイズを64→192に拡大
    • セカンダリ書き込み/スクリプト同時実行数の既定値算出と上限を更新
    • ブロッキングリプレイの並列上限を20→32に引き上げ
    • secondary-script-timeout(Luaスクリプト用)を追加
  • 動作改善
    • セカンダリ書き込み/(Lua含む)処理のタイムアウトを見直し(既定は最大30秒、Luaは別上限で制御)
    • Lua/コマンド種別に応じた読み取りタイムアウト適用を改善
    • 高速ZREM(ZREMFAST)が非対応の場合は通常のZREMへフォールバック
  • ドキュメント
    • docker/HA例、既定値とチューニング指針を更新
  • テスト
    • 既定値・タイムアウト・キュー処理・高速削除経路のテストを追加/更新

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

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bootjp, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4f0bbb1-1037-4bb2-8437-7c0c070a87ec

📥 Commits

Reviewing files that changed from the base of the PR and between 40370e4 and 424e35d.

📒 Files selected for processing (5)
  • adapter/dynamodb_test.go
  • proxy/backend.go
  • proxy/dualwrite.go
  • proxy/leader_aware_backend.go
  • proxy/proxy_test.go
📝 Walkthrough

Walkthrough

Redis proxyの容量、二次処理の並列度と期限、ZREM replay、Lua cleanup、HLC lease更新、起動ゲートの時刻機能を変更し、関連するテスト、設定例、監視、運用ドキュメントを更新した。

Changes

Redis proxyと二次処理

Layer / File(s) Summary
容量、接続上限、タイムアウト基盤
proxy/backend.go, proxy/leader_aware_backend.go, proxy/config.go, adapter/redis_peer_limiter.go, proxy/proxy_test.go
ElasticKVプールサイズ、per-peer接続上限、secondary timeout、read timeout APIとパイプライン経路を更新した。
二次並列度とスクリプト期限
cmd/redis-proxy/*, proxy/dualwrite.go, proxy/async_queue.go, proxy/proxy.go, proxy/pubsub.go, proxy/proxy_test.go
スクリプト並列度をwrite concurrencyの32分の1かつ最大3とし、スクリプト専用timeout、キュー期限、TXN replay経路を追加・更新した。
Blocking replayとZREM高速経路
proxy/blocking.go, proxy/dualwrite.go, proxy/command.go, adapter/redis_zset_cmds.go, adapter/redis_command_specs.go, adapter/redis_retry_test.go
blocking replayの効果判定、ElasticKV向けZREMFAST、unsupported時のZREM fallback、heavy command分類を追加した。
デプロイ設定と運用例
README.md, deploy/redis-proxy/docker-compose.ha.yml, docs/redis-proxy-deployment.md
dual-write例、HA設定、CLI説明、接続上限、timeoutの記載を新しい値に合わせた。

Lua commit cleanup

Layer / File(s) Summary
Lua dispatch timeout
adapter/redis.go, adapter/redis_lua.go, adapter/redis_lua_context.go
通常Redis dispatchとLua dispatchに別々のタイムアウトを適用した。
型別logical key cleanup
adapter/redis_compat_helpers.go, adapter/redis_lua_context.go, adapter/redis_txn_test.go
型別削除要素、TTLを考慮した型判定、削除履歴に基づくcleanup選択、走査範囲のテストを追加・更新した。

HLC lease更新

Layer / File(s) Summary
HLC lease更新期限
kv/coordinator.go, kv/sharded_coordinator.go
HLC物理窓を10秒に変更し、更新提案に専用timeoutを適用した。
HLC監視と説明
monitoring/hlc.go, monitoring/hlc_test.go, monitoring/grafana/dashboards/elastickv-raft-status.json, docs/architecture_overview.md
更新間隔、物理窓、wall skewの推奨閾値、ダッシュボード条件を更新した。

起動ゲートの時刻機能

Layer / File(s) Summary
Timestamp機能とlease recoveryの転送
main.go, main_encryption_rotate_on_startup_test.go
startupGatedCoordinatorNextNextAfterRecoverHLCLeaseを追加し、転送と非Dispatch動作をテストした。

テスト安定化

Layer / File(s) Summary
Leader health checkのリトライ
adapter/dynamodb_test.go
leader health checkが期待するHTTPステータスと本文になるまで再試行するよう変更した。

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

Possibly related PRs

  • bootjp/elastickv#1073: ElasticKVプールサイズ設定を同じコード領域で変更している。
  • bootjp/elastickv#1134: secondary async queueのtimeout処理と同じキュー基盤に関係している。
  • bootjp/elastickv#1140: Redis proxyのblocking replay経路を同じコード領域で変更している。
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.49% 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 ElasticKV の接続プール/peer 上限の引き上げを的確に表しており、変更内容の主軸と一致しています。
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.

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

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@bootjp
bootjp marked this pull request as ready for review July 23, 2026 03:16
@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.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/redis-proxy/main.go`:
- Line 58: Update the help text for the secondary-script-concurrency flag in
main so its 0-value behavior explicitly states the derived concurrency has a
minimum of 1, matching the documentation in redis-proxy-deployment.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c932864-260d-4d88-a336-d76f208c8dbd

📥 Commits

Reviewing files that changed from the base of the PR and between 8e4d48f and b4a9a63.

📒 Files selected for processing (14)
  • README.md
  • adapter/redis.go
  • adapter/redis_lua.go
  • adapter/redis_lua_context.go
  • adapter/redis_peer_limiter.go
  • adapter/redis_peer_limiter_test.go
  • cmd/redis-proxy/main.go
  • cmd/redis-proxy/main_test.go
  • deploy/redis-proxy/docker-compose.ha.yml
  • docs/redis-proxy-deployment.md
  • proxy/backend.go
  • proxy/config.go
  • proxy/dualwrite.go
  • proxy/proxy_test.go

Comment thread cmd/redis-proxy/main.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: b4a9a63f25

ℹ️ 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 thread proxy/config.go Outdated
Comment thread adapter/redis_lua.go Outdated
@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (a802b7d):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: a802b7dbab

ℹ️ 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 thread proxy/config.go
Comment thread proxy/config.go
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (9dc4adf):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (486037c):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
adapter/redis_lua.go (1)

836-836: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Lua 互換実行経路にも Lua 専用 timeout を使ってください。

Line 836 の execLuaCompat は Lua context と commit を実行するにもかかわらず、通常の redisDispatchTimeout を使用しています。runLuaScriptcommitredisLuaDispatchTimeout へ移行済みのため、この経路だけ短い通常期限で失敗します。

修正案
-	ctx, cancel := context.WithTimeout(context.Background(), redisDispatchTimeout)
+	ctx, cancel := context.WithTimeout(context.Background(), redisLuaDispatchTimeout)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@adapter/redis_lua.go` at line 836, execLuaCompat の context 作成で、通常の
redisDispatchTimeout ではなく Lua 専用の redisLuaDispatchTimeout を使用してください。Lua context
と commit の実行経路が runLuaScript と同じ Lua 用タイムアウトになるよう、該当する WithTimeout
呼び出しだけを更新してください。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/redis-proxy/main.go`:
- Line 65: secondary-script-timeout の負値を拒否し、ヘルプの「0
のみがフォールバック」という仕様と、SecondaryScriptTimeout <= 0
をフォールバック扱いするヘルパーの挙動を一致させてください。cmd/redis-proxy/main.go の secondary-script-timeout
CLI 入力または ProxyConfig 構成時に負値を検証してエラーにし、proxy/dualwrite.go の該当ヘルパーでは 0 のみを
SecondaryTimeout へフォールバックさせてください。

In `@monitoring/hlc.go`:
- Line 71: Update the metric Help text near the wallSkewSeconds definition to
document the pre-bootstrap condition consistently with the explanation around
the physical-window metric: clarify that wallSkewSeconds > -5 is meaningful for
alerting only when the physical window metric is positive, so ceilingMs == 0 at
startup does not trigger a false alert.

In `@proxy/proxy_test.go`:
- Around line 1170-1191: Replace the fixed time.Sleep in this test with
deterministic synchronization that waits for the script to be queued, using an
appropriate channel or metric signal before releasing blocker. Ensure cleanup is
registered to always unblock the blocked d.goWrite goroutine and call d.Close,
including when the test fails, using sync.Once or equivalent.

---

Outside diff comments:
In `@adapter/redis_lua.go`:
- Line 836: execLuaCompat の context 作成で、通常の redisDispatchTimeout ではなく Lua 専用の
redisLuaDispatchTimeout を使用してください。Lua context と commit の実行経路が runLuaScript と同じ
Lua 用タイムアウトになるよう、該当する WithTimeout 呼び出しだけを更新してください。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c1c92b6-6eaa-483e-8fbf-4deda4f72d07

📥 Commits

Reviewing files that changed from the base of the PR and between b4a9a63 and 9dc4adf.

📒 Files selected for processing (20)
  • README.md
  • adapter/redis_compat_helpers.go
  • adapter/redis_lua.go
  • adapter/redis_lua_context.go
  • adapter/redis_txn_test.go
  • cmd/redis-proxy/main.go
  • cmd/redis-proxy/main_test.go
  • docs/architecture_overview.md
  • docs/redis-proxy-deployment.md
  • kv/coordinator.go
  • kv/sharded_coordinator.go
  • main.go
  • main_encryption_rotate_on_startup_test.go
  • monitoring/hlc.go
  • monitoring/hlc_test.go
  • proxy/async_queue.go
  • proxy/backend.go
  • proxy/config.go
  • proxy/dualwrite.go
  • proxy/proxy_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • README.md
  • proxy/backend.go
  • docs/redis-proxy-deployment.md

Comment thread cmd/redis-proxy/main.go Outdated
Comment thread monitoring/hlc.go Outdated
Comment thread proxy/proxy_test.go

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 486037c994

ℹ️ 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 thread proxy/backend.go Outdated
defaultDialTimeout = 5 * time.Second
defaultReadTimeout = 3 * time.Second
blockingReadGrace = 10 * time.Second
defaultElasticKVReadTimeout = defaultSecondaryScriptTimeout + blockingReadGrace

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 Honor custom script timeouts in ElasticKV read deadlines

When an operator sets -secondary-script-timeout above the 5-minute default, this fixed default still leaves the ElasticKV go-redis client's ReadTimeout at 5m10s because cmd/redis-proxy builds secondaryOpts from DefaultElasticKVBackendOptions() and never adjusts it from the parsed config. go-redis applies that read deadline to Do calls, so async EVAL/EVALSHA replays can fail with a socket timeout before the advertised script deadline; derive the read timeout from the resolved script timeout plus grace, or reject larger values.

Useful? React with 👍 / 👎.

Comment thread proxy/backend.go Outdated
func DefaultElasticKVBackendOptions() BackendOptions {
opts := DefaultBackendOptions()
opts.PoolSize = defaultElasticKVPoolSize
opts.ReadTimeout = defaultElasticKVReadTimeout

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 Keep foreground ElasticKV reads on the short timeout

In elastickv-primary and elastickv-only modes the ElasticKV backend is the synchronous primary, but this default is also applied there, so ordinary client reads/writes now inherit the 5m10s script socket deadline. The proxy's foreground handlers call the backend with context.Background(), so a stalled ElasticKV GET/SET can block the client for minutes instead of the previous 3s; use the long timeout only for secondary script replays, or add a separate per-command timeout for foreground traffic.

Useful? React with 👍 / 👎.

Comment thread cmd/redis-proxy/main.go Outdated
flag.IntVar(&secondaryBlockingReplayQueueSize, "secondary-blocking-replay-queue-size", secondaryBlockingReplayQueueSize, "Maximum queued asynchronous secondary mutating blocking-command replays (0 = derived from blocking replay concurrency)")
flag.StringVar(&modeStr, "mode", "dual-write", "Proxy mode: redis-only, dual-write, dual-write-shadow, elastickv-primary, elastickv-only")
flag.DurationVar(&cfg.SecondaryTimeout, "secondary-timeout", cfg.SecondaryTimeout, "Secondary write timeout")
flag.DurationVar(&cfg.SecondaryScriptTimeout, "secondary-script-timeout", cfg.SecondaryScriptTimeout, "Secondary Lua-script write timeout (0 = secondary-timeout)")

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 Extend Redis secondary deadlines for primary-cutover scripts

In elastickv-primary mode the async secondary for script replays is Redis (primaryOpts), whose backend options still keep the 3s ReadTimeout; this new -secondary-script-timeout only changes the task context. A Lua script that succeeds on ElasticKV but takes longer than 3s to replay to Redis will still hit go-redis' socket deadline and be recorded as a secondary write failure despite the advertised 5m default, so the Redis backend needs a secondary-specific read timeout when it is used for async script replay.

Useful? React with 👍 / 👎.

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Latest-head follow-up:

  • Fixed expired secondary work dispatch so elapsed async deadlines now return a deadline error without sending the replay.
  • Fixed read-timeout extension so Redis socket writes keep the backend WriteTimeout while read waits can use the replay budget.
  • Verified the other current P2 items against this head: proxy/server timeout caps are aligned, transaction pipelines containing Lua use the script queue, ZREMFAST is classified as heavy, and unsupported ZREMFAST falls back to ZREM.

Validation:

  • go test ./proxy -run 'TestDualWriter_(SecondaryUsesPerCommandSocketTimeouts|SecondaryReadTimeoutUsesRemainingAsyncDeadline|ExpiredSecondaryReadDeadlineSkipsDispatch|TxnReplayWithScriptUsesScriptQueueAndTimeout|TxnReplayWithoutScriptUsesWriteQueueAndTimeout)|TestRedisClientWithReadTimeoutPreservesWriteTimeout|TestEffectiveBlockingReadTimeout|TestLeaderAwareRedisBackend' -count=1
  • go test ./proxy ./cmd/redis-proxy -count=1
  • go test ./adapter -run 'TestRedisHeavyCommandClassification|TestRedisHeavyCommandLimiterRejectsQueuedExecWhenFull|TestRedisHeavyCommandLimiterClassifiesQueuedExecCaseInsensitively|TestRedisHeavyCommandLimiterDoesNotGateCheapCommand' -count=1
  • go test ./cmd/redis-proxy -run 'TestValidateRuntimeTimeoutsRejectsUnsupportedScriptTimeout|TestDefaultRuntimeConfig' -count=1
  • go test ./proxy -run 'TestDualWriter_(Blocking_ZRemFastFallsBackToZRemWhenUnsupported|TxnReplayWithScriptUsesScriptQueueAndTimeout|TxnReplayWithoutScriptUsesWriteQueueAndTimeout|ExpiredSecondaryReadDeadlineSkipsDispatch|SecondaryReadTimeoutUsesRemainingAsyncDeadline)|TestRedisClientWithReadTimeoutPreservesWriteTimeout' -count=1
  • golangci-lint run ./proxy ./cmd/redis-proxy --timeout=5m --allow-parallel-runners
  • git diff --check

Latest pushed head: 8f100ddf7880d6b9d1b90c1b288345b28538cadf; CI is running.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8f100ddf78

ℹ️ 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".

…onnection-budget

# Conflicts:
#	docs/redis-proxy-deployment.md
#	proxy/backend.go
#	proxy/dualwrite.go
#	proxy/leader_aware_backend.go
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (9a94c9b):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD 9a94c9b:

  • Merged current origin/main and resolved conflicts in redis-proxy deployment docs, ElasticKV backend defaults documentation, blocking replay mutation gating, and leader-aware pipeline timeout handling.
  • Preserved the raised ElasticKV command pool budget of 192, retained PubSub/per-peer headroom guidance, kept blocking replay effect checks, and kept leader refresh for pipeline dispatches.
  • reviewThreads currently has no unresolved non-outdated findings; REST root inline comments are resolved/outdated threads.

Validation:

  • go test ./proxy ./cmd/redis-proxy -count=1
  • go test ./... -run ^'$' -count=1
  • go test ./adapter -run "Test(RedisPeerLimiter|RedisLeaderClient|RedisHeavyCommand|RedisIdleWait|RedisBZPopMinPollIteration|RedisExecLuaCompatRetriesWriteConflict|RedisEvalRetriesWriteConflict|ElasticKVZRemFast|LuaCommitPlanFor|DeltaCompactor_(TTLInline|BackoffAfterTimeout|RotatesHandlerAfterTimeout)|Redis_Stream)" -count=1
  • go test ./kv ./monitoring -count=1
  • golangci-lint --config=.golangci.yaml run ./... --timeout=5m --allow-parallel-runners
  • git diff --cached --check
  • merge commit signature verified locally for bootjp contact@bootjp.me

Current-head CI is running after the push.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 9a94c9b522

ℹ️ 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 thread proxy/leader_aware_backend.go Outdated
}

func (b *LeaderAwareRedisBackend) doWithReadTimeoutOnce(ctx context.Context, timeout time.Duration, args ...any) *redis.Cmd {
cli := b.currentClient()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Refresh leader before timed single-command dispatches

When an async single-command replay reaches a newly constructed leader-aware ElasticKV backend before the initial INFO discovery completes, secondaryDo now calls DoWithReadTimeout, but this path only reads currentClient() instead of waiting via currentClientOrRefresh() like Do, DoWithTimeout, and Pipeline do. In that startup/race window it immediately returns ErrNoLeaderBackend, records the secondary write as failed, and never replays it after discovery, so primary-accepted traffic can be missing from ElasticKV. Use the refresh-aware lookup here as well.

Useful? React with 👍 / 👎.

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (ddfffb7):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD ddfffb7:

Addressed the latest Redis proxy leader-aware backend finding:

  • DoWithReadTimeout now uses currentClientOrRefresh, matching Do, DoWithTimeout, and pipeline dispatch paths.
  • This prevents async single-command replays from failing with ErrNoLeaderBackend during the initial leader discovery window.
  • NOTLEADER handling remains unchanged: command-level NOTLEADER refreshes leader state but does not replay the ambiguous command.

Caller audit:

  • DoWithReadTimeout is used by secondaryDo for read-timeout bounded async replay.
  • DoWithTimeout and pipeline paths were already refresh-aware.
  • The timeoutCapturingBackend test double delegates DoWithReadTimeout to the existing timeout path and does not need behavior changes.

Validation:

  • go test ./proxy -run 'TestLeaderAwareRedisBackend_DoWithReadTimeoutWaitsForInitialLeaderDiscovery|TestLeaderAwareRedisBackend_(InitialCommandWaitsForLeaderDiscovery|UnknownLeaderDoesNotProbeOnEveryCommand|ScriptNotLeaderRefreshesWithoutReplay)' -count=1
  • go test ./proxy ./cmd/redis-proxy -count=1
  • golangci-lint --config=.golangci.yaml run ./proxy ./cmd/redis-proxy --timeout=5m --allow-parallel-runners
  • go test ./... -run '^$' -count=1
  • git diff --check
  • commit signature verified locally for bootjp contact@bootjp.me

The latest review thread is no longer active after the push. Current-head CI is running.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: ddfffb760e

ℹ️ 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 commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

CI follow-up addressed on latest HEAD 40370e4.

Root cause:

  • The failed GitHub Actions job was test (ubuntu-latest) in TestDynamoDB_LeaderHealthz/leader, where the leader health endpoint returned 503 during the post-startup leadership churn window.
  • The test was doing a single immediate health request even though the test harness already treats brief startup leader churn as expected under loaded CI runners.

Change made:

  • TestDynamoDB_LeaderHealthz now waits for the expected leader/follower health response using the existing leader churn retry budget and interval.

Validation:

  • go test ./adapter -run '^TestDynamoDB_LeaderHealthz$' -count=50
  • go test ./adapter -run '^TestDynamoDB_' -count=1
  • go test ./... -run '^$' -count=1
  • golangci-lint --config=.golangci.yaml run ./adapter --timeout=5m --allow-parallel-runners
  • git diff --check

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (40370e4):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
adapter/redis_lua_context.go (1)

3883-3883: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

//nolint:gosec の使用はガイドライン上非推奨です。

seqInTxndeltasredisPairWidth 上限)のループインデックスであり uint32 へのナローイングは実質的に安全ですが、コーディングガイドラインでは //nolint 抑制ではなくリファクタリングを優先することが求められています。境界チェック付きの変換ヘルパーへの置き換えを検討してください。

As per coding guidelines: "Avoid using //nolint directives; refactor instead in Go code".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@adapter/redis_lua_context.go` at line 3883, Remove the //nolint:gosec
suppression from the ListMetaDeltaKey call and replace the direct
uint32(seqInTxn) conversion with the project’s checked integer-conversion
helper. Preserve the existing bounded-index behavior and ensure the conversion
handles any out-of-range value according to the helper’s established error or
fallback contract.

Sources: Coding guidelines, Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@adapter/dynamodb_test.go`:
- Around line 272-280: Configure an individual timeout for each HTTP attempt in
the health-check request flow around http.NewRequestWithContext and
http.DefaultClient.Do. Use a timeout-bearing context or HTTP client, and treat
timeout errors as a false health-check result so the Eventually condition can
continue without blocking.
- Around line 278-285: Replace all three require.NoError calls within the
Eventually condition in the test around the HTTP request and response body
reads. Return false from the condition when an error occurs, or migrate the
assertion flow to require.EventuallyWithT and use its CollectT, so transient
request and read errors trigger retries instead of FailNow terminating the
condition goroutine.

---

Nitpick comments:
In `@adapter/redis_lua_context.go`:
- Line 3883: Remove the //nolint:gosec suppression from the ListMetaDeltaKey
call and replace the direct uint32(seqInTxn) conversion with the project’s
checked integer-conversion helper. Preserve the existing bounded-index behavior
and ensure the conversion handles any out-of-range value according to the
helper’s established error or fallback contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bdd833c-5201-4786-b4ff-88448ec88d00

📥 Commits

Reviewing files that changed from the base of the PR and between 9dc4adf and 40370e4.

📒 Files selected for processing (25)
  • adapter/dynamodb_test.go
  • adapter/redis.go
  • adapter/redis_command_specs.go
  • adapter/redis_lua_context.go
  • adapter/redis_peer_limiter_test.go
  • adapter/redis_retry_test.go
  • adapter/redis_workpool.go
  • adapter/redis_workpool_test.go
  • adapter/redis_zset_cmds.go
  • cmd/redis-proxy/main.go
  • cmd/redis-proxy/main_test.go
  • docs/redis-proxy-deployment.md
  • kv/sharded_coordinator.go
  • main.go
  • monitoring/grafana/dashboards/elastickv-raft-status.json
  • monitoring/hlc.go
  • proxy/backend.go
  • proxy/blocking.go
  • proxy/command.go
  • proxy/dualwrite.go
  • proxy/leader_aware_backend.go
  • proxy/leader_aware_backend_test.go
  • proxy/proxy.go
  • proxy/proxy_test.go
  • proxy/pubsub.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • adapter/redis_peer_limiter_test.go
  • kv/sharded_coordinator.go
  • main.go
  • monitoring/hlc.go
  • cmd/redis-proxy/main_test.go

Comment thread adapter/dynamodb_test.go
Comment thread adapter/dynamodb_test.go Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 40370e4e57

ℹ️ 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 commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

Evidence for current HEAD cf09c1b:

Addressed the latest DynamoDB health-check test findings:

  • Each Eventually HTTP attempt now uses a per-attempt context timeout.
  • Request creation, HTTP request, and body read errors now return false so Eventually retries instead of calling require.NoError inside the condition goroutine.

Validation:

  • go test ./adapter -run '^TestDynamoDB_LeaderHealthz$' -count=50
  • go test ./adapter -run '^TestDynamoDB_' -count=1
  • go test ./... -run '^$' -count=1 -timeout=10m
  • golangci-lint --config=.golangci.yaml run ./adapter --timeout=5m --allow-parallel-runners
  • git diff --check
  • commit signature verified locally for bootjp contact@bootjp.me

@codex review

@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (cf09c1b):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: cf09c1bd44

ℹ️ 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 thread proxy/backend.go
Comment thread proxy/dualwrite.go
@github-actions

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (424e35d):

  • kv/coordinator.go
  • kv/sharded_coordinator.go

What to check, by subsystem:

  • kv/hlc*.goNext() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (strategy (c) Observe(MaxAppliedHLC)), and the commit-time ceiling fence (fail-closed when wall_now >= physicalCeiling). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/coordinator.go, kv/sharded_coordinator.goRunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and the new-term detection that calls Observe(fsm.MaxAppliedHLC()) (strategy (c)). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on. (M2 spec will land OCC-1..OCC-5; until then the spec doc §5.2 is the contract.)
  • kv/fsm.go — FSM apply of HLC lease entries (SetPhysicalCeiling), and any future MaxAppliedHLC() accessor that strategy (c) needs.
  • store/mvcc_store.go — version visibility, snapshot install, and the MVCC-1..MVCC-4 invariants (M3 scope).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@bootjp

bootjp commented Jul 23, 2026

Copy link
Copy Markdown
Owner Author

Addressed the latest-head review items in 424e35d.

  • Indefinite blocking reads (BLPOP ... 0, XREAD BLOCK 0, etc.) now keep the explicit zero read-timeout override on blocking paths, while ordinary read-timeout overrides still ignore zero/negative values.
  • ELASTICKV.ZREMFAST unsupported fallback now resets the positive-int replay attempt counter and backoff before retrying as ZREM, preserving the normal no-effect retry budget.

Validation:

  • go test ./proxy -count=1
  • go test ./proxy ./cmd/redis-proxy -count=1
  • golangci-lint --config=.golangci.yaml run ./proxy --timeout=5m --allow-parallel-runners
  • git diff --check

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 424e35d29e

ℹ️ 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 f9b7e9c into main Jul 23, 2026
12 checks passed
@bootjp
bootjp deleted the feature/redis-proxy-connection-budget branch July 23, 2026 15:14
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