-
Notifications
You must be signed in to change notification settings - Fork 25.5k
SNAPSHOT+TESTS: Rem. Mock Atomic Writes Randomness #37011
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
Conversation
* Randomly doing non-atomic writes causes rare 0 byte reads from `index-N` files in tests * Removing this randomness fixes these random failures and is valid because it does not reproduce a real-world failure-mode: * Cloud based Blob stores (S3, GCS and Azure) do not have inconsistent partial reads of a blob, either you read a complete blob or nothing on them * For file system based blob stores the atomic move we do (to atomically write a file) by setting `java.nio.file.StandardCopyOption#ATOMIC_MOVE` would throw if the file system does not provide for atomic moves * Closes elastic#37005
Pinging @elastic/es-distributed |
yes, it's not an issue for the repository plugins that we provide, but the |
Should we fix the production code in 6.x then to fix these tests? We could simply break out of the read logic for repository data here https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java#L670 and return empty data if we read an empty blob (i.e. treat an empty blob like a missing file)? |
@ywelsch as a matter of fact, I think => Fix hdfs repository, adjust docs and just target 7.0 here? |
The problem with moving HDFS to the "write temp file -> atomic rename" pattern is that it will make writing to an HDFS repository slower (more metadata requests, which are executed sequentially on the namenode). My prior experience with HDFS showed that these operations can possibly take upward of a few 100 milliseconds to complete. This might be an ok tradeoff though if we can simplify the spec in ES 7. We still have to decide what to do for 6.x. Is there an alternative to removing the |
I suggested one above #37011 (comment) (simply break out of the read on empty blob and treat them like missing blobs). WDYT? ... that may also be an alternative for |
what if the file is not empty, but partially written?
Let's do this for both 7.0 and 6.x |
I don't think this will happen with the file system store because the content of that file is small enough to be less than a sector and just sync atomically right? => Is there really a practical situation where we want to support blob repositories that need multi-part writes for this little data? |
I wouldn't want to make any strong assumptions about the size of the files that are to be written with |
I guess it's not only changing docs here right? Basically we'd change the interface to require implementation of |
yes, we can restrict that change to 7.0 though. |
* Implement atomic writes the same way we do for the FsBlobContainer via rename which is atomic * Relates elastic#37011
* Implement atomic writes the same way we do for the FsBlobContainer via rename which is atomic * Relates #37011
* Implement atomic writes the same way we do for the FsBlobContainer via rename which is atomic * Relates #37011
@ywelsch with HDFS now fixed we could change the interface to not do the default fallback to non-atomic write for But do we even want to do anything else in this PR (since it needs to fix master and 6.x)? The docs there simply state:
This is factually correct and we don't want to change this for |
* With elastic#37066 introducing atomic writes to HDFS repository we can enforce atomic write capabilities on this interface * The overrides on the other three cloud implementations are ok because: * https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html states that "Amazon S3 never adds partial objects; if you receive a success response, Amazon S3 added the entire object to the bucket." * https://cloud.google.com/storage/docs/consistency states that GCS has strong read-after-write consistency * https://docs.microsoft.com/en-us/rest/api/storageservices/put-block#remarks Azure has the concept of committing blobs, so there's no partial content here either * Relates elastic#37011
* With #37066 introducing atomic writes to HDFS repository we can enforce atomic write capabilities on this interface * The overrides on the other three cloud implementations are ok because: * https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUT.html states that "Amazon S3 never adds partial objects; if you receive a success response, Amazon S3 added the entire object to the bucket." * https://cloud.google.com/storage/docs/consistency states that GCS has strong read-after-write consistency * https://docs.microsoft.com/en-us/rest/api/storageservices/put-block#remarks Azure has the concept of committing blobs, so there's no partial content here either * Relates #37011
@ywelsch thanks, will merge once green. The new commit I just pushed is just re-enabling the test fixed here. |
* Randomly doing non-atomic writes causes rare 0 byte reads from `index-N` files in tests * Removing this randomness fixes these random failures and is valid because it does not reproduce a real-world failure-mode: * Cloud-based Blob stores (S3, GCS, and Azure) do not have inconsistent partial reads of a blob, either you read a complete blob or nothing on them * For file system based blob stores the atomic move we do (to atomically write a file) by setting `java.nio.file.StandardCopyOption#ATOMIC_MOVE` would throw if the file system does not provide for atomic moves * Closes #37005
index-N
files in tests (SharedClusterSnapshotRestoreIT#testSnapshotCanceledOnRemovedShard failing on Master #37005 (comment))java.nio.file.StandardCopyOption#ATOMIC_MOVE
would throw if the file system does not provide for atomic moves