Skip to content

[FLINK-30975][filesystems] Upgrade to Hadoop to 3.4.3 and support AWS SDK v2 in flink-filesystem - #27026

Open
ctrlaltdilj wants to merge 1 commit into
apache:masterfrom
ctrlaltdilj:upgrade-hadoop
Open

[FLINK-30975][filesystems] Upgrade to Hadoop to 3.4.3 and support AWS SDK v2 in flink-filesystem#27026
ctrlaltdilj wants to merge 1 commit into
apache:masterfrom
ctrlaltdilj:upgrade-hadoop

Conversation

@ctrlaltdilj

@ctrlaltdilj ctrlaltdilj commented Sep 23, 2025

Copy link
Copy Markdown

What is the purpose of the change

Hadoop 3.4.X introduced 2500+ bug fixes and support for AWS SDK V2. Note AWS SDK V1 is EOL 12/31/2025.

One challenge is maintaining support for presto which is using AWS SDK V1 and is not updated just yet, While Hadoop 3.4.X has support for AWS SDK V1 there are a couple wrapper classes need to support the SDK changes and maintain support for Presto's AWS SDK V1 and support Hadoop's AWS SDK V2 upgrade.

Brief change log

  • update hadoop to 3.4.2
  • provide wrapper classes to support AWS SDK V1/V2

Verifying this change

This change is already covered by existing tests and adds new test coverage:

Existing tests:
- All existing unit tests for flink-s3-fs-hadoop (HadoopS3FileSystemTest, HadoopS3FileSystemsSchemesTest) pass with Hadoop 3.4.2 and AWS
SDK V2
- All existing unit tests for flink-s3-fs-presto continue to pass with AWS SDK V1
- Integration tests (HAJobRunOnHadoopS3FileSystemITCase, S5CmdOnHadoopS3FileSystemITCase) verify S3 functionality with new SDK

New/updated tests:
- Converted S3FileSystemMinioTest and PrestoS3FileSystemMinioTest E2E tests to JUnit framework
- Both tests verify write, read, and delete operations against MinIO (S3-compatible storage)
- Tests confirm that both Hadoop (SDK V2) and Presto (SDK V1) filesystems work correctly

Manual verification:
- Verified AWS SDK V1 is completely removed from flink-s3-fs-hadoop JAR (0 classes from com.amazonaws.*)
- Verified AWS SDK V1 remains in flink-s3-fs-presto JAR as expected
- Confirmed multipart upload operations work correctly with new HadoopS3AccessHelper

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

  • Dependencies (does it add or upgrade a dependency): yes (Hadoop 3.3.6 → 3.4.2, adds AWS SDK V2 to Hadoop module)
  • 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: yes (Hadoop S3 filesystem now uses AWS SDK V2)

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable (this is a dependency upgrade and internal refactoring)

@ctrlaltdilj ctrlaltdilj changed the title Upgrade hadoop [FLINK-30975] Upgrade hadoop to start adding support for AWS SDK V2 Sep 23, 2025
@ctrlaltdilj ctrlaltdilj changed the title [FLINK-30975] Upgrade hadoop to start adding support for AWS SDK V2 [FLINK-30975] Upgrade hadoop to 3.4.X Sep 23, 2025
@flinkbot

flinkbot commented Sep 23, 2025

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

@ctrlaltdilj
ctrlaltdilj marked this pull request as draft September 23, 2025 03:37
@ctrlaltdilj
ctrlaltdilj marked this pull request as ready for review October 4, 2025 17:49

@Samrat002 Samrat002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure

  1. Code is compiling, and all integration tests are passing properly
  2. Add proof of code working e2e with S3 filesystem with a sample application

@ctrlaltdilj
ctrlaltdilj requested a review from Samrat002 October 6, 2025 17:07
@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Oct 7, 2025
@davidradl

Copy link
Copy Markdown
Contributor

I am not in a position to approve this as I do not know the area. The title says upgrade hadoop 3.4.x - I am not sure what backports you could do - I assume you would want to deprecate the existing hadoop version and add the new one.

@ctrlaltdilj
ctrlaltdilj requested a review from davidradl October 11, 2025 21:59

