Describe the bug
I am running a go-filecoin test-devnet-0.2.2 version as a miner; and set up another miner as client to send proposals in parallel.
After a few hours, I got crash on miner side.
To Reproduce
Steps to reproduce the behavior:
[0;37m18:29:59.359 [33mWARNI [0;34m/fil/hello: [0mfailed to send hello handshake to peer QmbNJ2Hzf7qJ32cPzAkRzqsjzBAR52RwhB6feWcT2xE1pX: stream reset [0;37mhello.go:179[0m
[0;37m18:29:59.657 [33mWARNI [0;34mnet/identi: [0merror reading identify message: stream reset [0;37mid.go:146[0m
panic: send on closed channel
goroutine 35945557 [running]:
github.com/filecoin-project/go-filecoin/proofs/sectorbuilder.(*RustSectorBuilder).AddPiece.func2(0xc0b5e52fc0, 0x22, 0xc03780e760, 0xc0098b3900, 0x1f, 0xc024b3df80, 0xc000be42a0)
/root/go/src/github.com/filecoin-project/go-filecoin/proofs/sectorbuilder/rustsectorbuilder.go:230 +0x377
created by github.com/filecoin-project/go-filecoin/proofs/sectorbuilder.(*RustSectorBuilder).AddPiece
/root/go/src/github.com/filecoin-project/go-filecoin/proofs/sectorbuilder/rustsectorbuilder.go:208 +0x27c
Expected behavior
no crash
Reject the proposal if too many to handle.
Or report an error, instead of crashing.
Version information
go-filecoin test-devnet-0.2.2
I also ran into this, though I was only working with a single deal at a time.
Thanks for the logs, @steven004. I see the following, which is interesting:
context completed before CGO call could return (sinkPath=/tmp/916184228.fifo) rustsectorbuilder.go:237
failed to add piece: context completed before CGO call could return miner.go:429
What's happening is:
RustSectorBuilder#AddPiece is called with a contextMaxTimeToWriteBytesToSink to this contextadd_piece callerrCh, sectorIDCh, and the ctx.Done() chanctx.Done() and returnssectorIDCh and errChadd_piece call returns (in the goroutine) and attemps to send a value to a now-closed sectorIDChThe fix:
sectorIDCh and errCherrCh and should close that channel when doneI do not know why the context which is passed to RustSectorBuilder#AddPiece is being marked as done.
I was able to consistently repro this bug locally.
If the node receives deal proposals for pieces which completely fill up a staged sector while the node is sealing (and its CPUs are all pegged), RustSectorBuilder#AddPiece takes longer and longer (peaking on my machine at ~20s) until we bust the 30s timeout. Once we hit the timeout, we eject from RustSectorBuilder#AddPiece, which closes the channels that the goroutines try to send to. Thus the panic.
I propose a two-headed solution:
So this is induced by load, and spreading deal proposals out is a workaround for users who are self proposing deals?
So this is induced by load, and spreading deal proposals out is a workaround for users who are self proposing deals?
Yes, that is correct.
Most helpful comment
Thanks for the logs, @steven004. I see the following, which is interesting:
What's happening is:
RustSectorBuilder#AddPieceis called with a contextMaxTimeToWriteBytesToSinkto this contextadd_piececallerrCh,sectorIDCh, and thectx.Done()chanctx.Done()and returnssectorIDChanderrChadd_piececall returns (in the goroutine) and attemps to send a value to a now-closedsectorIDChThe fix:
sectorIDChanderrCherrChand should close that channel when doneI do not know why the context which is passed to
RustSectorBuilder#AddPieceis being marked as done.