Closed jmwample closed 1 year ago
Not sure if we definitely have 7M goroutines, or if go is just numerically incrementing go routine IDs? E.g. if you do something like
go func() { fmt.Println("A") }()
sleep(1)
go func() { fmt.Println("B") }()
does B get printed from goroutine 1 or goroutine 2?
In any case, this seems like a good idea to forward FINs like this. One thing to be careful of is double closing (e.g. two halfPipes for (src, dst) and (dst, src) don't each need to close both connections in their defers, but it looks like you handle this by just closing dst in the defer for halfPipe
One thing to be careful of is double closing (e.g. two halfPipes for (src, dst) and (dst, src) don't each need to close both connections in their defers, but it looks like you handle this by just closing dst in the defer for halfPipe
I actually try to close both on both sides. We could add a channel that indicated to the other conn to close the dst, but I think that in golang the worst that happens with a double close is a return net.ErrClosed
error.
does B get printed from goroutine 1 or goroutine 2?
I don't know the answer to this. It is possible that they increment globally over time and that in total we had used 7M, but that doesn't mean that there were 7M live at one time. I am not sure how to get goroutine IDs. I did add a count of the current number of goroutines in use by the application to the stats logging, so we can watch over time.
does B get printed from goroutine 1 or goroutine 2?
Seems they are globally incrementing within the process according to this SO thread. So it would probably be 2 (or more since go probably uses some under the hood).
The ultimate issue seems to have been a race condition in connection handling which then caused thread starvation elsewhere. Fixes to the proxy halfPipe
s are probably still a good thing.
One of the main stations crashed overnight seeminlgly due to thread starvation in the
proxy.halfPipe()
function. In the crash logs in syslog it says:oroutine 6_933_001 [semacquire, 4 minutes]:
which makes me things that there may have been ~7 million goroutines running.test solutions
proxy.halfpipe()