Repository navigation
Conversation
MapFileMeta only creates its writing-segment map and segment indexes on the first segment, so toPbFileInfo threw an NPE for MAP partitions written without segment granularity. The worker's committed file info saver then stopped and the shutdown save skipped those shuffles, so they could not be recovered after a graceful restart.
| // Both are created lazily on the first segment: null without segment granularity. | ||
| if (mapFileMeta.getSubPartitionWritingSegmentId != null) { | ||
| builder.putAllPartitionWritingSegment(mapFileMeta.getSubPartitionWritingSegmentId) | ||
| } |
There was a problem hiding this comment.
Verified the NPE and that the periodic saver (saveCommittedFileInfosExecutor) silently stops after the first uncaught exception. LGTM.
One note: after restore these fields are empty collections rather than null, so MapFileMeta#hasPartitionSegmentIds() now returns true for restored non-segment MAP partitions. That is harmless today since reader selection is based on isSegmentGranularityVisible(), but it is a subtle semantic difference worth a sentence in the PR description.
yew1eb
left a comment
There was a problem hiding this comment.
+1, LGTM. Verified against main: both fields are lazily initialized in MapFileMeta, and the worker builds MAP file metas via the no-arg constructor in both createMemoryFileInfo and getFileMeta, so both stay null without segment granularity. The restore path is also safe — restored metas are writer-closed and non-segment MAP partitions are read through plain MapPartitionData.
One process nit: the PR title is missing a JIRA id — Apache projects generally expect [CELEBORN-xxxx] in the title. Could you file a JIRA and retitle?
What changes were proposed in this pull request?
PbSerDeUtils.toPbFileInfonow adds the MAP partition's writing-segment map and segment indexes only when they are non-null.MapFileMetacreates both lazily, on the firstaddPartitionSegmentId/addSegmentIdAndFirstBufferIndexcall. The worker builds MAP file metas withnew MapFileMeta(), so for a MAP partition written without segment granularity both fields staynull, andputAllPartitionWritingSegment(null)threw:On restore,
fromPbFileInforeads both fields back as empty (not null). That is safe. Non-segment MAP partitions are read throughMapPartitionData, which never touches either field.getSegmentIdByFirstBufferIndexreturnsnullfor an empty index list, and restored metas are already marked writer-closed, so nothing writes to them. Partitions with segment granularity serialize exactly as before.Why are the changes needed?
When graceful shutdown is enabled, the worker persists committed file infos through
toPbFileInfoMap→toPbFileInfoin two places, and the NPE breaks both:worker-storage-manager-committed-fileinfo-saver). It runs withscheduleWithFixedDelayand does not catch the NPE, so the first failure cancels it and nothing is saved afterwards.saveAllCommittedFileInfosToDBat shutdown. It logs the error and skips any shuffle that contains such a MAP partition.As a result, after a graceful restart the worker cannot recover MAP partitions written without segment granularity, such as Flink shuffle partitions. Readers fail to find them, and the producing tasks have to be re-run.
Does this PR resolve a correctness bug?
Shuffle data is never incorrect. Partitions are lost on graceful restart instead of being recovered.
Does this PR introduce any user-facing change?
With graceful shutdown enabled, a worker restart now recovers committed MAP partitions without segment granularity. No configuration or protocol change.
How was this patch tested?
Added two tests to
PbSerDeUtilsTest:fromAndToPbFileInfo with MapFileMeta without segment granularitybuilds the meta the way the worker does (no-arg constructor plus buffer size and subpartition count). It round-trips it throughtoPbFileInfo/fromPbFileInfoand throughtoPbFileInfoMap/fromPbFileInfoMap, checking the buffer size, subpartition count, segment-granularity flag, writer-closed flag, a segment lookup, path and length. Onmainit fails with the NPE above.fromAndToPbFileInfo with MapFileMeta with segment granularityis a regression check. It confirms that recorded segment IDs and segment indexes still round-trip.