Hi Sophia, Martijn, DJ,

Thanks for the summary. And thanks DJ for the pointer to FLINK-41054 /
#29564 — the "detect rather than tolerate" distinction is a helpful way to
frame the completeness question.
I've put the PoC I implemented earlier in this PR
https://github.com/lvyanquan/flink/pull/8 on my fork, so it can serve as a
reference.

One note on the completeness question. I re-checked the mainstream file
systems and could not find any basis for FileSystem.listStatus transiently
omitting files that keep existing — i.e. a listing that flickers for a
directory that is not actually being modified. My consecutive-absence check
was mainly a conservative defence based on community discussions I had seen
earlier, but I haven't been able to locate the exact source yet; I will add
it once I find it. Please re-evaluate that part and treat it accordingly.

You are very welcome to build the reference implementation from the
existing code, and I would be glad to help review it. If you run into any
issues while drafting the FLIP, I'm happy to assist with that as well.

Best regards, Yanquan


Sophia Izokun via dev <[email protected]> 于2026年12月3日周四 07:27写道:

> Hi Martijn, Yanquan, DJ,
>
> Thank you all. Summarizing where I think the discussion landed, so we can
> move to a FLIP:
>
>   1.
> Option C (drop processed paths that are absent from a complete listing) as
> the primary mechanism, opt in to start with the two behaviour changes
> Martijn described documented (a file recreated under the same path, or
> moved out and back, is read again)
>   2.
> Option B withdrawn. The S3 lifecycle timing point settles this one.
>   3.
> Option A kept as a second opt in for directories without any retention, in
> the spirit of Spark's maxFileAge, with no default offset.
>   4.
> A gauge for the number of tracked paths.
>
> Sequencing -- I agree FLINK-29757 goes first, and I'll open a PR for it
> this week. I'm not reviving the 2022 PR as is. It keys the state on
> path+offset+length, so state grows per split and every file is re-read on
> restore from an existing checkpoint. A path level fix keeps the key and the
> format unchanged, and it builds the listed paths set that option C needs
> anyway.
>
> I'll write this up as a FLIP this week. It will reference FLIP-619 as
> complementary (that one makes large coordinator state storable while this
> one makes it small) and FLINK-22792 as the original report.
>
> @Yanquan Lv<mailto:[email protected]>, would you be open to sharing your
> poc? I'd like to start the reference implementation from it and credit it
> in the FLIP, rather than build it twice.
> Regards,
> Sophia
>
> From: ctrlaltdilj.icloud.com via dev <[email protected]>
> Date: Tuesday, 1 December 2026 at 17:04
> To: [email protected] <[email protected]>
> Cc: Martijn Visser <[email protected]>; [email protected] <
> [email protected]>
> Subject: [EXTERNAL] Re: [DISCUSS] FLINK-25672: FileSource enumerator
> remembers paths of all already processed files
>
> Hi all,
>
> A related change may be useful as a reference here: FLINK-41054 [1],
> PR #29564 [2]. It takes the same approach as option C, in the REST
> MetricStore rather than the FileSource.
>
> The MetricStore keeps every metric a TaskManager ever reported, so
> per-split metrics stay forever once a split finishes. The PR removes a
> metric when it is missing from the TaskManager's dump, since the dump is
> a full listing of what the TaskManager currently reports.
>
> The same "is the listing complete" concern raised in this thread applies.
> A dump can be cut short, for example when it exceeds the RPC frame size.
> The PR marks such dumps as incomplete and only removes metrics based on
> dumps that are provably complete. An incomplete dump is merged add-only,
> as today. That made a consecutive-absence threshold unnecessary for us,
> because a bad listing is detected rather than tolerated. Whether a file
> system listing can give the enumerator the same guarantee is probably the
> deciding question for option C.
>
> Best regards,
> Diljeet(DJ) Singh
>
> [1]
> https://urldefense.proofpoint.com/v2/url?u=https-3A__issues.apache.org_jira_browse_FLINK-2D41054&d=DwIFaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=TTS5IrHagwPHfc0X_GcS-SOrTIAyeka2alEZWqYzCeU&m=ntM-lF0sfB8p2wo6uDuO-8QfuoFUhYd-hXaKnhO_wKERGsQCYe8JYV1XpOkgy483&s=RYjQfBoDJsqhvO1f_5ILcpujLpQ9YoqICaGBEEXVK7I&e=
> [2]
> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_flink_pull_29564&d=DwIFaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=TTS5IrHagwPHfc0X_GcS-SOrTIAyeka2alEZWqYzCeU&m=ntM-lF0sfB8p2wo6uDuO-8QfuoFUhYd-hXaKnhO_wKERGsQCYe8JYV1XpOkgy483&s=hlXBmOckVxcWY9RsnKu0IrHwH2lMM4pLkSg9_LC2D1Q&e=
>
> > On Nov 27, 2026, at 10:07 AM, Martijn Visser via dev <
> [email protected]> wrote:
> >
> > Hi Sophia,
> >
> > Thanks for the write-up. I ran both options and a third one through a
> simulation.
> >
> > The enumerator lists the whole directory tree on every discovery
> interval, so a processed path that is missing from a listing is gone and
> can be dropped from the state. The state is then bounded by the files that
> exist, needs no mtime assumption, clock or TTL, and keeps the current
> checkpoint format. It does change two cases: a file that is deleted and
> recreated under the same path is read again, and a file that is moved out
> and back is read twice. So I think it should start as an opt-in.
> >
> > 1. I would prefer that third option, with option a as a second opt-in
> for directories without retention, like Spark's maxFileAge.
> > 2. I don't think there is a safe default. S3 sets Last-Modified of a
> multipart upload to when the upload started, and our FileSink completes it
> only after the next checkpoint. With a 15 minute rollover and 10 minute
> checkpoints, a 5 minute offset skipped 42% of the files.
> > 3. S3 lifecycle rounds expiry up to midnight UTC and doesn't guarantee
> when it deletes, so a TTL equal to the retention re-reads files.
> > 4. Yes.
> > 5. A new option on the FileSource builder is public API, so that needs a
> FLIP.
> >
> > Best regards,
> >
> > Martijn
> >
> > On 2026-05-04 15:09 UTC Sophia Izokun via dev wrote:
> >> Hello Everyone,
> >>
> >> I'd like to start a discussion on FLINK-25672 [1], which I've recently
> >> been assigned. Before drafting a FLIP I want to lay out the design space
> >> and get the community's input on which direction (or combination) to
> >> pursue.
> >>
> >>
> >> The FiileSource​ ContinuousFileSplitEnumerator​ keeps an unbounded
> HashSet<Path> of every
> >> file ever processed. The set is held in JobManager coordinator state and
> >> serialized into PendingSplitsCheckpoint on every checkpoint. For
> >> long-running streaming jobs over massive amounts of data, this set
> >> grows without bound and is also documented as a current limitation in
> >> the FileSystem connector docs [2].
> >>
> >> Two independent production reports establish the pattern:
> >>
> >>  - Cliff R. (FLINK-25672 comment, Jan 2023): 16 GB JM heap pool
> >>    exhausted in a HA Kubernetes setup, blocked by un-evictable file
> >>    path history.
> >>
> >>  - Nickel F. (FLINK-25672 comment, Apr 2025): JM OOM, fixed in their
> >>    fork with TTL-based eviction.
> >>
> >>
> >> The comments above implemented their own fixes because the project
> hasn't
> >> shipped one yet.
> >>
> >>
> >>
> >> I am currently mulling over two viable options, both options below are
> opt-in (default behavior unchanged), keep the serializer's V1
> deserialization branch intact for savepoint compatibility, and change
> PendingSplitsCheckpointSerializer​ to V2.
> >>
> >> Option a: watermark + offset
> >>
> >> Replace the unbounded HashSet<Path> with two pieces of state:
> >>
> >>  - maxProcessedTime: the highest mtime ever processed.
> >>  - processedFilesInOffsetWindow: a HashSet<Path> of paths whose mtime
> >>    falls within [maxProcessedTime - offset, maxProcessedTime].
> >>
> >> Dedup decision: a file is new if mtime >= maxProcessedTime - offset AND
> >> the path isn't in the windowed set. After each discovery batch, advance
> >> the watermark and evict anything older than (maxProcessedTime - offset).
> >>
> >> User-facing API (sketch):
> >>
> >>  FileSource.forRecordStreamFormat(format, path)
> >>      .monitorContinuously(Duration.ofSeconds(30))
> >>      .outOfOrderTolerance(Duration.ofMinutes(5))
> >>      .build();
> >>
> >> pros:
> >>  - State bounded by the offset window. For typical workloads that's
> >>    a few KB to a few MB.
> >>  - No external prerequisite. Works on any filesystem.
> >>  - FileSourceSplit already carries fileModificationTime, so no
> >>    FileSystem API changes are needed.
> >>
> >> cons:
> >>  - Files with mtime older than (maxProcessedTime - offset) are
> >>    silently dropped. This breaks the following workloads:
> >>
> >>  *
> >> Historical backfills
> >>  *
> >> Application-level mtime overrides (mtime set to event-time
> >>
> >>        rather than wall-clock).
> >>  - The offset must be sized appropriately to absorb expected mtime v.
> arrival
> >>    variance, including scenarios such as S3 multipart upload duration
> and replication
> >>    lag.
> >>
> >> i believe there are some mitigations that can be included such as:
> >>  - a metric: count files skipped because their mtime fell below the
> >>    boundary. This makes the silent-drop failure mode observable to the
> end user.
> >>  - an optional way to deal with this: configurable late-file policy
> (skip / process /
> >>    side-output), mirroring how Flink handles late records.
> >>
> >> option b: TTL-based eviction
> >>
> >> Keep a path set, but tag each entry with the timestamp at which it was
> >> processed and evict entries older than a configurable retention.
> >>
> >> State: LinkedHashMap<Path, Long> processedPathsByTime. Insertion-order
> >> iteration makes eviction amortized.
> >>
> >> User-facing API (sketch):
> >>
> >>  FileSource.forRecordStreamFormat(format, path)
> >>      .monitorContinuously(Duration.ofSeconds(30))
> >>      .withProcessedPathsRetention(Duration.ofDays(7))
> >>      .build();
> >>
> >> Pros:
> >>  - No assumption about mtime semantics. Backfills, replication lag,
> >>    and application-level mtime overrides all work correctly because
> >>    dedup is by path, not by timestamp.
> >>  - Quite conceptually simple and easy: same data structure, just with
> eviction.
> >>  - Already proven in production
> https://urldefense.proofpoint.com/v2/url?u=https-3A__issues.apache.org_jira_browse_FLINK-2D25672-3FfocusedCommentId-3D17941577-26page-3Dcom.atlassian.jira.plugin.system.issuetabpanels-3Acomment-2Dtabpanel-23comment-2D17941577&d=DwIFaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=TTS5IrHagwPHfc0X_GcS-SOrTIAyeka2alEZWqYzCeU&m=ntM-lF0sfB8p2wo6uDuO-8QfuoFUhYd-hXaKnhO_wKERGsQCYe8JYV1XpOkgy483&s=H4f3QGdn89RrG3jx1fBVJq2iAeWLOZBriYXprsUv0SE&e=
> .
> >>
> >> Cons:
> >>  - Requires an external retention guarantee from the user (such as a S3
> >>    lifecycle policy). If storage retention is longer than the
> >>    configured TTL, files reappear and get reprocessed silently.
> >>  - State is bounded by retention duration, not by offset window.
> >>    For a 7-day retention on a busy datalake, that's still tens of
> >>    millions of paths, though it is better than unbounded it can still
> get quite large. Larger than the first options footprint
> >>
> >> Both options above require tradeoffs regardless of which method is used.
> >>
> >> Another option is that we could ship both behind explicit builder
> methods,
> >> with the unbounded mode as default. But that conclusion should come out
> >> of this discussion, not into it.
> >>
> >>
> >>
> >>
> >> My question for this dev list:
> >>
> >>  1. Single mechanism or both? If one, which one?
> >>  2. For option a: reasonable default offset? my instinct is 5 min as a
> default to absorb
> >>     multipart uploads and replication lag, but I have no strong
> >>     basis for that number.
> >>  3. For option b: when we measure how old a path entry is for eviction,
> should we use the JobManager's wall-clock time or Flink's processing time?
> My instinct is wall-clock since users will set the TTL to match their
> external storage retention
> >>  4. is it worth introducing a `processedPathsStateSize` metric so users
> >>     can observe state size regardless of which mode they choose?
> >>  5. Does the scope of this change warrant a FLIP, or is a
> >>     well documented pull request sufficient given the additive, opt-in
> >>     nature?
> >>
> >>
> >> Regards,
> >> Sophia
> >>
> >> [1]
> https://urldefense.proofpoint.com/v2/url?u=https-3A__issues.apache.org_jira_browse_FLINK-2D25672&d=DwIFaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=TTS5IrHagwPHfc0X_GcS-SOrTIAyeka2alEZWqYzCeU&m=ntM-lF0sfB8p2wo6uDuO-8QfuoFUhYd-hXaKnhO_wKERGsQCYe8JYV1XpOkgy483&s=mn73VnjUmfHr1_RPYglhoM0wGu1SPJunTmVJnDPZR2k&e=
> >> [2]
> https://urldefense.proofpoint.com/v2/url?u=https-3A__nightlies.apache.org_flink_flink-2Ddocs-2Dstable_docs_connectors_datastream_filesystem_-23current-2Dlimitations&d=DwIFaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=TTS5IrHagwPHfc0X_GcS-SOrTIAyeka2alEZWqYzCeU&m=ntM-lF0sfB8p2wo6uDuO-8QfuoFUhYd-hXaKnhO_wKERGsQCYe8JYV1XpOkgy483&s=4O4tVuJS3CuDi_72yyfReiJHep05rX0taYVW_FkPpZo&e=
> >>
> >>
>
>

Reply via email to