curator icon indicating copy to clipboard operation
curator copied to clipboard

[CURATOR-636] Make PersistentTtlNode initialDelay more configurable

Open jira-importer opened this issue 3 years ago • 1 comments

Currently when PersistentTtlNode starts, it will

  1. create a CONTAINER node
  2. create a CHILD node `_touch`

But there is a initialDelay between 1 and 2. If the initialDelay is long enough and the client is disconnected, 1 will not be deleted forever (because CONTAINER node only delete its parent when all its child is gone, but in this case, it never has any of them).

The initialDelay could be configured, but not so flexible. The initialDelay is calculated by the formula `ttl/touchScheduleFactor`, but this formula is also used to how frequent we want to ping Zookeeper to keep our znodes alive, aka period.

As you can see here (2nd parameter is initialDelay and 3rd parameter is for period)

// PersistentTtlNode.java
Future> future = executorService.scheduleAtFixedRate(touchTask, ttlMs / touchScheduleFactor, ttlMs / touchScheduleFactor, TimeUnit.MILLISECONDS);
 
// Interface ScheduledExecutorService
ScheduledFuture> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)

Let's say we have ttl of 5 minutes. We want to have 0 initialDelay so we will set the touchScheduleFactor to 5 minutes too. This will give us 1ms (5 minutes/5 minutes) of initialDelay (which solves our problem) but spamming Zookeeper every second.

So it would be nice if we can set `initialDelay` 


Originally reported by yang-wei, imported from: Make PersistentTtlNode initialDelay more configurable
  • status: Open
  • priority: Minor
  • resolution: Unresolved
  • imported: 2025-01-21

jira-importer avatar Mar 31 '22 03:03 jira-importer

ISSUE 1258 is solving exactly the problem discussed in this ticket.

If you agree I think this ticket could be closed

chevaris avatar Apr 22 '25 07:04 chevaris