sandynz opened a new issue, #2533: URL: https://github.com/apache/shardingsphere-elasticjob/issues/2533
## Bug Report ### Expected behavior Lifecycle APIs should handle an ephemeral instance disappearing between child enumeration and metadata lookup without counting it, returning ghost metadata, or failing with a null-related exception. ### Actual behavior Instance traversal combines direct `getChildrenKeys()` with cached `get(instancePath)`. If an instance is deleted after children are enumerated, a not-yet-evicted cache entry can hide the deletion. A deterministic ZooKeeper harness deletes the instance after returning the real child list and preserves the real pre-deletion cache snapshot for the following metadata read: ```text JOB_STATISTICS_GHOST_INSTANCE direct=null instanceCount=1 SERVER_STATISTICS_GHOST_INSTANCE direct=null instancesNum=1 SHARDING_STATISTICS_GHOST_INSTANCE direct=null status=SHARDING_FLAG instanceId=10.0.0.1@-@instance serverIp=10.0.0.1 RESULT jobGhostCount=true serverGhostInstance=true shardingGhostMetadata=true ``` ### Environment - ElasticJob: `3.0.6-SNAPSHOT` - Commit: `0694c8f6b376b166324992be5431f6d4be131c66` - Curator: `5.9.0` - ZooKeeper client/server: `3.9.5` / `3.9.3` - JDK: `21.0.10` ### Affected code Cached instance metadata reads remain in: - `JobOperateAPIImpl.shutdown()`; - `JobStatisticsAPIImpl.getJobInstanceCountByJobNameAndIP()`; - `ServerStatisticsAPIImpl.getAllServersBriefInfo()`; - `ShardingStatisticsAPIImpl.getShardingInfo()`. The children, existence, assignment, and metadata reads do not form an atomic snapshot. ### Proposed behavior - Use authoritative metadata reads in management-facing instance traversal. - Treat an instance that disappears during statistics traversal as absent and skip it. - Do not populate `ShardingInfo` instance ID or server IP from cached metadata when the instance no longer exists. - Treat concurrent deletion during shutdown as idempotent completion. - Add deterministic deletion-race tests for job statistics, server statistics, sharding statistics, and shutdown. The implementation must handle `null` from a direct metadata read. A mechanical `get()` to `getDirectly()` replacement is insufficient because it can convert ghost data into a null-related exception. ### Scope boundary This issue defines missing-instance behavior during traversal. It does not promise an atomic multi-node ZooKeeper snapshot and does not cover stale sharding assignment values, which should be handled separately. -- 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]
