The International Simutrans Forum

 

Author Topic: Losses of synchronisation related to road vehicle movement  (Read 309 times)

0 Members and 1 Guest are viewing this topic.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 594
  • Languages: EN
Losses of synchronisation related to road vehicle movement
« 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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20648
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Losses of synchronisation related to road vehicle movement
« Reply #1 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.

Offline Matthew

  • *
  • Posts: 511
    • Japan Railway Journal
  • Languages: EN, some ZH, DE & SQ
Re: Losses of synchronisation related to road vehicle movement
« Reply #2 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!

Offline freddyhayward

  • Devotee
  • *
  • Posts: 594
  • Languages: EN
Re: Losses of synchronisation related to road vehicle movement
« Reply #3 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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20648
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Losses of synchronisation related to road vehicle movement
« Reply #4 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.