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

Periodically reconcile the list of metadata files #2085

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class SingularityS3UploaderDriver extends WatchServiceHelper implements S
private final Map<S3UploadMetadata, CompletableFuture<Integer>> immediateUploadersFutures;

private ScheduledFuture<?> future;
private ScheduledFuture<?> fileSyncFuture;

@Inject
public SingularityS3UploaderDriver(SingularityRunnerBaseConfiguration baseConfiguration, SingularityS3UploaderConfiguration configuration, SingularityS3Configuration s3Configuration,
Expand Down Expand Up @@ -187,6 +188,17 @@ public void startAndWait() {
}
}, configuration.getCheckUploadsEverySeconds(), configuration.getCheckUploadsEverySeconds(), TimeUnit.SECONDS);

fileSyncFuture = scheduler.scheduleAtFixedRate(() -> {
runLock.lock();
try {
readInitialFiles();
Copy link
Contributor

Choose a reason for hiding this comment

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

checking - do you know how long this process usually takes, and is there a concern that it'll hold the lock long enough to cause issues for the S3 uploads?

Copy link
Member Author

Choose a reason for hiding this comment

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

This whole process is async/background, nothing hits it live or like a service, and it only holds the lock for a second or two

} catch (Throwable t) {
throw new RuntimeException(t);
} finally {
runLock.unlock();
}
}, configuration.getRecheckFilesEverySeconds(), configuration.getRecheckFilesEverySeconds(), TimeUnit.SECONDS);

try {
super.watch();
} catch (Throwable t) {
Expand All @@ -209,6 +221,10 @@ public void shutdown() {
runLock.unlock();
}

if (fileSyncFuture != null) {
fileSyncFuture.cancel(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

why allow interrupts here but not for the upload future?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good Q, I don't remember why I put that there... Will take a second look at it

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, this one is just checking for new files, interrupting in the middle won't actually interrupt an upload. The uploaders themselves we want to give a better chance to finish

}

if (future != null) {
future.cancel(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class SingularityS3UploaderConfiguration extends BaseRunnerConfiguration
@JsonProperty
private long checkUploadsEverySeconds = 600;

@Min(60)
@JsonProperty
private long recheckFilesEverySeconds = 600;

@Min(1)
@JsonProperty
private long stopCheckingAfterMillisWithoutNewFile = TimeUnit.HOURS.toMillis(168);
Expand Down Expand Up @@ -104,6 +108,14 @@ public void setCheckUploadsEverySeconds(long checkUploadsEverySeconds) {
this.checkUploadsEverySeconds = checkUploadsEverySeconds;
}

public long getRecheckFilesEverySeconds() {
return recheckFilesEverySeconds;
}

public void setRecheckFilesEverySeconds(long recheckFilesEverySeconds) {
this.recheckFilesEverySeconds = recheckFilesEverySeconds;
}

public long getStopCheckingAfterMillisWithoutNewFile() {
return stopCheckingAfterMillisWithoutNewFile;
}
Expand Down