Skip to content

[FLINK-32509][core] Avoid using skip in InputStreamFSInputWrapper.seek - #29246

Open
Jackeyzhe wants to merge 1 commit into
apache:masterfrom
Jackeyzhe:feature/FLINK-32509-input-stream-seek
Open

Jackeyzhe wants to merge 1 commit into
apache:masterfrom
Jackeyzhe:feature/FLINK-32509-input-stream-seek

Conversation

@Jackeyzhe

Copy link
Copy Markdown
Contributor

What is the purpose of the change

This pull request addresses
FLINK-32509.

InputStreamFSInputWrapper.seek(long) currently relies on
InputStream.skip(long) to move forward. The InputStream contract allows
skip() to return zero, including at EOF, so seeking beyond the stream can
loop forever. Some implementations can also report a positive skip beyond the
actual EOF, allowing the wrapper to accept an unreachable position.

This change makes forward seek consume bytes through a bounded buffer and
throw EOFException when the requested position cannot be reached.

Brief change log

  • Replace InputStream.skip() in forward seek with bounded read-and-discard
    operations.
  • Keep the wrapper position aligned with bytes actually consumed.
  • Add regression coverage for zero-progress EOF, false skip progress beyond
    EOF, and successful forward seek across the buffer boundary.

Verifying this change

This change added tests and can be verified as follows:

  • InputStreamFSInputWrapperTest covers normal forward seek, zero-progress EOF,
    and a stream that reports skip progress beyond its real end.
  • FileInputFormatTest covers the closest existing caller behavior.
  • ./mvnw -pl flink-core -am -DskipITs -Dtest=InputStreamFSInputWrapperTest,FileInputFormatTest -Dsurefire.failIfNoSpecifiedTests=false test
    passes 36 tests with no failures, errors, or skips.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with
    @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its
    components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • [] Yes (please specify the tool below)

Generated-by:

@flinkbot

flinkbot commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants