Repository navigation
CASSANALYTICS-221: Add COORDINATED_WRITE_FAST_FORWARD_ENABLED writer option to enable Sidecar fast forward for coordinated write - #262
Conversation
…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"; |
There was a problem hiding this comment.
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.
…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.
| /** | ||
| * 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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.
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_ENABLEDwriter option. When it's set, the driver sendsfastForwardEnabled=truewhen creating the restore job on every cluster inCOORDINATED_WRITE_CONFIG.COORDINATED_WRITE_CONFIGis present.CoordinatedWriteConfas a top-levelfastForwardEnabled(), not in the per-cluster JSON, sotoJson()and existing configs are unchanged.BulkSparkConfapplies it afterbuildCoordinatedWriteConf(), so subclasses that override that method pick it up too, both on the driver and when executors rebuild the transient conf.fastForwardEnabledinto the Analytics copy ofCreateRestoreJobRequestPayload, 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.CassandraBulkSourceRelation.buildCoordinatedRestoreJobPayloadso it can be unit tested.docs/src/user.adocdocument this, along with the S3 replication and older Sidecar behavior.Testing:
BulkSparkConfTest: the option is rejected withoutCOORDINATED_WRITE_CONFIG, defaults to false, and survives a serialization round-trip (executor path).CoordinatedWriteConfTest: defaults to false;withFastForwardEnabledreturns a copy and leaves the per-cluster JSON unchanged.BuildCoordinatedRestoreJobPayloadTest: the per-cluster create restore job request carriesfastForwardEnabledandwriteToLocalDcOnly.CreateRestoreJobRequestPayloadTest: default omitted from JSON, round-trip, rejected without a consistency level.