Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

bottomless: stream gzip snapshot #585

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

neubaner
Copy link
Contributor

@neubaner neubaner commented Aug 8, 2023

Stream gzip snaphosts using S3's multipart upload.

S3 requires Content-Length to be set when doing a PutObject operation and since we can't know the size of the gzip stream upfront, we send it in parts to S3 using a fixed-sized buffer that increases every 16 chunks up to 100 MiB, ensuring small allocations for small databases.

@neubaner neubaner force-pushed the gzip_stream_snapshot branch from 66203ad to 2cfbf01 Compare August 8, 2023 00:33
Copy link
Contributor

@psarna psarna left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for contributing, left a few nitpicks. I wonder if error handling for multipart uploads doesn't get handled by itself already -- e.g. when https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpu-abort-incomplete-mpu-lifecycle-config.html is configured. The temporary leftover file for storing the last part is also handled on failure, since it will get deleted eventually -- and if you switch to tempfile, it would probably even get deleted as part of its drop routine.

bottomless/src/replicator.rs Outdated Show resolved Hide resolved
bottomless/src/read.rs Outdated Show resolved Hide resolved
@neubaner
Copy link
Contributor Author

neubaner commented Aug 8, 2023

Nice work! Thanks for contributing, left a few nitpicks. I wonder if error handling for multipart uploads doesn't get handled by itself already -- e.g. when https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpu-abort-incomplete-mpu-lifecycle-config.html is configured. The temporary leftover file for storing the last part is also handled on failure, since it will get deleted eventually -- and if you switch to tempfile, it would probably even get deleted as part of its drop routine.

Yes, but you are still billed by how much you retain the incomplete parts. I also don't know if this can be done for other S3-compatible stores.

As a best-effort we can wrap the upload parts in a tokio::spawn and check if the JoinHandle returned JoinError for panics or the Result is Err.

@neubaner neubaner marked this pull request as ready for review August 9, 2023 23:05
@neubaner neubaner requested a review from psarna August 9, 2023 23:05
@neubaner
Copy link
Contributor Author

neubaner commented Aug 9, 2023

I decided to not abort the multipart upload on panics, that was harder than what I initially thought because tokio::spawn requires the Future to be 'static.

Only catching errors should be enough for now, and we can leave the panic case to the AbortIncompleteMultipartUpload lifecycle setting.

Copy link
Contributor

@Horusiath Horusiath left a comment

Choose a reason for hiding this comment

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

In general this PR should be married with #574 - one cover the issue of asynchronous snapshot upload between checkpoints (which is a must have in order to avoid latency spikes), another covers multipart upload.

bottomless/src/read.rs Show resolved Hide resolved
@neubaner neubaner force-pushed the gzip_stream_snapshot branch from 0df0ad1 to fedc6ac Compare August 24, 2023 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants