Skip to content

fix(redis): avoid poisoning Lua SHA cache on transient load failures#56

Draft
twisti-dev wants to merge 1 commit into
masterfrom
codex/propose-fix-for-cached-lua-script-failure
Draft

fix(redis): avoid poisoning Lua SHA cache on transient load failures#56
twisti-dev wants to merge 1 commit into
masterfrom
codex/propose-fix-for-cached-lua-script-failure

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

Motivation

  • The previous implementation cached a Mono<String> from script.scriptLoad(...).cache(), and Mono.cache() retains terminal errors which can permanently replay transient SCRIPT LOAD failures.
  • Permanently caching a failed load can cause persistent unavailability of Lua-backed operations for a script ID until process restart, creating an availability/DoS risk.
  • The change aims to preserve retryability after transient failures by only caching successfully loaded script SHAs.

Description

  • Change scriptShas from ConcurrentHashMap<String, Mono<String>> to ConcurrentHashMap<String, String> so the map stores concrete SHA strings rather than Mono instances.
  • Update getSha to return Mono.just(cachedSha) when present, or call script.scriptLoad(...) and store the SHA into scriptShas via doOnNext only after a successful load.
  • Preserve existing execute behavior, including RedisNoScriptException removal of the cached SHA and the retry policy, so functionality is unchanged except for avoiding cached load errors.

Testing

  • Attempted to compile the core module with ./gradlew --no-daemon -q :surf-redis-core:compileKotlin, but the build requires Java 25 while the environment provides Java 21, so compilation could not be completed.
  • No other automated tests were run in this environment due to the JVM version limitation.

Codex Task

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant