[Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

This subforum contains all the issues which we already resolved.
User avatar
Sephrat
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Wed Mar 16, 2016 2:39 pm
Contact:

[Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Sephrat »

A train passed through a chain signal and suddenly stopped some chain signals later. It shouldn't have entered this section if the path wasn't free.
train stops.gif
train stops.gif (2.76 MiB) Viewed 13222 times
Additionally, the train doesn't reroute even though it has alternative available paths. If I switch the automatic mode off/on, it changes its path and goes through an alternative (available) route.

Here is my save just a couple of seconds before the train arrives (vanilla): https://www.dropbox.com/s/mwx0udn108k09 ... g.zip?dl=0

You can find a detailed explanation of my setup and what I'm trying to achieve here. As I've explained, I have a lot of trouble with the pathing algorithm on this setup. I don't believe it is directly linked to this bug but this setup has unexplained patterns regarding train pathing.
TL;DR: one entrance with a chain signal, multiple routes (waiting bays) splitting and merging progressively, leading to a station, all of them being of equal length but with entrances closer/farther from the station. Intermediate chain signals are there to make sections smaller so that multiple trains can enter the waiting bays at a time.

What seems to happen is that the train entered the chain signals section, planning to go through an available waiting bay. For some reason when passing one of the chain signals, it rerouted twice (!!) through another waiting bay, but the second rerouting lead to a used waiting bay* (next regular signal is red). Therefore the chain signal suddenly switches from yellow to red, and stucks my train in the middle of chain signals.


*Why it did that in the first place, I really wonder: I don't understand (broke? :D ) the pathing algorithm on my setup... However it seems somehow correlated to the trains positions on the merging part of the waiting bays: I noticed it in the other topic, and when this bug occurs a train is moving in the merging part, probably causing the multiple reroutings. I would love you guys if you gave an explanation of what really happens here. :D I would really love this kind of setup to work, which doesn't seem possible so far.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Rseding91 »

I'm pretty sure I have a fix for this. I mean.. it fixes this scenario and the one linked I just don't know fully what the ramifications of my fix might be. At this stage in 0.15 stabilization I think it's too risky. I'll put it in 0.16.

I understand now what's causing the train to do what it's doing and why it's doing it - it was simply flawed in the case of large chain signal blocks with multiple exits.

This is the scenario:
  • 1. A train is driving on a path towards some point.
    2. The path crosses a set of chain signals which is perfectly valid for the train to cross
    3. While the train is driving over the chain signals it detects that at it's current speed accounting for its braking force the total rail distance in front of itself + 1 contains a rail signal that it can't reserve
    4. In this state the train tries to see if there's a better path that might be able to go around the blocked chain signal instead of just "stop at signal and wait"
    5. If a new path is found that doesn't block the train then it keeps driving as if nothing happened
    6. If there's no new path or the new path is also blocked by a signal the train slows to arrive at the blocked signal
In the above steps the logic broke at step 4: if the train is in the middle of a chain signal block and it finds a *new* path through the same signal block that doesn't currently have an exit it will have to stop at the next chain signal on the rail its sitting on thus the train sits in the middle of a set of chain signals defeating the entire purpose of the chain signal - never enter when you can't exit.
If you want to get ahold of me I'm almost always on Discord.
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Bilka »

Do I understand this right? The last chain signal of the 3 chain signals turns blue (because a rail signal at that end of the chained blocks becomes red?) while the train is inside of the chained blocks. Because the chain signal is blue and the route the trains wants to go to is blocked (aka the rail signal at that end of the chain signal block is red), the train has to stop at the chain signal.

If my above paragraph is right, how would you fix that? There will always be long enough chained blocks so that a rail signal in a trains path can turn red while it's inside the chained blocks.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Rseding91 »

Bilka wrote:Do I understand this right? The last chain signal of the 3 chain signals turns blue (because a rail signal at that end of the chained blocks becomes red?) while the train is inside of the chained blocks. Because the chain signal is blue and the route the trains wants to go to is blocked (aka the rail signal at that end of the chain signal block is red), the train has to stop at the chain signal.

If my above paragraph is right, how would you fix that? There will always be long enough chained blocks so that a rail signal in a trains path can turn red while it's inside the chained blocks.
No, once a train enters any chain signal block (assuming the logic is correct) it will always take the pre-determined exit route - that's where it's currently broken. If when it reaches the exit route the normal signal is red it will wait at that non-chain signal.

However, if you're signaled your rails correctly that never happens because in a proper signaled setup the "end" signal would be impossible to block except by the train coming from the chain signals: AKA: one-way rails.
If you want to get ahold of me I'm almost always on Discord.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by steinio »

Does this fix roundabouts?
Image

Transport Belt Repair Man

View unread Posts
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Rseding91 »

steinio wrote:Does this fix roundabouts?
Probably. I don't have a save that shows a reproducible problem with them so I couldn't test them.
If you want to get ahold of me I'm almost always on Discord.
orzelek
Smart Inserter
Smart Inserter
Posts: 3922
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by orzelek »

There was mention above that this will be fixed for 0.16 - and it's in latest release notes.
Is factorio bot a bit to zealous or it was moved to 0.15?
User avatar
Sephrat
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Wed Mar 16, 2016 2:39 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Sephrat »

YES!! :-)
Thanks for the fix, I'm excited to build a mega-train network in my 0.15 game and see how it goes.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Rseding91 »

orzelek wrote:There was mention above that this will be fixed for 0.16 - and it's in latest release notes.
Is factorio bot a bit to zealous or it was moved to 0.15?
I put it in 0.15. I figure if it's going to cause problems it's easy enough to revert but at most it would cause "a train isn't going where I want" kind of problems and not crashes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 305
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by SupplyDepoo »

Rseding91 wrote:If when it reaches the exit route the normal signal is red it will wait at that non-chain signal.
It should be impossible for that to happen. When a train passes a chain signal, it reserves the exit.
Rseding91 wrote:However, if you're signaled your rails correctly that never happens because in a proper signaled setup the "end" signal would be impossible to block except by the train coming from the chain signals: AKA: one-way rails.
Even if you have two-way rail and a shared exit block, or an exit block that crosses another exit block, it shouldn't cause problems. There's no "correct way to signal the exit block" in that sense. No matter how it's signaled, trains should never stop in a chain-signaled block, because of the reservation mechanic.
ykyjohn
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri May 05, 2017 8:05 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by ykyjohn »

Stuff
The purpose of this topic is not to demonstrate proper signalling but to show of a bug, unless one has additional information on this particular bug I would ask to refrain from making comments here.
-Loewchen
User avatar
Sephrat
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Wed Mar 16, 2016 2:39 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Sephrat »

ykyjohn wrote:
Stuff
The purpose of this topic is not to demonstrate proper signalling but to show of a bug, unless one has additional information on this particular bug I would ask to refrain from making comments here.
-Loewchen
I use that many signals only for throughput reasons: it helps loosening the bottleneck. The many chain signals are only there to have shorter blocks. I know it could work with fewer signals, but the way I designed it make it so that several trains may enter the waiting bays. If one goes all the way to the end, the following one can enter the first waiting bay while the first train still is one its way to its assigned waiting bay.
Anyway, we should discuss it on the original thread instead of the bug report one. :-) let's continue there: viewtopic.php?f=18&t=34321&p=216771
User avatar
Nexarius
Filter Inserter
Filter Inserter
Posts: 275
Joined: Sat May 09, 2015 7:34 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Nexarius »

