Skip to content
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

Merged
merged 18 commits into from
Apr 8, 2020
Merged

Dag export command, complete #7036

merged 18 commits into from
Apr 8, 2020

Conversation

ribasushi
Copy link
Contributor

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

@ribasushi ribasushi mentioned this pull request Mar 26, 2020
core/commands/dag/dag.go Outdated Show resolved Hide resolved
core/commands/dag/dag.go Outdated Show resolved Hide resolved
core/commands/dag/dag.go Outdated Show resolved Hide resolved
}()

if err := res.Emit(pipeR); err != nil {
pipeW.Close() // ignore errors if any
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

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).

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Member

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:

  1. Copying from the pipe to the http writer fails because the http connection dies.
  2. Emit returns an error.
  3. 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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

core/commands/dag/dag.go Show resolved Hide resolved
core/commands/dag/dag.go Outdated Show resolved Hide resolved
@ribasushi
Copy link
Contributor Author

Ready for final re-review ( every comment addressed, sharness fixed )

core/commands/dag/dag.go Outdated Show resolved Hide resolved
core/commands/dag/dag.go Outdated Show resolved Hide resolved
@Stebalien
Copy link
Member

I missed a few things and I'd like to avoid making any assumptions about when the fixes to go-ipld-prime will ship.

@ribasushi
Copy link
Contributor Author

no worries, I am going down the list already, fixes to be pushed in ~15

Copy link
Member

@Stebalien Stebalien left a 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.

@ribasushi ribasushi changed the title Dag export command, silent, no progress Dag export command, complete Mar 28, 2020
core/commands/dag/dag.go Outdated Show resolved Hide resolved
core/commands/dag/dag.go Outdated Show resolved Hide resolved
@ribasushi
Copy link
Contributor Author

@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

@ribasushi
Copy link
Contributor Author

And of course it fails tests, seemingly unrelated:

=== FAIL: core/coreapi/test TestIface/Dht (1.37s)
2020-03-28T05:50:04.000Z	ERROR	core	core/builder.go:47	failure on stop: context canceled
github.com/ipfs/go-ipfs/core.NewNode.func2
	/home/circleci/ipfs/go-ipfs/core/builder.go:47
    --- FAIL: TestIface/Dht (1.37s)

@Stebalien
Copy link
Member

That's a known flaky test, unfortunately.

core/commands/root.go Outdated Show resolved Hide resolved
@ribasushi
Copy link
Contributor Author

@Stebalien latest push on this branch merges master one last time, addresses #7036 (comment), and removes urfave/cli.

@Stebalien
Copy link
Member

Rebased to remove merge commits.

@Stebalien Stebalien merged commit 92140ec into master Apr 8, 2020
@rvagg rvagg deleted the feat/carfile-export-only branch June 30, 2020 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants