-
Notifications
You must be signed in to change notification settings - Fork 48
[support bundle] Ensure that the transfer buffers are flushed #8708
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
@@ -592,11 +592,12 @@ impl BundleCollection { | |||
})?; | |||
|
|||
// Only stream at most "transfer_chunk_size" bytes at once | |||
let remaining = std::cmp::min( | |||
let chunk_size = std::cmp::min( |
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.
This is just for clarify; it's not the bug fix
})?; | ||
|
||
offset += self.transfer_chunk_size.get(); | ||
offset += chunk_size; |
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.
This technically wasn't "wrong" before, because we didn't use the offset after the very last call, but over-shooting the actual length of the support bundle still felt fishy, so I changed this.
(The resulting behavior should be identical)
// It is possible, although uncommon, for us to write to this file, | ||
// drop the handle to it, and for it to have not been fully written to | ||
// storage. | ||
tmp_file.flush().await?; |
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.
This is the real fix of this issue
tmp_file | ||
.seek(tokio::io::SeekFrom::Current(i64::try_from(offset)?)) | ||
.await?; | ||
tmp_file.seek(tokio::io::SeekFrom::Start(offset)).await?; |
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.
Again, this isn't wrong, because we just opened the file, so it should be equivalent. However, IMO this version is less sketchy.
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.
Thanks, @smklein, great job running this down. There was one change you made that I don't quite understand, but otherwise this looks good.
@@ -743,7 +758,7 @@ impl<'a> SupportBundleManager<'a> { | |||
info!(log, "Bundle written successfully"); | |||
let metadata = SupportBundleMetadata { | |||
support_bundle_id, | |||
state: SupportBundleState::Complete, | |||
state: SupportBundleState::Incomplete, |
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 you explain this change?
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.
TL;DR this is basically an informational change that results in no behavioral changes, but it was a code smell.
- Before we chunked support bundles, the status would return "has the bundle been created, and is it ready for usage"
- We used "Complete" to indicate "you're good to use the bundle" and "incomplete" to mean "the bundle has not been fully written to durable storage yet"
- When we switched to chunking behavior, this protocol changes a little bit. Nexus used the new "transfer + finalize" APIs, and would never infer that the bundle was ready from a call to "Transfer" alone
- However, we didn't change that returned state from transfer. Even though bundles are never ready-to-use before finalize, we returned "Complete"
- ... but this didn't matter, because Nexus was ignoring the returned state anyway.
So: It's more accurate to say "The bundle has not been finalized" during this transfer. Arguably we could remove this state from the internal transfer API altogether. But "Incomplete" is more accurate than "Complete"
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.
Thanks, makes sense.
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.
Nothing further from me, thanks!
@@ -743,7 +758,7 @@ impl<'a> SupportBundleManager<'a> { | |||
info!(log, "Bundle written successfully"); | |||
let metadata = SupportBundleMetadata { | |||
support_bundle_id, | |||
state: SupportBundleState::Complete, | |||
state: SupportBundleState::Incomplete, |
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.
Thanks, makes sense.
Fixes #8681