Repository navigation
refactor(search): split the session store into Redis and in-memory stores - #3896
Conversation
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 38 minutes. View limit details
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ores searchSessionStore held a Redis client and an in-memory map and branched on a nil client in put and get. Make it an interface with two implementations: redisSearchSessionStore (the Lua script path, unchanged) and memorySearchSessionStore (the map, sweep, and eviction, unchanged). Session ID generation and the ID-format check are shared helpers. The provider used to get ErrSearchContinuationUnavailable from a nil store pointer; the Meilisearch cursor path now checks for a nil store before each call so a provider built without one still returns that error. No behavior change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
f2bd9ae to
c6121ae
Compare
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Related issue: #3699
Validation tasks: none (search continuation paths behind #1143 C2 and #1144 C3 run this code; behavior is unchanged)
After #3699,
searchSessionStoreininternal/catalog/search_session.goholds both a Redis client and a mutex-guarded in-memory map, andputandgetchoose the backend by checking whether the client is nil. This PR splits the two backends into separate types. It is a refactor with no behavior change.Approach
searchSessionStoreis now an unexported interface withputandget, implemented by two types:redisSearchSessionStore: the existing Lua script path, unchanged.memorySearchSessionStore: the existing map, cross-account expiry sweep, and earliest-expiry eviction, unchanged.Session ID generation (24 random bytes, hex) and the ID-format check that returns
invalid_cursorare shared helpers that both stores call.NewMeilisearchSearchProviderstill installs the in-memory store, andCatalogSearchService.WithSearchSessionStorestill swaps in the Redis store when the router has a Redis client.A nil
*searchSessionStoreused to returnErrSearchContinuationUnavailable. A nil interface would panic instead, so the Meilisearch cursor path now checks for a missing store before each call and returns the same error. Production always installs a store; tests that build the provider directly rely on this.Validation
go vet, andmake lint-changed: clean.go test ./internal/catalog/ ./internal/api/: pass, including the existing in-memory store test, which now runs againstmemorySearchSessionStore.ErrSearchContinuationUnavailablewrapping for an unreachable server. It passed. The test is not committed, because it would add a dependency to check code this PR only moves.Evidence
No user-visible change. The page below records the checks.
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3896/
Risks
None identified. Session keys, TTL, eviction, and error codes are unchanged, so continuation cursors issued before a deploy keep working after it.
Checklist
AI Disclosure
/siloskillErrSearchContinuationUnavailable; fixed with the guards described above. A simplify pass ran and changed nothing. The plan round was skipped because the requester specified the design. The background adversarial review was skipped because the PR changes no behavior.🤖 Generated with Claude Code
Note
Split search session store into
redisSearchSessionStoreandmemorySearchSessionStoreReplaces the combined session store struct with a
searchSessionStoreinterface and two concrete implementations in search_session.go. The Redis and in-memory put/get paths are moved into their respective types, sharing new helpersnewSearchSessionIDandvalidSearchSessionIDplus thesearchSessionIDBytesconstant.NewMeilisearchSearchProviderdefaults to the in-memory store, andWithSearchSessionStoreconfigures the Redis store (search_meilisearch_provider.go, search_service.go).searchCursorPagenow checks for a missing session store before both session get and put, returning the continuation-unavailable error.Macroscope summarized c6121ae.