adapter: fix orphaned list items when DEL + recreate in same Lua script#385
Merged
Conversation
Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/a35c08cd-cb6d-4ea5-9605-cd91074de396
Copilot
AI
changed the title
[WIP] Adapter: reduce Lua list lock contention
adapter: fix orphaned list items when DEL + recreate in same Lua script
Mar 21, 2026
bootjp
approved these changes
Mar 21, 2026
Owner
|
@copilot fix golangci-lint |
…mbers) Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com> Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/c131ce44-56b0-443c-bf86-5921e0684a69
Contributor
Author
Fixed in commit b4ab53e:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Lua script deleted a key and then recreated it as a list in the same transaction, the delta commit path (
preserveExisting=true) skippeddeleteLogicalKeyElems, leaving the original list items orphaned in storage.Root cause:
listCommitPlanalways returnedpreserveExisting=truefor non-materialized (delta) lists. But if the key was previously deleted in the same script,listStatenever loaded the persisted meta (becausedeleted[key]=truemadekeyTypereturnredisTypeNone), so the delta path wrote only the new items while the old storage entries were never cleaned up.Changes
luaScriptContext: addeverDeleted map[string]boolfield, populated bydeleteLogicaland never reset (unlikedeleted, which is cleared when commands recreate a key).listCommitPlan: wheneverDeleted[key]is true, force the full-rewrite/materialized path (preserveExisting=false) sodeleteLogicalKeyElemsruns and cleans up stale storage before writing the new list.TestRedis_LuaDelAndRecreateListNoOrphan: covers the DEL → RPUSH sequence to guard against regression.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.