Rseding91 wrote:
steinio wrote:Does this fix roundabouts?
Probably. I don't have a save that shows a reproducible problem with them so I couldn't test them.
No. If a station is being disabled and the train changes route while in a roundabout it can still get stuck. (0.15.27)
Rseding91
Factorio Staff
Factorio Staff
Posts: 14251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Rseding91 »

Nexarius wrote:
Rseding91 wrote:
steinio wrote:Does this fix roundabouts?
Probably. I don't have a save that shows a reproducible problem with them so I couldn't test them.
No. If a station is being disabled and the train changes route while in a roundabout it can still get stuck. (0.15.27)
That's a different thing. There was an issue with trains in roundabouts.
If you want to get ahold of me I'm almost always on Discord.
triffid_hunter
Inserter
Inserter
Posts: 41
Joined: Wed Dec 14, 2016 7:33 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by triffid_hunter »

Rseding91 wrote:
Nexarius wrote:
Rseding91 wrote:
steinio wrote:Does this fix roundabouts?
Probably. I don't have a save that shows a reproducible problem with them so I couldn't test them.
No. If a station is being disabled and the train changes route while in a roundabout it can still get stuck. (0.15.27)
That's a different thing. There was an issue with trains in roundabouts.
This is fixable and we'd love it to be fixed, but as a programmer I can see that it's really not easy.

