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

sending SIGINT to ipfs repo verify incorrectly reports verify complete when daemon isn't running #4360

Closed
leerspace opened this issue Nov 1, 2017 · 7 comments · Fixed by #4453
Assignees
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@leerspace
Copy link
Contributor

Version information:

go-ipfs version: 0.4.12-rc1-
Repo version: 6
System version: amd64/windows
Golang version: go1.9

Type:

Bug

Severity:

Medium

Description:

Sending a SIGINT using CTRL+C to ipfs repo verify without the daemon running causes the command to report

verify complete, all blocks validated.

even though the command did not get a chance to complete. Before it reports this message, it appears to keep processing blocks for a few seconds until it finally stops.

When the daemon is running, canceling the ipfs repo verify command instead spits out an error. I'm not sure if this is desirable, but at least it doesn't report that the verify is complete.

21:09:37.028 ERROR commands/h: net/http: request canceled client.go:247
Error: net/http: request canceled

Perhaps the output in both cases (daemon running and stopped) should report something like

verify interrupted, not all blocks were validated
@kevina kevina self-assigned this Nov 1, 2017
@kevina kevina added the kind/bug A bug in existing code (including security flaws) label Nov 1, 2017
@kevina
Copy link
Contributor

kevina commented Nov 1, 2017

I look into it.

@kevina
Copy link
Contributor

kevina commented Nov 30, 2017

With master I am now getting:

$ ipfs repo verify
^C7 blocks processed.
18:07:57.774 ERROR       cmds: expected type <-chan interface {}, got <nil> legacy.go:408

@keks can you have a look at this, this is likely related to the command code

@keks
Copy link
Contributor

keks commented Dec 1, 2017

@kevina are you on the current master? #4437 might have fixed this and I now get

$ ./ipfs repo verify                                   
^C5 blocks processed.
Error: net/http: request canceled

@kevina
Copy link
Contributor

kevina commented Dec 1, 2017

@keks I just tried this on master, without the daemon running here is the result:

$ ipfs repo verify
^C6 blocks processed.
12:50:31.094 ERROR       cmds: expected type <-chan interface {}, got <nil> legacy.go:408
$ echo $?
0
$ ipfs repo verify
^C3 blocks processed.
$ echo $?
0

So not getting Error: net/http: request canceled and the exit code is still 0.

With the daemon running I get Error: net/http: request canceled and the exit code is 1

@keks
Copy link
Contributor

keks commented Dec 4, 2017

Phew, this one is tricky. I think the issue is that the program terminates too quickly to set the exit code after the cancel is received.

@keks
Copy link
Contributor

keks commented Dec 4, 2017

The error is thrown here and we can't pass it on from there on. Thinking through the options.

@Stebalien
Copy link
Member

Stebalien commented Dec 5, 2017

I'm (probably) seeing the same error (produced by the daemon) when manually calling the API with a bad path: (edit: not fixed by ipfs/go-ipfs-cmds#34, #4461)

