-
Notifications
You must be signed in to change notification settings - Fork 498
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
Replace 'tar' crate with 'tokio-tar' #3202
Conversation
'async-tar' is a fork of the 'tar' crate, just replacing sync functions with corresponding async ones. I'm not sure how well maintained it is, but a crate like this doesn't really need much change or maintenance. If we go with this, it might be good to take a close look at 'async-tar' and compare if it's missing any fixes that have been made on 'tar' crate. I'm surprised by how many dependencies the 'async-tar' crate pulls in. It depends on 'async-std'; is that really necessary, or could we update 'async-tar' to rely on the corresponding std functionality instead? |
Let's not pull that in then, it's yet another async runtime and we have |
I see.
Tried that now. There's one problem with it:
tokio_tar::Builder requires the writer to be That's hacky IMHO. The EOF-block-writing-task executes at some not-well defined time after the drop has happened. And it's super annoying for us, because we actually don't want the EOF marker to be written at all. We actually work hard to skip it, that's exactly why we have the AbortableWrite hack. So ideally tokio-tar just didn't have that Drop implementation, and then it wouldn't require |
Switched to a modified version of 'tokio-tar' without the Drop implementation and the 'static requirement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vorot93/tokio-tar@master...hlinnaka:tokio-tar:no-termination-on-drop
As a tokio-tar
maintainer, I would not want to accept a PR that could break its users' workflow just by the version bump, silently.
I would imagine, more PR-friendly way would be to define some extra field in the Builder
, that allows disabling archive termination and use that in Drop
.
Otherwise, I like how straightforward most of this PR is, including the old sync code transition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find anything wrong in this aside from @SomeoneToIgnore's comments. Happy to have clearer stack traces with one more block_in_place gone :)
Looking more, vorot93/tokio-tar#9 does look quite important in case the work not completing on one poll, however that's only on the read path which we don't use. Looking at |
0a716ed
to
911421c
Compare
The synchronous 'tar' crate has required us to use block_in_place and SyncIoBridge to work together with the async I/O in the client connection. Switch to 'tokio-tar' crate that uses async I/O natively. As part of this, move the CopyDataWriter implementation to postgres_backend_async.rs. Even though it's only used in one place currently, it's in principle generally applicable whenever you want to use COPY out. Unfortunately we cannot use the 'tokio-tar' as it is: the Builder implementation requires the writer to have 'static lifetime. So we have to use a modified version without that requirement. It was required just for the Drop implementation that writes the end-of-archive sections if the Builder is dropped without calling `finish`. But we don't actually want that behavior anyway; in fact we had to jump through some hoops with the AbortableWrite hack to skip those. With the modified version of 'tokio-tar' without that Drop implementation, we don't need AbortableWrite either, but I kept that for now.
We don't use that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I trust the transformations from sync to async were mostly mechanical / done carefully. Didn't review those.
The tokio-tar
PR has been merged into our fork. Hence it's OK to use it in this PR now.
I scanned for FIXMEs and started conversations. Please address them, then let's get this merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash before merge
The synchronous 'tar' crate has required us to use block_in_place and SyncIoBridge to work together with the async I/O in the client connection. Switch to 'async-tar' crate that uses async I/O natively.
As part of this, move the CopyDataWriter implementation to postgres_backend_async.rs. Even though it's only used in one place currently, it's in principle generally applicable whenever you want to use COPY out.