The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: freddyhayward on December 02, 2020, 10:21:06 AM

Title: Losses of synchronisation related to road vehicle movement
Post by: freddyhayward on December 02, 2020, 10:21:06 AM
I have solved one common desync that was caused by road vehicle movement: https://github.com/jamespetts/simutrans-extended/pull/308
In summary, it was caused because road vehicles determine whether to continue driving when another vehicle is ahead based partially on the routing status of that convoy. However, routing status is thread-unsafe whenever routes are being calculated, typically when convoys are about to depart. I resolved that particular case by checking whether the convoy ahead is actually moving at all.
I speculate that there are many other potential causes of desynchronisation in other sections of movement code that rely on routing information, as this can change in a thread-unsafe manner.
Title: Re: Losses of synchronisation related to road vehicle movement
Post by: jamespetts on December 02, 2020, 06:00:54 PM
Thank you for your work on this: this is very helpful. I know that these can be fantastically difficult to track down, so you must have put a great deal of effort into this. I have now incorporated this.

I was not aware that can_enter_tile() is called whilst a vehicle is in the ROUTING state; to find other instances of this sort of issue, we may want to consider running a test checking for the ROUTING state in this and similar methods and how this is reached. This may well be an issue for other types of vehicle besides road vehicles.
Title: Re: Losses of synchronisation related to road vehicle movement
Post by: Matthew on December 03, 2020, 08:26:45 AM
Thank you Freddy for finding and fixing the problem and James for integrating the patch.

Discovering a whole new class of desync causes seems like a major breakthrough!
Title: Re: Losses of synchronisation related to road vehicle movement
Post by: freddyhayward on December 03, 2020, 08:35:38 AM
Thank you Freddy for finding and fixing the problem and James for integrating the patch.

Discovering a whole new class of desync causes seems like a major breakthrough!
You certainly deserve some credit for reporting desyncs as they happened - this helped me to construct the test map that reproduced it.
Title: Re: Losses of synchronisation related to road vehicle movement
Post by: jamespetts on December 12, 2020, 05:10:30 PM
I have added assertion checks for the state of a convoy being in the ROUTING_1 or ROUTING_2 status when calling can_enter_tile(), and have found no instances where this is the case running a recent saved game from the Stevenson-Seimens server.