Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling for suspend/resume case for PeriodFromFirst #88

Merged
merged 1 commit into from
Jan 26, 2022

Conversation

mdedetrich
Copy link
Contributor

@mdedetrich mdedetrich commented Jan 21, 2022

About this change - What it does

This PR fixes the suspend/resume handling for the FirstFromPeriod case. As documented for the Backup configuration section in TimeConfiguration, when using FirstFromPeriod if you kill a backup and then resume it, it will create a new object regardless of what the current configured duration is as long as at least one chunk has been persisted into S3.

The current behavior of Guardian does not do this, the PR fixes this.

In addition the PR also renames some tests so its much more clear what is actually being tested

Why this way

The intention of this PR is to keep the interface for BackupClientInterface as simple as possible so that implementations of BackupClientInterface (i.e. S3's BackupClient) are trivial, simple and easy to understand even at a cost of internals of BackupClientInterface being more complicated.

Here is a brief documentation of the public changes to the BackupClientInterface

*backupToStorageTerminateSink: This newly added method is responsible for terminating an already existing backup which is needed for FirstFromPeriod to function as documented. The defined Sink is basically the same as backupToStorageSink however it doesn't have to deal with a Kafka context (since its not writing any Kafka messages) and it will always be resuming from a currently unfinished backup
*getCurrentUploadState: This method has been updated so that it returns the necessary information to implement this PR. It not only returns the state for the current key (if it exists) but it also returns the state for the last previous key before the current one (named previousKey) along with the key itself.

  • In general documentation of public functions in BackupClientInterface have been greatly improved.

Additional changes

  • CurrentState has been renamed to State to avoid confusion since we are dealing with both current previous states.
  • Tests have been renamed so its much more clear what is actually been tested.

TBD

@mdedetrich mdedetrich marked this pull request as draft January 21, 2022 12:38
@mdedetrich mdedetrich force-pushed the terminate-with-period-from-first branch from b92c57b to 25d94e5 Compare January 24, 2022 11:20

override def empty: () => Future[Done] = () => Future.successful(Done)

/** Override this method to define how to backup a `ByteString` to a `DataSource`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doc isn't doing anything useful since its already documented in BackupClientInterface and its also a test we are dealing with.

@mdedetrich mdedetrich force-pushed the terminate-with-period-from-first branch from 25d94e5 to e89782d Compare January 24, 2022 12:10
@@ -55,36 +56,61 @@ trait BackupClientInterface[T <: KafkaClientInterface] {
override val context: kafkaClientInterface.CursorContext
) extends ByteStringElement

case class PreviousState(state: State, previousKey: String)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These data structures have to be placed within BackupClientInterface because they reference State which is an abstract type member of the class itself

@mdedetrich mdedetrich marked this pull request as ready for review January 24, 2022 12:32
@mdedetrich mdedetrich requested review from jlprat and reta January 24, 2022 12:32
@mdedetrich mdedetrich force-pushed the terminate-with-period-from-first branch from e89782d to 53f82d3 Compare January 25, 2022 14:24
@mdedetrich mdedetrich force-pushed the terminate-with-period-from-first branch from 53f82d3 to 4514490 Compare January 25, 2022 14:38
@reta
Copy link
Contributor

reta commented Jan 25, 2022

@mdedetrich just curious what would happen if for some reason multiple instances of the backup happen to run concurrently (deployment error let say), could / do we detect that?

@mdedetrich
Copy link
Contributor Author

@reta Definitely, we should outright prevent this. There is an issue for this #82 but I forgot to mention there that we should also prevent concurrent runs of Guardian.

@mdedetrich
Copy link
Contributor Author

Thanks for the approval, I also just added a commit that moves kafkaConsumerSettingsOpt from core-cli to backup-cli because its a not a common option (consumer only exists for backup).

@mdedetrich mdedetrich merged commit 8b7812d into main Jan 26, 2022
@mdedetrich mdedetrich deleted the terminate-with-period-from-first branch January 26, 2022 06:07
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