-
Notifications
You must be signed in to change notification settings - Fork 18
panic: concurrent write to websocket connection #56
Comments
Is a report of this from go-ipfs |
@vyzo could you look into this and ipfs/kubo#6197? They've stumped me in the past. We can always fix it with a lock (maybe we should just do that) but it would be nice to know why this is happening. |
@bonedaddy updating go-mplex, go-yamux, and github.com/multiformats/go-multistream may help. Basically, go-ws-transport doesn't support concurrent writes and we may be doing that somewhere else in libp2p. I'm suggesting upgrading because upgrading libp2p has stopped this bug from appearing on the our gateways. |
I'm on However one thing I'm unsured about is if |
Why not just wrap writer in an |
I didn't notice this bit, but that is a bit concerning. If something doesn't support concurrent writes it should be quite clearly explained. One CTRL+F on the home page of this repository doesn't show any hits for concurrent writes. The problem is most definitely some libp2p component that is attempting to perform concurrent writes. While it is doubtful a clear warning would prevent this, it would at least make it much less likely to happen 😞 |
Concurrent writes don't make sense with most (all?) |
|
I don't see how that follows. Writing to a single stream/connection from two goroutines at the same time will always yield garbage results as the writes can be arbitrarily interleaved and merged. Note: You can obviously still write to multiple streams on the same connection from multiple goroutines. The stream muxer takes care of muxing/demuxing. |
@Stebalien Concurrent writes to the same stream (or the connection, if you're not running a stream muxer) was what I meant. Did I misunderstand the issue here? |
@Stebalien I think we'd have to bite the bullet and use a lock. |
Reproduced with very few nodes ~ 200 :
Also it was dial out because I'm not listening on ws. |
No. I'm just clarifying.
Maybe but that doesn't actually fix the issue. Either:
Basically, there's a logic bug somewhere. |
@Jorropo or @bonedaddy are you using github.com/libp2p/go-conn-security-multistream v0.0.2? |
I would say that |
@Stebalien no I'm using |
@bonedaddy go-conn-security-multistream, not go-multistream. There was a bug in previous releases that could, maybe, have caused this. (of course, users are seeing this issue with go-ipfs 0.4.22 which has the latest go-conn-security-multistream so there must be more issues) |
It shouldn't. And even if it did, this error is at a higher layer. Re-using the same TCP conn shouldn't cause this error. |
@Stebalien, its just IPFS v0.4.22, also my arm node on v0.5.0 was never having that. |
Using |
Ah, got it. I hadn't pulled.
|
FYIW I'm experimenting with wrapping the I have made these changes to a fork already so I can port them upstream (here) if desired. |
@bonedaddy that seems an ugly hacks (even if I'm totaly okay with that if that works).
But you got me an idea, I'll for each write check if the lock is already taken it will log the stack for both goroutine (holder and taker). |
@Jorropo that's exactly what I was planning to do too! That should give us the contenting threads so that we can debug it. |
See #57 for instrumentation. Can you try this patch? |
Using the latest commit to the
master
this happens. I have also confirmed it present on the0.1.2
version.I previously opened this on the
go-multistream
repo multiformats/go-multistream#49. Failure is happening here. I suspect we need to protect the connection by a mutex?The text was updated successfully, but these errors were encountered: