ctm / mb2-doc

Mb2, poker software
https://devctm.com
7 stars 2 forks source link

NickMapper removes table with messages pending #1328

Closed ctm closed 4 months ago

ctm commented 4 months ago

Fix so we don't get warnings similar to:

2024-02-29T01:42:51.031Z WARN [mb2::mb2::nick_mapper] Could not find event_id for TableId(5715) 2024-02-29T01:42:51.038Z WARN [mb2::mb2::nick_mapper] Could not find event_id for TableId(5715)

I checked the timestamps on when those messages were generated, and it looks like a race condition where we shut down a table but there are still pending messages being processed. FWIW, I think this bug has been here for a while, it's just that NickMapper now points it out to us.

mb2=> select id, received_at, message from public_table_messages where table_id = 5715 order by received_at desc limit 3;
select id, received_at, message from public_table_messages where table_id = 5715 order by received_at desc limit 3;
    id    |          received_at          |         message         
----------+-------------------------------+-------------------------
 10561321 | 2024-02-29 01:42:51.034435+00 | "TableFinished"
 10561320 | 2024-02-29 01:42:51.028078+00 | {"MovedTo": [9, 5714]}
 10561318 | 2024-02-29 01:42:51.0084+00   | {"MovedTo": [11, 5714]}
(3 rows)

I don't think that those missing messages matter, per-se, because the players who are moved will continue to get messages at their new table. However, we really don't want to have WARN messages in our log, and even benign race-conditions are icky, so I've made this high priority.

ctm commented 4 months ago

Currently there are two places an entry can be removed from NickMapper's tables, one of which is fairly early in moved_from_to and is likely the cause of the warnings. However, neither of them are necessary, since we can simply not delete until TableFinished has been sent and the last player leaves. I'll add a is_finished field to TableInfo and use it appropriately.

ctm commented 4 months ago

Done. Deploying now.

ctm commented 4 months ago

Still here:

2024-03-01T01:23:14.957Z WARN  [mb2::mb2::nick_mapper] Could not find event_id for TableId(5716)
ctm commented 4 months ago

Oops. Previously I put in code to update "finished", but didn't actually use it to defer the removal from tables.

Fixed. Deploying now.