Upload segment to remote store post refresh#3403
Merged
Bukhtawar merged 2 commits intoopensearch-project:feature/durability-enhancementsfrom May 22, 2022
Merged
Conversation
Signed-off-by: Sachin Kale <kalsac@amazon.com>
Bukhtawar
reviewed
May 19, 2022
| import java.nio.file.NoSuchFileException; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.*; |
Comment on lines
+55
to
+82
| if (didRefresh) { | ||
| Set<String> localFiles = Arrays.stream(storeDirectory.listAll()).collect(Collectors.toSet()); | ||
| localFiles.stream().filter(file -> !filesUploadedToRemoteStore.contains(file)).forEach(file -> { | ||
| try { | ||
| remoteDirectory.copyFrom(storeDirectory, file, file, IOContext.DEFAULT); | ||
| filesUploadedToRemoteStore.add(file); | ||
| } catch (NoSuchFileException e) { | ||
| logger.info("The file {} does not exist anymore. It can happen in case of temp files", file); | ||
| } catch (IOException e) { | ||
| // ToDO: Handle transient and permanent un-availability of the remote store (GitHub #3397) | ||
| logger.warn("Exception while uploading file {} to the remote segment store", file); | ||
| } | ||
| }); | ||
|
|
||
| Set<String> remoteFilesToBeDeleted = new HashSet<>(); | ||
| // ToDo: Instead of deleting files in sync, mark them and delete in async/periodic flow (GitHub #3142) | ||
| filesUploadedToRemoteStore.stream().filter(file -> !localFiles.contains(file)).forEach(file -> { | ||
| try { | ||
| remoteDirectory.deleteFile(file); | ||
| remoteFilesToBeDeleted.add(file); | ||
| } catch (IOException e) { | ||
| // ToDO: Handle transient and permanent un-availability of the remote store (GitHub #3397) | ||
| logger.warn("Exception while deleting file {} from the remote segment store", file); | ||
| } | ||
| }); | ||
|
|
||
| remoteFilesToBeDeleted.forEach(filesUploadedToRemoteStore::remove); | ||
| } |
Contributor
There was a problem hiding this comment.
- Do we need to ensure this happens within a lock
- let log exception as well
- Can we do batch deletions outside of upload flow without blocking subsequent uploads?
Member
Author
There was a problem hiding this comment.
Do we need to ensure this happens within a lock
ReferenceManager.doMaybeRefresh() acquires lock before notifying refresh listeners
let log exception as well
Will add exception. Most probably it will change based on the exception handling.
Can we do batch deletions outside of upload flow without blocking subsequent uploads?
Yes, that is the plan. Added as ToDo before the delete block. #3142
c51f5c2 to
a9d9da7
Compare
Signed-off-by: Sachin Kale <kalsac@amazon.com>
a9d9da7 to
deb3975
Compare
Collaborator
|
❌ Gradle Check failure a9d9da761e0f7932af72fe27d98c4cc7be55e65e |
Bukhtawar
reviewed
May 21, 2022
| remoteDirectory.copyFrom(storeDirectory, file, file, IOContext.DEFAULT); | ||
| filesUploadedToRemoteStore.add(file); | ||
| } catch (NoSuchFileException e) { | ||
| logger.info( |
Contributor
There was a problem hiding this comment.
Could a possible segment merge with a concurrency bug manifest in files to be removed?
Bukhtawar
approved these changes
May 22, 2022
b1c36fa
into
opensearch-project:feature/durability-enhancements
5 tasks
sachinpkale
added a commit
to sachinpkale/OpenSearch
that referenced
this pull request
May 27, 2022
Signed-off-by: Sachin Kale <kalsac@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Sachin Kale kalsac@amazon.com
Description
afterRefreshmethod ofRemoteStoreRefreshListener.Issues Resolved
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.