J-HowHuang opened a new pull request, #20381: URL: https://github.com/apache/pinot/pull/20381
## Description Adds an operation lease framework to `pinot-common`: an advisory, exclusive right to run one operation, held as an EPHEMERAL ZNode in the Helix property store. It lets replicas (or any other components) that would run the same work on a shared resource agree that one of them does it while the others wait for it, skip it, or do something else. **Depends on #20367.** This branch is stacked on it so that a downstream build can use both; only the last commit, `Lease framework`, belongs to this PR. I will rebase onto master once #20367 merges. - `PinotOperationLeaseUtils`: `tryAcquire`, `awaitRelease` (watch-based, no polling, bounded by a max wait), `getLeaseInfo` and `forceRelease`. A lease is named by a table and an opaque, caller-built key. The key becomes one ZNode under `/OPERATION_LEASES/<tableNameWithType>/`; the framework validates ZNode name rules and hashes keys over 1 KB (`sha256-<hex>`, with the full key kept in the node data). Each method also takes a full property store path, for a caller that keeps an existing ZNode. - `PinotOperationLease` (`AutoCloseable`): `isHeld` / `checkOwnership` compare the ZNode's ephemeral owner with the manager's current session, so a session expiry ends the lease on both sides. `release` is idempotent and never deletes a ZNode created by another session. - ZooKeeper errors are thrown, not swallowed, so each caller decides whether to do the work without a lease or skip it. - The lease is advisory: it saves duplicate work but does not fence a holder that stalls past its session timeout. What to do while a lease is held, and how to tell that an operation is done, are left to the caller. - `PinotHelixResourceManager` removes a table's lease directory when the table is deleted. No existing code path takes a lease yet. ## Testing `PinotOperationLeaseUtilsTest` (13 tests, embedded ZooKeeper, one session per simulated instance): only one instance holds a lease; release lets another acquire and never deletes another session's lease; a session end releases the lease and a session change ends it; `awaitRelease` wakes on release and returns at once when free; acquire fails while disconnected; `forceRelease` on a missing lease; table deletion removes held leases; full-path leases; key validation and hashing of long keys. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
