Open Sharpe49 opened 4 years ago
I've just pushed a fix on master branch for this. Hoping this will help.
Alright, there is no crash, but when the server seems to freeze at a moment. The GUI is responding but not the server. Perhaps a mutex is not unlocked properly. I also tested it without the patch for the other issue. Same problem. We should probably do a test session together.
@npiganeau Ok, it is still not fixed. It went back to the same error of the first message.
@Sharpe49 Do you have the stack trace? I suppose it is a different map where we have a concurrent read/write.
I removed two other copied mutexes.
Can you test multiplayer-fix
branch ? (PR #52 )
Ok, we had a freeze with this version. It happened when a train entered the map. And some messages were received after the start of the freeze (a train entered the map).
@Sharpe49 I'm trying to reproduce with a unit test but I couldn't.
Do you have a way to reproduce the bug ? Or perhaps more information to help find the issue ?
We probably have to do tests together.
@Sharpe49 I finally managed to reproduce in unit tests. There were massive data races and locks. I rewrote almost all the concurrent logic to bring the simulation logic back on a single thread and removed almost all mutexes.
My tests do not race nor freeze anymore.
Can you test on your side too ?
Tell me also if you see bad side effects of this rewrite.
After pulling and compiling, we did a test with 2 players, we had a freeze during a route setting. Parts of the route were starting to become white on the screen when the server froze for us both.
Ok. We'll do tests together then. I send you an email.
@Sharpe49 Following our tests, I updated the multiplayer-fix
branch with non-blocking client notifications.
Can you test again and tell me if you still encounter simulation freeze ?
We did two long tests on Gretz and London Liverpool Street. It seems to work. We will try to do some other tests sessions to confirm that.
Log : INFO[01-19|19:36:26] Train 2C01 arrived on time at station LIVERPOOL STREET module=simulation msgType=2 INFO[01-19|19:36:52] Train 5U53 entered the area 2 minutes late module=simulation msgType=2 fatal error: concurrent map read and map write
goroutine 16 [running]: runtime.throw(0x888993, 0x21) C:/Go/src/runtime/panic.go:617 +0x79 fp=0xc00155f4c8 sp=0xc00155f498 pc=0x42ed89 runtime.mapaccess1_faststr(0x7f89c0, 0xc0000a2780, 0xc000238d3c, 0x3, 0x3) C:/Go/src/runtime/map_faststr.go:21 +0x470 fp=0xc00155f538 sp=0xc00155f4c8 pc=0x4126b0 github.com/ts2/ts2-sim-server/plugins/points.StandardManager.Direction(...) C:/Users/gniew/Desktop/ts2-sim-server/plugins/points/points.go:35 github.com/ts2/ts2-sim-server/plugins/points.(*StandardManager).Direction(0xc0000805c0, 0xc0003918c0, 0x3)