Skip to content

Fix Redis state store query index init on Redis 8.8+ - #4404

Open
wrysjy wants to merge 5 commits into
dapr:mainfrom
wrysjy:fix-redis-query-index-already-exists
Open

Fix Redis state store query index init on Redis 8.8+#4404
wrysjy wants to merge 5 commits into
dapr:mainfrom
wrysjy:fix-redis-query-index-already-exists

Conversation

@wrysjy

@wrysjy wrysjy commented Jun 11, 2026

Copy link
Copy Markdown

Description

Redis 8.8 started prefixing module error replies with an error code: a duplicate FT.CREATE now returns SEARCH_INDEX_EXISTS Index already exists instead of the bare Index already exists. registerSchemas in the Redis state store compared the error string exactly, so on Redis 8.8+ any daprd initializing a state.redis component with queryIndexes against an existing index failed with INIT_COMPONENT_FAILURE and exited — breaking every app with more than one replica, and single-replica apps on restart.

This PR matches the error with strings.Contains so both reply formats take the existing drop-and-recreate path, and adds unit tests for registerSchemas covering both error formats plus unrelated-error passthrough (the function previously had no tests).

Verified empirically: daprd built with this change initializes successfully against redis:8.8.0 with a pre-existing index (logs drop stale query index), while v1.18.0 exits with INIT_COMPONENT_FAILURE. Behavior on redis:8.6.3 and earlier is unchanged.

Issue reference

Please reference the issue this PR will close: #4403

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests

Redis 8.8 started prefixing the duplicate FT.CREATE reply with an error
code, changing it from "Index already exists" to
"SEARCH_INDEX_EXISTS Index already exists". registerSchemas compared
the error string exactly, so on Redis 8.8+ any sidecar initializing a
state.redis component with queryIndexes against an existing index
failed with INIT_COMPONENT_FAILURE and exited. This breaks every app
with more than one replica, and single-replica apps on restart.

Match the error with strings.Contains so both reply formats take the
existing drop-and-recreate path, and add unit tests covering both
formats plus unrelated-error passthrough.

Signed-off-by: Yu <wrysjy@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@wrysjy
wrysjy requested review from a team as code owners June 11, 2026 06:46
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.

Redis state store: queryIndexes init fails on Redis 8.8+ ("SEARCH_INDEX_EXISTS Index already exists")

2 participants