Repository navigation
fix(kvstoreentry): close directory upload files and rewind before retry - #1966
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
Close each file opened in ProcessDir and seek to the start before retrying insert after a connection-loss rewind error. Fixes fastly#1942 Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for the contribution! This pull request doesn't follow our pull request template:
Please edit the description to use the template. If it is still missing after 3 days, this pull request will be closed automatically. |
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.
Problem
kv-store-entry create --diropens each file withos.OpeninProcessDirand never closes it, which can exhaust file descriptors on large directories. On a retry afternet/http: cannot rewind body after connection loss, the same reader is reused after the first attempt already consumed the body, so the retry uploads empty or truncated content.Reproduction
See issue #1942: read from the captured request body after upload (still open, not
os.ErrClosed); simulate connection-loss error on first insert and observe empty body on retry.Root cause
Missing
Close()on opened files and no seek back to offset 0 before rebuilding the length reader for the retry path.Solution
defer f.Close()after each successfulos.Open, and on the rewind retry pathSeek(0)plus a freshFileLengthReaderbefore the secondinsertKey.Tests
Added
create_processdir_test.gowith:TestProcessDirClosesUploadedFilesTestProcessDirRetriesAfterConnectionLossWithRewoundBodyTestProcessDirRetryStillFailsReportsConnectionLossLocal
go testwas not run on this Windows host (gonot on agent PATH); prior PR #1965 demonstrated full CI coverage on this fork.Fixes #1942