@Samrat002 Samrat002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @ctrlaltdilj for the patch.
I have reviewed the changes at a high level.

Cheers, Samrat

Comment thread flink-end-to-end-tests/flink-presto-s3-filesystem-test/pom.xml
@ctrlaltdilj
ctrlaltdilj requested a review from Samrat002 October 20, 2025 18:26
@MartijnVisser

Copy link
Copy Markdown
Contributor

This upgrade won't address the concerns from #23844 (comment) - I don't think we can't move forward with this one right now.

@ctrlaltdilj

ctrlaltdilj commented Oct 26, 2025

Copy link
Copy Markdown
Author

@MartijnVisser I was thinking about working through this by creating FlinkS3AFileSystem which provides access to the s3Client, not a huge fan of this(just work around), what do you think?

@rmetzger

Copy link
Copy Markdown
Contributor

I have not spend a lot of time fully understanding the hadoop upgrade situation, but before I go into a research rabbithole:
Why are the concerns raised my @MartijnVisser in #23844 (comment) not breaking any test?
Ideally we should have a test that only passes when our S3 FS implementation is stable. Once we have that in place, we can get more confidence in a fix.

@MartijnVisser

Copy link
Copy Markdown
Contributor

Why are the concerns raised my @MartijnVisser in #23844 (comment) not breaking any test?

Because S3 tests only run on merged PRs, because they rely on AWS S3 credentials that aren't in the pipelines because they could get leaked.

@rmetzger

Copy link
Copy Markdown
Contributor

Because S3 tests only run on merged PRs

Ok, I see. You can also run them locally by setting these env variables, I believe:

  export IT_CASE_S3_BUCKET="your-bucket-name"
  export IT_CASE_S3_ACCESS_KEY="your-access-key"
  export IT_CASE_S3_SECRET_KEY="your-secret-key"

@ctrlaltdilj have you validated this PR locally with those env variables set against a real S3 bucket?

@ctrlaltdilj

ctrlaltdilj commented Feb 11, 2026

Copy link
Copy Markdown
Author

@rmetzger @MartijnVisser I believe I had ran this locally a couple months ago, I'll run my test against S3 bucket

@ctrlaltdilj

Copy link
Copy Markdown
Author

@rmetzger @MartijnVisser I have tested locally against a real s3 bucket and the tests are working

@ctrlaltdilj

Copy link
Copy Markdown
Author

let me check if I can simplify these changes and add performance tests

@MartijnVisser

Copy link
Copy Markdown
Contributor

let me check if I can simplify these changes and add performance tests

It would be good to first get the CI tests passing

@xx789633

Copy link
Copy Markdown

This upgrade is particularly important and useful, given that AWS SDK v1 reached end-of-support in December 2025.

Comment thread .github/workflows/template.flink-ci.yml
@ctrlaltdilj

Copy link
Copy Markdown
Author

@rmetzger @MartijnVisser do you think can you enable the CI runs for this PR

@rmetzger

Copy link
Copy Markdown
Contributor

I think this has been extensively reviewed, and we'll have some time for testing it from the master branch in the coming months before the next release, so I'm fine merging it.

@ctrlaltdilj

ctrlaltdilj commented Jun 22, 2026

Copy link
Copy Markdown
Author

thanks for the work that has gone into the reviews thus far, happy to tackle any bugs or issues( hopefully none 🤞) that arise.

@Samrat002

Samrat002 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

From our internal experience, we initially started by upgrading Hadoop to 3.x and leveraging SDK v2. As you can see, I have initiated the Jira and shared the first version of the patch.

Before we merge this patch, I think the following details need to be added for a better understanding of the behaviour of the upgrade and what we are adding as transitive changes.

  1. There are a good number of Flink jobs where flink-s3-fs-presto and flink-s3-fs-hadoop are used. One for checkpointing and another for better performance for Filesystem writes. Have this patch tested for such scenarios? @ctrlaltdilj Is it possible for you to add/share a successful run along with metrics of the TM JVM profile?

  2. With the current implementation, two SDKs share one TaskManager JVM (Presto for checkpoints + Hadoop for the file sink deployment). JVM-level resource utilisation on long-running jobs has absert observations

  3. @ctrlaltdilj Can you showcase the scenario where any upgrade/restore across the version boundary? Savepoint written by old (v1) build, restored by new (v2)

  4. hadoop-aws 3.4 ships S3A prefetching / analytics-accelerator → changed read pattern, more memory per stream and different (often higher) GET volume → S3 cost surprises and new throttling for big table scans/batch reads. this is infact true with native-s3-fs but we have added patch to control the unregulated api calls to s3 service

