Skip to content

CASSANALYTICS-221: Add COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option to enable Sidecar fast forward for coordinated write - #262

Open
mansikhara wants to merge 7 commits into
apache:trunkfrom
mansikhara:CASSANALYTICS-221
Open

mansikhara wants to merge 7 commits into
apache:trunkfrom
mansikhara:CASSANALYTICS-221

Conversation

@mansikhara

@mansikhara mansikhara commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

JIRA: https://issues.apache.org/jira/browse/CASSANALYTICS-221

CASSSIDECAR-463 added fast forward to Sidecar: it stages slices while a coordinated restore job is still in CREATED status, and imports once the job reaches STAGED, instead of waiting for the STAGE_READY and IMPORT_READY signals. It is set per restore job, so clients need a way to request it.

This PR adds the COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option. When it's set, the driver sends fastForwardEnabled=true when creating the restore job on every cluster in COORDINATED_WRITE_CONFIG.

.option("COORDINATED_WRITE_CONFIG", coordinatedWriteConfJson)
.option("COORDINATED_WRITE_FAST_FORWARD_ENABLED", "true")
  • The option applies to all clusters, since they must all run the same way. It defaults to false and is rejected unless COORDINATED_WRITE_CONFIG is present.
  • It's stored on CoordinatedWriteConf as a top-level fastForwardEnabled(), not in the per-cluster JSON, so toJson() and existing configs are unchanged. BulkSparkConf applies it after buildCoordinatedWriteConf(), so subclasses that override that method pick it up too, both on the driver and when executors rebuild the transient conf.
  • Ports fastForwardEnabled into the Analytics copy of CreateRestoreJobRequestPayload, including Sidecar's requirement that a consistency level is set. When false, the field is omitted from the create restore job request, so existing jobs and Sidecars without fast forward support are unaffected.
  • Extracts the per-cluster create restore job request into CassandraBulkSourceRelation.buildCoordinatedRestoreJobPayload so it can be unit tested.
  • With fast forward, STAGED becomes the point of no return: imported data is visible immediately and can't be rolled back, and a failure after STAGED is reported as a job failure even though some data may already be imported. The option's Javadoc and docs/src/user.adoc document this, along with the S3 replication and older Sidecar behavior.

Testing:

  • BulkSparkConfTest: the option is rejected without COORDINATED_WRITE_CONFIG, defaults to false, and survives a serialization round-trip (executor path).
  • CoordinatedWriteConfTest: defaults to false; withFastForwardEnabled returns a copy and leaves the per-cluster JSON unchanged.
  • BuildCoordinatedRestoreJobPayloadTest: the per-cluster create restore job request carries fastForwardEnabled and writeToLocalDcOnly.
  • CreateRestoreJobRequestPayloadTest: default omitted from JSON, round-trip, rejected without a consistency level.

…option to enable Sidecar fast forward for coordinated write

Sidecar (CASSSIDECAR-463) can eagerly pipeline the staging and importing
phases of a coordinated write: it stages slices while the job is still in
CREATED status and imports once the job reaches STAGED, instead of waiting
for the STAGE_READY and IMPORT_READY signals. The option is set per restore
job, so it only takes effect when the client asks for it.

Add the COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option. When set, the
driver sends fastForwardEnabled=true when creating the restore job on each
cluster. The option defaults to false and requires COORDINATED_WRITE_CONFIG.

Port the fastForwardEnabled field into the Analytics copy of
CreateRestoreJobRequestPayload, including the requirement that a
consistency level is set. The field is omitted from the request when false,
so jobs that don't enable it, and Sidecars without fast forward support,
are unaffected.

Patch by Mansi Khara for CASSANALYTICS-221
* The option should only be enabled by callers that can accept that the imported data becomes immediately visible
* and that importing cannot be rolled back.
*/
public static final String JOB_FAST_FORWARD_ENABLED = "fastForwardEnabled";

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.

Since this option is only applicable to coordinated write, how about placing it under CoordinatedWriteConf.ClusterConf? For example, boolean writeToLocalDcOnly() is a similar case and it's part of ClusterConf

Address review: fast forward only applies to coordinated write, so make it a
per-cluster field of the coordinated write config, alongside
writeToLocalDcOnly, instead of a top-level writer option. This drops the
COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option and its BulkSparkConf
and JobInfo plumbing, and matches Sidecar, where fast forward is a property
of each cluster's restore job.
@mansikhara mansikhara changed the title CASSANALYTICS-221: Add COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option to enable Sidecar fast forward for coordinated write CASSANALYTICS-221: Add fastForwardEnabled to the coordinated write cluster config to enable Sidecar fast forward Nov 19, 2026
mkhara added 2 commits November 19, 2026 14:27
…s, and test the restore job request

