fix(client): correct DoublyLinkedList head removal#3320
Open
abhijeet117 wants to merge 1 commit into
Open
Conversation
DoublyLinkedList.remove skipped the neighbor pointer fixup when the removed node was the head, so the new head kept a stale previous pointer. A later removal of that head then set tail to the already removed node, leaving the list inconsistent and causing following push calls to silently lose data. Update head and tail from the node's own previous/next links so both neighbors are always fixed up.
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.
Description
DoublyLinkedList.removeskipped the neighbor pointer fixup whenever the removed node was the head, so the new head kept a stalepreviouspointer to the removed node. If that head was later removed,tailwas set to the already removed node, leaving the list inconsistent and causing followingpushcalls to silently drop values (length reported items that iteration never yielded). This list backs the connection pool, so the corruption could surface there.The fix sets
headandtailfrom the node's ownprevious/nextlinks, so both neighbors are always relinked correctly. Added tests cover removing the head and the head-then-tail sequence. Relates to #3062.Checklist
npm testpass with this change (including linting)?Note
Medium Risk
Touches core list logic used by the connection pool and command write queue, but the change is a small, well-tested fix to pointer maintenance rather than new behavior.
Overview
Fixes
DoublyLinkedList.removeso removing the head always relinks neighbors instead of only advancingheadand skipping pointer fixup on the old head’s successor.The implementation now uses a single path: splice via
previous/next, and set#heador#tailwhen the removed node is at an end. That clears stalepreviouson the new head and avoidstailpointing at a detached node after head-then-tail removal (which could make laterpushvalues disappear from iteration while length still increased).Adds unit tests for the new-head
previousinvariant and for head-then-tail followed bypush. The list backs the Redis client connection pool and commands write queue, so this corruption could surface as pool or outbound-command inconsistencies.Reviewed by Cursor Bugbot for commit 882c26d. Bugbot is set up for automated code reviews on this repo. Configure here.