@snuyanzin @gaborgsomogyi

@Poorvankbhatia / @rkhachatryan
(viz)

@rkhachatryan rkhachatryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to do a more complete meta review but so far I only have a concern about breaking Presto.
Can you please double check that this PR doesn't introduce class not found exceptions in case when only Presto is used?

Comment thread flink-filesystems/flink-s3-fs-presto/pom.xml

@Samrat002 Samrat002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left few comment.

My major concern is this patch upgrade the flink-s3-base and touches flink-s3-presto.

  1. this can have impact on flink users who uses both connector for a job.
  2. there are few specific dependencies are removed explicitly which fixes vulnerablities . e.g : https://issues.apache.org/jira/browse/FLINK-21123.

it would be great @ctrlaltdilj if you can share logs and test results of using presto-s3 e2e for a fink job ?

Comment thread flink-filesystems/flink-s3-fs-base/pom.xml
Comment thread flink-filesystems/flink-s3-fs-presto/pom.xml
@ctrlaltdilj

Copy link
Copy Markdown
Author

taking a look at the comments

@ctrlaltdilj
ctrlaltdilj force-pushed the upgrade-hadoop branch 4 times, most recently from 0cc78f8 to 437fc04 Compare July 13, 2026 06:15
@ctrlaltdilj

Copy link
Copy Markdown
Author

Will do some performance tomorrow and report back

@ctrlaltdilj

Copy link
Copy Markdown
Author

All testing was done with Minio:

Write (10.28 GB, 5 M × 2 KB records, unthrottled FileSink, 64 MB roll):
old 17,886 ms (16,838–18,140), 64.95 CPU-s · new 16,574 ms (16,310–16,719), 56.42 CPU-s · both sides: exactly 156 MPUs / 1,994 uploaded parts / 156 completes per run

Read (same fixed 10.28 GB / 156-object dataset, both sides read identical objects):
old 157,717 ms / 310.2 CPU-s · new 160,930 ms / 306.5 CPU-s · both: 156 GetObject (one per object, sequential), 314 HeadObject, 6 ListObjectsV2.

Checkpoint latency (StateMachine-style, 90 checkpoints/run, small state):
s3p control p50 2–3 ms both sides; s3a p50 12–13 ms (old) vs 10.5–14 ms (new); savepoint ~1.0–1.1 s; restore-to-first-checkpoint ~4.1–4.3 s — parity everywhere, presto control unchanged as expected (same SDK v1 on both sides).

Checkpoint throughput (~560 MB full hashmap snapshots every 5 s, stats over all >400 MB checkpoints):
s3a old: median 816 ms → 693 MB/s, 78–85 CPU-s, plus 607–761 bulk-delete marker calls/run · s3a new: median 750 ms → 759 MB/s, 54–57 CPU-s, 0 bulk-deletes · s3p control: 298 vs 282 MB/s (parity). The hadoop
path uses 64 MB parts (386–400 parts/run) vs presto's ~5 MB parts (3,300–3,900/run) on both sides.

@rkhachatryan rkhachatryan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR!

I've left some comments, PTAL.