Address review:
- Make ClusterConf.fastForwardEnabled() a default method returning false, so
  existing ClusterConf implementations keep compiling and don't fail with
  AbstractMethodError.
- Reject coordinated write configs that enable fast forward for only some
  clusters. Otherwise, those clusters import at STAGED while the others wait
  for IMPORT_READY, and aborting before IMPORT_READY leaves the clusters out
  of sync with no way to roll back.
- Clarify in the Javadoc and user docs that importing starts at STAGED,
  which the driver sets only after all clusters have staged and satisfied
  the consistency level.
- Extract the per-cluster create restore job request into
  buildCoordinatedRestoreJobPayload and test that fastForwardEnabled and
  writeToLocalDcOnly reach the request.
- Make the fast forward round-trip test serialize the cluster confs, since
  create() keeps the input JSON as is.
…nd drop the stale TODO

Address review:
- create() with the JSON value null failed with the "Unable to parse" error
  before the constructor moved out of the try block; restore that error.
- Validating fastForwardEnabled sorted cluster ids with natural order, so a
  directly built map with a null cluster id failed with NullPointerException.
  Sort nulls first instead, leaving null cluster ids to the existing checks.
- Remove the TODO in buildCoordinatedRestoreJobPayload;
  BuildCoordinatedRestoreJobPayloadTest now covers writeToLocalDcOnly.
Comment on lines +203 to +216
/**
* Whether Sidecar should fast forward the restore job of the cluster, i.e. eagerly pipeline the staging and
* the importing phases instead of waiting for the phase signals. Staging starts while the restore job is
* still in CREATED status. Importing starts once the job reaches STAGED, which the driver sets only after
* all clusters have staged and satisfied the consistency level, instead of waiting for IMPORT_READY.
* <p>
* It must be set the same way on all clusters; {@link CoordinatedWriteConf} rejects mixed settings. Only
* enable it when it is acceptable that the imported data becomes visible immediately and that importing
* cannot be rolled back. It requires the Sidecars of the cluster to support fast forward (CASSSIDECAR-463);
* otherwise, the restore job creation is rejected.
*
* @return true if fast forward is enabled for the cluster; false otherwise. Defaults to false
*/
default boolean fastForwardEnabled()

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.

Reading through the comment, I think it make sense that "it must be set the same way on all cluster". In this case, we can promote this option to the top level, CoordinatedWriteConf and eliminate the validation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, done. I added a COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option and stored it on CoordinatedWriteConf as a top-level fastForwardEnabled(). BulkSparkConf applies it after buildCoordinatedWriteConf(), so subclasses pick it up too. The per-cluster field and the validation are removed.

…tion

Address review: fast forward must be the same for all clusters, so make it a
single option instead of a per-cluster field, and drop the validation.

- Add the COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option. It requires
  COORDINATED_WRITE_CONFIG and defaults to false.
- Store it on CoordinatedWriteConf as a top-level fastForwardEnabled(), not
  in the per-cluster JSON. BulkSparkConf applies it after
  buildCoordinatedWriteConf(), so subclasses that override that method pick
  it up too, on the driver and when executors rebuild the transient conf.
- Remove fastForwardEnabled from ClusterConf and SimpleClusterConf, and the
  mixed-setting validation.
- Document the option, including that STAGED becomes the point of no return.
@mansikhara mansikhara changed the title CASSANALYTICS-221: Add fastForwardEnabled to the coordinated write cluster config to enable Sidecar fast forward CASSANALYTICS-221: Add COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option to enable Sidecar fast forward for coordinated write Nov 20, 2026
…t forward against it

Address review:
- withFastForwardEnabled returns this when the setting is unchanged, and
  BulkSparkConf only applies it when fast forward is on, so the
  CoordinatedWriteConf returned by buildCoordinatedWriteConf is kept as is.
- Require a resolved CoordinatedWriteConf for fast forward, instead of the
  raw COORDINATED_WRITE_CONFIG option, so subclasses that build the conf
  differently can enable it.
- Document that when an older Sidecar rejects the restore job, the restore
  jobs already created on other clusters are left until they expire.
- Initialize CoordinatedWriteConf through a single constructor.

@sarankk sarankk 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.

+1 Thanks Mansi, lgtm

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.

3 participants