-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Dag export command, complete #7036
Conversation
core/commands/dag/dag.go
Outdated
}() | ||
|
||
if err := res.Emit(pipeR); err != nil { | ||
pipeW.Close() // ignore errors if any |
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.
We shouldn't need to call this.
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.
done
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.
Ah, wait, actually... we need to call pipeR.Close()
to unblock the writer, I think (it can't hurt to call it anyways).
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 modeled original code on the example at https://golang.org/pkg/io/#Pipe is showing a writer close only, and no reader closures. That's also consistent with "posix-ish thinking". Are you sure you want to move to pipeR.Close()
instead?
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 just did it anyway, even though it doesn't seem right... Closing a reader will just block a writer, though these are virtual writers so shouldn't matter.
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.
Closing the reader will unblock the writer: https://golang.org/pkg/io/#PipeReader.Close. I'm concerned about the following:
- Copying from the pipe to the http writer fails because the http connection dies.
- Emit returns an error.
- We walk away but the CAR writer is still trying to write to the pipe.
Closing the writer will unblock the CAR writer and cause it to abort with an error.
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.
Oh... ok... that makes sense... BUT
Then the code can be made much safer like:
diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go
index 6835d0945..ec4e88c94 100644
--- a/core/commands/dag/dag.go
+++ b/core/commands/dag/dag.go
@@ -295,6 +295,7 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
// if err := car.Write(pipeW); err != nil {}
pipeR, pipeW := io.Pipe()
+ defer pipeR.Close() // ignore the error if any, ublock the writer goroutine to exit
errCh := make(chan error, 2) // we only report the 1st error
go func() {
@@ -319,7 +320,6 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
}()
if err := res.Emit(pipeR); err != nil {
- pipeR.Close() // ignore the error if any
return err
}
Not pushing it now not to muddle things up, but if you agree with add it to the import rebase
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.
You're right. That's much better.
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.
Everything is terrible. THIS is the correct way to close the pipe: 70834450926f53902
This is the only extra commit I added since your LGTM, the rest is just merging master. Not planning to push more commits here unless the above closer needs fixing.
Ready for final re-review ( every comment addressed, sharness fixed ) |
I missed a few things and I'd like to avoid making any assumptions about when the fixes to go-ipld-prime will ship. |
no worries, I am going down the list already, fixes to be pushed in ~15 |
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.
Provisional LGTM pending tests.
7083445
to
ccbd08b
Compare
@Stebalien this currently is exactly at where you said "LGTM" + the concurrency-free progressbar. If this passes sharness - it should be good to merge as-is. I am working on the import part based off ccbd08b16f96 |
And of course it fails tests, seemingly unrelated:
|
That's a known flaky test, unfortunately. |
ccbd08b
to
8e8ca84
Compare
@Stebalien latest push on this branch merges master one last time, addresses #7036 (comment), and removes urfave/cli. |
This still works over "loosely defined" .car files Please refer to the sharness tests for extra info We can tighten this up if the sentiment is "Postel was wrong"
2d1d6cd
to
a903e23
Compare
Rebased to remove merge commits. |
This is the most non-controversial part of all. The commented-out go-ipld-prime hickup is being debugged by @warpfork and me over at https://github.com/ribasushi/gip-muddle-up