lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
15.78k stars 2.28k forks source link

Swiss round can get stuck in a round failed loop. #14387

Open TBestLittleHelper opened 11 months ago

TBestLittleHelper commented 11 months ago

Exact URL of where the bug happened

Two examples, both swisses were manually ended. https://lichess.org/swiss/oDyWAtwp https://lichess.org/swiss/Pt1Q0fpN

Steps to reproduce the bug

Unclear, however possibly the swiss failing is a side effect of a match being created twice in the same round.

https://lichess.org/lysyIINx/black https://lichess.org/fCXBXaUA/black

and

https://lichess.org/VHxyckr8 https://lichess.org/VQZEGNCr/black

What did you expect to happen?

Swiss to pair as normal. Or, if the round fails multiple times, that the swiss is ended.

What happened instead?

Swiss got stuck in a loop of.

Round 2 failed Round 3 will start soon

Operating system

win11

Browser and version (or alternate access method)

Any

Additional information

No response

kraktus commented 11 months ago

looks Lila is producing an invalid TRF file

swiss BBPairing oDyWAtwp Error parsing file REDACTED: Invalid line "001    4       ignatiy-yakhont2008              2288                             0.0         42 w 0    62 b Z
Virinas-code commented 1 month ago

So I might be dumb but in the sample from kraktus we can see on round 2 for player 4:

62 b Z

So on round 2 player 4 was paired against 62, but since the player was missing lila gave a zero-point-bye Z.

However in bbpPairings code:

          if (
            resultChar == '+'
              || resultChar == '-'
              || resultChar == 'H'
              || resultChar == 'F'
              || resultChar == 'U'
              || resultChar == 'Z'
              || resultChar == ' ')
          {
            gameWasPlayed = false;
            if (resultChar != '+' && resultChar != '-' && opponent != id)
            {
              throw InvalidLineException();
            }
          }

Where:

char resultChar = 'Z'; // The round result
int opponent = 62;     // The opponent
int id = 4;            // The player id

So that explains the exception. I will try running bbpPairings with a debugger to have more insight, but I need the exact TRF file generated by lila. (@kraktus where did you get that line from?)

ornicar commented 1 month ago

Thank you for looking into this. Every lichess swiss page contains a link to download the TRF.

kraktus commented 1 month ago

Nice findings! The error was from the server logs, in that case the trf should be this one https://lichess.org/swiss/oDyWAtwp.trf from https://lichess.org/swiss/oDyWAtwp

Virinas-code commented 1 month ago

Again, might be dumb, but in this file we can't see the "Z" on player 4 round 2...

Virinas-code commented 1 month ago

It isn't the right player too: 5 instead of 4

001    5       ignatiy-yakhont2008              2288                             0.0         49 w 0    69 b 0
kraktus commented 1 month ago

Lichess generates a TRF after each round to send to bbp for pairing. I don't know how the players order is generated or if it supposed to be consistent across rounds, I doubt it especially considering late-joiner.

I've tried to find more recent examples in the logs, to no avail unfortunately.

Virinas-code commented 1 month ago

So maybe the starting rank doesn't mean anything, but the result of round 2 for this player is still different:

And this is the source of the issue. Maybe try dumping the full TRF when an error occurs with bbpPairings?

kraktus commented 1 month ago

I have found out a local copy I made of these logs from that day, with more occurences. I will clean it up and post it here.