[Fix][Zeta] CleanLogOperation receives jobId=0 in separated cluster mode#10797
[Fix][Zeta] CleanLogOperation receives jobId=0 in separated cluster mode#10797hyboll wants to merge 1 commit intoapache:devfrom
Conversation
|
Hi @hyboll, I rechecked the current PR head locally as This PR fixes a real separated-cluster log-cleanup bug: Before this patch, I do not see a source-level blocker. The tests cover the serialization round-trip and the Conclusion: can merge after fixesBlocking item:
|
Purpose of this pull request
In separated cluster mode,
CleanLogOperationis serialized on the master node and deserialized on the worker node. SincejobIdwas not included inwriteInternal/readInternal, the worker always receivedjobId=0, causing all log files whose name contains "0" to be deleted by mistake.Root Cause
CleanLogOperationextendsTracingOperationwhich extends HazelcastOperation. When Hazelcast deserializes anIdentifiedDataSerializableon a remote node, it uses the no-arg constructor and then callsreadInternalto restore fields. SinceCleanLogOperationdid not override these methods, thejobIdfield defaulted to0after deserialization. ThegetLogFilesmethod usesname.contains(String.valueOf(jobId))as the filter, sojobId=0matches nearly every log file in the directory.Changes:
writeInternal/readInternaltoCleanLogOperationto properlyserialize jobId across Hazelcast nodes
(path == null || jobId <= 0)inTaskLogManagerService.clean()to prevent invalid cleanup attemptsDoes this PR introduce any user-facing change?
No
How was this patch tested?
Added unit tests:
CleanLogOperationSerializationTest: VerifiesjobIdis preserved through HazelcastSerializationServiceround-trip (serialize viawriteInternal, deserialize viareadInternal). Tests normaljobIdvalue.TaskLogManagerServiceTest: Verifies the boundary guard inclean(long jobId):jobId=0: guard takes effect, no files deletedjobId: matching log files are deleted, unrelated files are preservedCheck list
New License Guide
incompatible-changes.mdto describe the incompatibility caused by this PR.