Now that random rerouting after chain signal is fixed (0.15.27 changelog, haven't tried yet), we need to do something intelligent on /forced/ rerouting after chain (eg destination station becomes disabled, track tile gets removed, normal signal forced red by circuit, etc)

So, what should we do in this case? Continue on the planned path *anway* until we pass the chain exit (first normal signal)? That could break stackers and such, but is still worth exploring.

Evaluate all reachable chain exits and ignore chain signals? That could cause crashes when multiple trains are in the same chain block - unless the train internally converts chains to normal signals until it exits the chain block.. This could still deadlock if there's two trains in a roundabout, in which case they'd want to fall back on continuing on their original planned route which should still be reserved/clear.

Hm that might work quite well, but if there's another viable destination station it could try to reroute towards that..

Plenty of thinking to be done on this one, but what we specifically *don't* want is trains *parking* in a chained roundabout/intersection when they get confused - they should exit the chain block and intelligently go *somewhere* outside the chain block without crashing into anyone else, somehow..

PS: the stacker thing might be more easily solved if we could attach circuit wires to chain signals ;)

glossary for this post:
"chain block" is the block that a train would be in if all chain signals were removed, and only normal signals remained. Chain signals (already) make it so a train won't enter a "chain block" until it can exit that chain block past a normal signal, and multiple trains can simultaneously occupy a chain block.
"chain exit" is all reachable normal signals from within the current "chain block" - ie places that the train can exit the current chain block
User avatar
SupplyDepoo
Filter Inserter
Filter Inserter
Posts: 305
Joined: Sat Oct 29, 2016 8:42 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by SupplyDepoo »

  1. Trains should never reroute inside of chain-signaled blocks.
  2. When a train reserves blocks, it should be guaranteed that it will use them.
Ripshaft
Inserter
Inserter
Posts: 49
Joined: Tue May 23, 2017 9:09 pm
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Ripshaft »

O, I didn't realize this was actually a bug, I'd always find a spot to place another chain signal to isolate so that a different train could travel through the same area... but I guess that once that other train has passed it prompts the stuck train to recalculate its path? Or I have not been victim to this particular problem... either way, yay fixes!
triffid_hunter
Inserter
Inserter
Posts: 41
Joined: Wed Dec 14, 2016 7:33 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by triffid_hunter »

Ripshaft wrote:O, I didn't realize this was actually a bug, I'd always find a spot to place another chain signal to isolate so that a different train could travel through the same area... but I guess that once that other train has passed it prompts the stuck train to recalculate its path? Or I have not been victim to this particular problem... either way, yay fixes!
The bug happens when a train reroutes, passes a signal or three and then sees *itself* in the next block and refuses to budge until manually moved.

(it can also happen with multiple trains in large junctions, but this is the easiest one to reliably trigger and visualise)

This is really easy to trigger with 6-long or longer trains in roundabouts with 4 to 8 chain signals on the ring. It'll plan to go through the roundabout then reroute after the first signal and decide to go the other way, but its own tail is in that block and trains will never move into an occupied block - boom, deadlock.

There was a note in a recent changelog that the devs have stopped trains randomly rerouting after passing a chain signal but you can still trigger the deadlock by disabling their destination station while they're in the roundabout.
Zavian
Smart Inserter
Smart Inserter
Posts: 1648
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: [Rseding91] [0.14.14] Train stuck in between chain signals (due to rerouting?)

Post by Zavian »

Personally I consider disabling stations whilst trains are en-route to them to be a case of shooting yourself in the foot. If that is causing you problems then don't disable stations whilst trains are en-route.
Locked

Return to “Resolved Problems and Bugs”