Apart from that, it looks like configuration is effectively changed upon migration due to inheriting default configs:

  The PR's own code changes nothing here — applyHadoopConfigDefaults only pins fs.s3a.input.stream.type=classic; nothing else touches buffers/threads/pools/retries.

  But Hadoop's own defaults shifted 3.3.6→3.4.2/3.4.3, and this PR inherits every bit of it silently (verified against Constants.java/AWSClientConfig.java across the actual release tags):

  ┌─────────────────────────────────────────────────────────┬──────────────────┬───────────────────────────────────────────────────────────┬─────────────────────────────────────────┐
  │                         Setting                         │  3.3.x (SDK v1)  │                      3.4.x (SDK v2)                       │                 Change                  │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ fs.s3a.connection.maximum (HTTP pool size)              │ 96               │ 500                                                       │ 5x more connections                     │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ fs.s3a.threads.max                                      │ 10               │ 96                                                        │ ~10x more threads                       │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ fs.s3a.attempts.maximum (retry count)                   │ 10               │ 5                                                         │ halved                                  │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ Retry strategy                                          │ SDK v1 legacy    │ SDK v2 RetryMode.ADAPTIVE (client-side throttling-aware   │ qualitatively different, not just       │
  │                                                         │ policy           │ rate limiting)                                            │ backoff timing                          │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ fs.s3a.connection.establish.timeout                     │ 50s              │ 30s                                                       │ shorter                                 │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ fs.s3a.connection.acquisition.timeout /                 │ n/a              │ 60s / 5min                                                │ new, SDK v2-only                        │
  │ fs.s3a.connection.ttl                                   │                  │                                                           │                                         │
  ├─────────────────────────────────────────────────────────┼──────────────────┼───────────────────────────────────────────────────────────┼─────────────────────────────────────────┤
  │ Multipart size/threshold, fast-upload-buffer            │ 64MB / 128MB /   │ unchanged                                                 │ not a concern                           │
  │                                                         │ disk             │                                                           │                                         │
  └─────────────────────────────────────────────────────────┴──────────────────┴───────────────────────────────────────────────────────────┴─────────────────────────────────────────┘

I don't think we should preserve the config strictly as-is, but such changes should be justified and documented.

Comment on lines +93 to +97
// S3A keeps zero-byte directory markers since Hadoop 3.4
// (fs.s3a.directory.marker.retention defaults to "keep"); only actual
// ApplicationResultStore entries are relevant for the assertions.
.filter(summary -> !summary.getKey().endsWith("/"))
.collect(Collectors.toList());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we keep the current behavior by configuring fs.s3a.directory.marker.retention?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, fixed, so we now set s3.directory.marker.retention: delete in the test config instead and dropped the listing filter

Comment on lines +333 to +335
final CompletedPart completedPart =
CompletedPart.builder().partNumber(partNumber).eTag(result.eTag()).build();
future.complete(completedPart);

@rkhachatryan rkhachatryan Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With SDK v2, this becomes incorrect if user sets s.s3a.checksum.generation=true. In that case, S3 will require checksum per part and fail the request because the checksum is missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for calling that out, I fixed it by copying every checksum field from the UploadPartResponse into the CompletedPart (centralized in a new S3PartChecksum enum so the set can't drift from the SDK). That also required bumping S3RecoverableSerializer to v2, recoverable persisted at checkpoints only stored partNumber and eTag, so a commit after recovery would have failed the same way. v1 state deserializes as before (it predates checksum generation, so checksum-less is correct)


@Override
public AwsCredentials resolveCredentials() throws SdkException {
S3SessionCredentials credentials = AbstractS3DelegationTokenReceiver.getCredentials();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fragile: this code (HadoopDynamicTemporaryAWSCredentialsProvider) has only sdk v1 on its classpath; however, AbstractS3DelegationTokenReceiver imports sdk v2 code.
If a AbstractS3DelegationTokenReceiver / S3SessionCredentials method that uses sdk v2 classes is called (in the future); that will result in class not found exception.

I'm not sure it's worth fixing it though given that we'll have v2 (and native) S3.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via S3SessionCredentials which is a plain POJO with no SDK imports, and conversion to v1/v2 types happens only inside each plugin's own credentials provider. Let me know if you prefer to handle this differently

@ctrlaltdilj

Copy link
Copy Markdown
Author

addressing the comments today

@rmetzger

rmetzger commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Cool, thank you!

@ctrlaltdilj
ctrlaltdilj force-pushed the upgrade-hadoop branch 2 times, most recently from 6409732 to b99b991 Compare September 7, 2026 16:08
@ctrlaltdilj

Copy link
Copy Markdown
Author

@rkhachatryan thanks for your review, I have made some of the fixes you pointed out, let me know what you think

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

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants