Repository navigation
ZOOKEEPER-5129: Don't let container cleanup delete a node that replaced the container - #2504
Open
SpookyJumpyBeans wants to merge 1 commit into
Open
SpookyJumpyBeans wants to merge 1 commit into
SpookyJumpyBeans wants to merge 1 commit into
Conversation
SpookyJumpyBeans
added a commit
to SpookyJumpyBeans/boyidai
that referenced
this pull request
Nov 13, 2026
…ed the container ContainerManager picks candidate paths, then sends a delete request for each in turn, pacing them. The request only carried the path, and the server only refused normal ephemeral nodes. So if a candidate was deleted and recreated in between, the new node was deleted: any persistent node, or a new container or TTL node still within its grace period. A TTL node modified after it was picked, which restarts its TTL, was deleted too. ContainerManager now checks each candidate again just before sending its request, skips it if it no longer exists or is no longer a container or TTL node past its grace period, and sends the node's mzxid with the request. The server only deletes a container or TTL node, and only if its mzxid is unchanged, so it isn't deleted if it is replaced or modified after that check either.
SpookyJumpyBeans
force-pushed
the
ZOOKEEPER-5129
branch
from
November 22, 2026 14:55
c2dcbb3 to
548dc77
Compare
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.
https://issues.apache.org/jira/browse/ZOOKEEPER-5129
ContainerManager.checkContainerscollects the candidate paths first, then sends aDeleteContainerRequestfor each in turn, pacing them byznode.container.maxPerMinute. The request only carried the path. ThedeleteContainercase inPrepRequestProcessoronly refused a node with children or a normal ephemeral node.So if a candidate was deleted and recreated before its request was processed, the new node was deleted:
EphemeralType.get(0)isVOID, which passed);maxNeverUsedInterval;Changes
ContainerManagerchecks each candidate again just before sending its request. It skips the candidate if it no longer exists, or isn't a container or TTL node past its grace period. The grace period rules moved into one helper,isPastGracePeriod, whichgetCandidatesuses too.The request carries the node's
mzxid, read together with the check under the node's lock. A replacement always has a differentmzxid, and so does a modified node. Adding or removing children doesn't change it.PrepRequestProcessoronly deletes a container or TTL node, and only if itsmzxidis still the one in the request. Prep reads outstanding change records too, so a replacement or asetDatathat isn't committed yet is also caught:DeleteContainerRequestgets anmzxidfield. The request is only created byContainerManageron the leader (or standalone server), and prep turns it into aDeleteTxn. So nothing sent between servers or written to the txn log changes. Clients still can't send it.Notes:
setDatabetween the check and the request is now refused. It is deleted at the next check instead.testMaxPerMinutenow uses real emptied containers, since a candidate that doesn't exist is no longer sent.AuditHelperreads a faileddeleteContainerrequest as aDeleteRequestand logs aClassCastException. This already happens on master for refused requests, for example a container that has children again. This change adds refusals, so it can show up more often.Tests
New tests in
CreateContainerTestandCreateTTLTest:testDeleteContainerRequestDoesNotDeletePersistentNodetestReplacementContainerIsNotDeletedmzxidchecktestModifiedAfterCheckIsNotDeletedsetDataon a TTL node, after the checkmzxidchecktestReplacementPersistentNodeIsNotDeletedmzxidcheckstestReplacementContainerIsCheckedAgainBeforeDeletiontestReplacementIsCheckedAgainBeforeDeletion(TTL)testDeletedCandidateIsNotSentForDeletionAll 7 fail on master. Removing only the type check, only the
mzxidcheck, or only the grace period check makes the tests listed for it fail.CreateContainerTest,CreateTTLTest,Emulate353TTLTestandPrepRequestProcessorTestpass, and so does checkstyle.