> curl -i "http://localhost:5001/api/v0/object/get?arg=&encoding=protobuf"
20:37:12.107 ERROR  cmds/http: expected type <-chan interface {}, got <nil> responseemitter.go:124
20:37:12.107 ERROR  cmds/http: a panic has occurred in the commands handler! handler.go:125
20:37:12.107 ERROR  cmds/http: expected type <-chan interface {}, got <nil> handler.go:126
20:37:12.108 ERROR  cmds/http: stack trace:
goroutine 929199 [running]:
runtime/debug.Stack(0xc42000d520, 0xc42e61f890, 0x1)
        /usr/lib/go/src/runtime/debug/stack.go:24 +0xa7
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.internalHandler.ServeHTTP.func1()
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http/handler.go:127 +0x130
panic(0x12cd260, 0xc42e61f430)
        /usr/lib/go/src/runtime/panic.go:491 +0x283
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.(*responseEmitter).SetError(0xc4202a9880, 0x12cd260, 0xc420073960, 0x0)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http/responseemitter.go:147 +0x228
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds.(*fakeResponse).SetError(0xc423edadc0, 0x1cb3280, 0xc420073960, 0x0)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/legacy.go:191 +0xa6
github.com/ipfs/go-ipfs/core/commands/object.glob..func4(0x1cc95c0, 0xc42e61f0e0, 0x1cc8620, 0xc423edadc0)
        /home/steb/projects/go/src/github.com/ipfs/go-ipfs/core/commands/object/object.go:221 +0x517
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds.NewCommand.func1(0x1cc9500, 0xc421992480, 0x6723494dcd68, 0xc4202a9880)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/legacy.go:405 +0x18c
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds.(*Command).Call(0x1c98660, 0x1cc9500, 0xc421992480, 0x6723494dcd68, 0xc4202a9880, 0x0, 0x0)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/command.go:118 +0x1cb
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.internalHandler.ServeHTTP(0x0, 0xc42001804a, 0xd, 0xc42027ea80, 0xc4201cc240, 0x1573708, 0xc4201be700, 0xc420382fa0, 0x1c98660, 0xc42027e5a0, ...)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http/handler.go:193 +0x9c3
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.(*internalHandler).ServeHTTP(0xc4204f3b80, 0x1cbdb00, 0xc4204f8358, 0xc420356100)
        <autogenerated>:1 +0x72
gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors.(*Cors).Handler.func1(0x1cbdb00, 0xc4204f8358, 0xc420356100)
        /home/steb/projects/go/src/gx/ipfs/QmPG2kW5t27LuHgHnvhUwbHCNHAt2eUcb4gPHqofrESUdB/cors/cors.go:188 +0x108
net/http.HandlerFunc.ServeHTTP(0xc4202c4c00, 0x1cbdb00, 0xc4204f8358, 0xc420356100)
        /usr/lib/go/src/net/http/server.go:1918 +0x44
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.Handler.ServeHTTP(0x0, 0xc42001804a, 0xd, 0xc42027ea80, 0xc4201cc240, 0x1573708, 0x0, 0xc420382fa0, 0x1c98660, 0xc42027e5a0, ...)
        /home/steb/projects/go/src/gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http/handler.go:117 +0x5e
gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http.(*Handler).ServeHTTP(0xc420287ec0, 0x1cbdb00, 0xc4204f8358, 0xc420356100)
        <autogenerated>:1 +0x78
net/http.(*ServeMux).ServeHTTP(0xc420311800, 0x1cbdb00, 0xc4204f8358, 0xc420356100)
        /usr/lib/go/src/net/http/server.go:2254 +0x130
net/http.(Handler).ServeHTTP-fm(0x1cbdb00, 0xc4204f8358, 0xc420356100)
        /usr/lib/go/src/net/http/h2_bundle.go:5462 +0x4d
gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus.InstrumentHandlerFuncWithOpts.func1(0x1cbf080, 0xc42dc761c0, 0xc420356100)
        /home/steb/projects/go/src/gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus/http.go:287 +0x26f
net/http.HandlerFunc.ServeHTTP(0xc4204f32c0, 0x1cbf080, 0xc42dc761c0, 0xc420356100)
        /usr/lib/go/src/net/http/server.go:1918 +0x44
net/http.(*ServeMux).ServeHTTP(0xc4203117d0, 0x1cbf080, 0xc42dc761c0, 0xc420356100)
        /usr/lib/go/src/net/http/server.go:2254 +0x130
net/http.serverHandler.ServeHTTP(0xc4201b1520, 0x1cbf080, 0xc42dc761c0, 0xc420356100)
        /usr/lib/go/src/net/http/server.go:2619 +0xb4
net/http.(*conn).serve(0xc4285f6320, 0x1cbff00, 0xc4213c7740)
        /usr/lib/go/src/net/http/server.go:1801 +0x71d
created by net/http.(*Server).Serve
        /usr/lib/go/src/net/http/server.go:2720 +0x288
 handler.go:127

related to #2468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants