Skip to content

proxy: fix EVALSHA_RO fallback, guard script cache on primary error, bounded eviction#373

Merged
bootjp merged 2 commits intocodex/primary-blocking-bzpopminfrom
copilot/sub-pr-372
Mar 20, 2026
Merged

proxy: fix EVALSHA_RO fallback, guard script cache on primary error, bounded eviction#373
bootjp merged 2 commits intocodex/primary-blocking-bzpopminfrom
copilot/sub-pr-372

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

Three bugs in the proxy-side script cache introduced in the previous commit.

EVALSHA_RO fell back to EVAL instead of EVAL_RO

Read-only semantics were silently dropped on secondary replay. evalFallbackArgs now maps EVALSHA_RO → EVAL_RO and EVALSHA → EVAL.

Script cache mutated on primary failure

rememberScript (including clearScripts for SCRIPT FLUSH) was called before checking the primary's error. A failed SCRIPT FLUSH would clear the proxy cache while the primary still held its scripts, breaking subsequent EVALSHA → EVAL fallbacks. Moved rememberScript to after the error guard.

Unbounded script cache

The scripts map[string]string had no size limit. Added maxScriptCacheSize = 512 with FIFO eviction tracked via an insertion-order scriptOrder []string slice—no new dependencies required.

// storeScript now evicts oldest entry at capacity
if len(d.scripts) >= maxScriptCacheSize {
    oldest := d.scriptOrder[0]
    d.scriptOrder = d.scriptOrder[1:]
    delete(d.scripts, oldest)
}

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…add bounded eviction

Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
Copilot AI changed the title [WIP] Add proxy-side support for Redis blocking commands proxy: fix EVALSHA_RO fallback, guard script cache on primary error, bounded eviction Mar 20, 2026
Copilot AI requested a review from bootjp March 20, 2026 11:49
@bootjp bootjp marked this pull request as ready for review March 20, 2026 11:51
@bootjp bootjp merged commit 055fa86 into codex/primary-blocking-bzpopmin Mar 20, 2026
5 checks passed
@bootjp bootjp deleted the copilot/sub-pr-372 branch March 20, 2026 11:51
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.

2 participants