Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
Original file line number Diff line number Diff line change
Expand Up @@ -2146,8 +2146,9 @@ Both subsystems need to have sufficient amount of threads to achieve peak read t
maximum interval in milliseconds that a container that has never had
any children is retained. Should be long enough for your client to
create the container, do any needed work and then create children.
Default is "0" which is used to indicate that containers
that have never had any children are never deleted.
Default is "300000"(a.k.a. 5 minutes) since 3.10.0, for earlier versions,
it is "0" which is used to indicate that containers that have never had
any children are never deleted.

<a name="sc_debug_observability_config"></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public class ContainerManager {
private final Timer timer;
private final AtomicReference<TimerTask> task = new AtomicReference<>(null);

/**
* @param zkDb the ZK database
* @param requestProcessor request processor - used to inject delete
* container requests
*/
public ContainerManager(ZKDatabase zkDb, RequestProcessor requestProcessor) {
this(
zkDb, requestProcessor,
Integer.getInteger("znode.container.checkIntervalMs", (int) TimeUnit.MINUTES.toMillis(1)),
Integer.getInteger("znode.container.maxPerMinute", 10000),
Long.getLong("znode.container.maxNeverUsedIntervalMs", TimeUnit.MINUTES.toMillis(5))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default 5-minute cleanup is a breaken change and is not recommended i think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it break things ? Container nodes with no children are supposed to be deleted.

/**
* The znode will be a container node. Container
* nodes are special purpose nodes useful for recipes such as leader, lock,
* etc. When the last child of a container is deleted, the container becomes
* a candidate to be deleted by the server at some point in the future.
* Given this property, you should be prepared to get
* {@link org.apache.zookeeper.KeeperException.NoNodeException}
* when creating children inside of this container node.
*/
CONTAINER(4, false, false, true, false),

);
}

/**
* @param zkDb the ZK database
* @param requestProcessor request processor - used to inject delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.management.JMException;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.audit.ZKAuditProvider;
Expand Down Expand Up @@ -168,13 +167,7 @@ public void runFromConfig(ServerConfig config) throws IOException, AdminServerEx
secureCnxnFactory.startup(zkServer, needStartZKServer);
}

containerManager = new ContainerManager(
zkServer.getZKDatabase(),
zkServer.firstProcessor,
Integer.getInteger("znode.container.checkIntervalMs", (int) TimeUnit.MINUTES.toMillis(1)),
Integer.getInteger("znode.container.maxPerMinute", 10000),
Long.getLong("znode.container.maxNeverUsedIntervalMs", 0)
);
containerManager = new ContainerManager(zkServer.getZKDatabase(), zkServer.firstProcessor);
containerManager.start();
ZKAuditProvider.addZKStartStopAuditLog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.zookeeper.server.quorum;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import javax.management.JMException;
import org.apache.zookeeper.KeeperException.SessionExpiredException;
Expand Down Expand Up @@ -78,13 +77,7 @@ protected void setupRequestProcessors() {
}

private synchronized void setupContainerManager() {
containerManager = new ContainerManager(
getZKDatabase(),
prepRequestProcessor,
Integer.getInteger("znode.container.checkIntervalMs", (int) TimeUnit.MINUTES.toMillis(1)),
Integer.getInteger("znode.container.maxPerMinute", 10000),
Long.getLong("znode.container.maxNeverUsedIntervalMs", 0)
);
containerManager = new ContainerManager(getZKDatabase(), prepRequestProcessor);
}

@Override
Expand Down