Skip to content

Support serialization and deserialization for GoogleCloudStorageReadOptions#39445

Open
shunping wants to merge 5 commits into
apache:masterfrom
shunping:fix-gcs-read-options
Open

Support serialization and deserialization for GoogleCloudStorageReadOptions#39445
shunping wants to merge 5 commits into
apache:masterfrom
shunping:fix-gcs-read-options

Conversation

@shunping

@shunping shunping commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes a bug where annotating GoogleCloudStorageReadOptions with @JsonIgnore caused custom GCS read options (such as fadvise) to be dropped during JSON serialization, forcing remote workers to fall back to default settings.

Additionally, in gcs-connector v3, GoogleCloudStorageReadOptions.DEFAULT changed its default fadvise from SEQUENTIAL to AUTO .

Beam workloads default to SEQUENTIAL in GcsReadOptionsFactory to preserve expected sequential read throughput and caching behavior.

Going forward, users can configure GoogleCloudStorageReadOptions so that they successfully take effect on workers using a code snippet like the following:

        // Configure GCS Read Options with AUTO fadvise
        GoogleCloudStorageReadOptions gcsReadOpt = GoogleCloudStorageReadOptions.DEFAULT.toBuilder()
                .setFadvise(GoogleCloudStorageReadOptions.Fadvise.AUTO)
                .build();
        options.as(GcsOptions.class).setGoogleCloudStorageReadOptions(gcsReadOpt);

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@shunping

Copy link
Copy Markdown
Collaborator Author

r: @Abacn

@shunping
shunping requested a review from Abacn July 22, 2026 20:33
@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@Abacn Abacn Jul 23, 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.

The size of this fix is non-trivial. There are a few concerns

  • reflection based, generally fragile

  • It also increases serialized size of pipeline options (seen in Dataflow UI, internal objects, etc).

Given that get/setGoogleCloudStorageReadOptions are deprecated and is only effective in GcsUtilV1, I would prefer a smaller fix:

  • Only json-serialize-deserialize options that we want to explicitly expose (Fadvise, etc). On serialization, when it's found not the default, write to encoding. In this way we can avoid reflection and largely reduce the serialization size

  • If possible, do not leak jackson classes to ApiSurface

@shunping shunping Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If our goal is solely to fix the regression caused by the default value of fadvise, we wouldn't need to modify the serialization and deserialization logic for GoogleCloudStorageReadOptions.

However, the broader intent of this fix is to address the underlying issue: the inability to propagate GoogleCloudStorageReadOptions to remote workers via pipeline options.

Regarding the use of reflection, it was chosen to future-proof the implementation. If we explicitly serialize fields instead of using reflection, we will be forced to update our code every time the upstream gcs-connector modifies or adds fields to this class.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I made the change to support a subset of options.

However, Jackson classes must be included in the ApiSurface. This is because GcsOptions is a public interface with methods annotated with @JsonSerialize and @JsonDeserialize. The JsonDeserialize annotation declares methods returning Class<? extends JsonDeserializer>, which pulls com.fasterxml.jackson.databind into the exposed API surface graph. JsonDeserializer, in turn, references JsonParser and other classes from com.fasterxml.jackson.core.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

shunping added 4 commits July 22, 2026 22:02
…ptions

Fixes an issue where GoogleCloudStorageReadOptions set on GcsOptions
was annotated with @JsonIgnore, causing it to be omitted when serializing
PipelineOptions for remote workers (e.g., Dataflow) and falling back to
defaults.
This fixes the regression introduced by gcs-connector v3.
@shunping
shunping force-pushed the fix-gcs-read-options branch from efc6f35 to 74d2358 Compare July 23, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants