Closed ctm closed 7 months ago
This is undoubtedly due to the table 5562 being newly cloned:
mb2=> select id, received_at at time zone 'mst', substr(message::text, 0, 80), table_id from public_table_messages where player_id is null and hand_id = 386777 order by received_at;
id | timezone | substr | table_id
----------+----------------------------+---------------------------------------------------------------------------------+----------
10279211 | 2024-01-02 18:30:03.475766 | {"Dealing": ["800 1600 Murder (High/Low Eight Qualifier)", 0, "SplitLimit", 7, | 5562
10279241 | 2024-01-02 18:30:05.371264 | "NoAnte" | 5562
10279242 | 2024-01-02 18:30:05.376345 | {"Blinds": [6, 500, false, "Small"]} | 5562
10279243 | 2024-01-02 18:30:05.380915 | {"Blinds": [17, 1000, false, "Big"]} | 5562
10279244 | 2024-01-02 18:30:05.385625 | {"BeginRound": [0, null, 1000, 0, false, 35]} | 5562
10279245 | 2024-01-02 18:30:05.390158 | {"Status": {"board": {"grid": null, "cards": {"cards": []}}, "button": {"seat": | 5562
10279246 | 2024-01-02 18:30:05.394993 | {"Remind": [20000, 1000, "2024-01-03T01:30:25.370102489Z", 11, 20]} | 5562
10279249 | 2024-01-02 18:30:09.669433 | {"Calls": [11, null, false, 1000]} | 5562
10279250 | 2024-01-02 18:30:09.674388 | {"Remind": [20000, 1000, "2024-01-03T01:30:29.668029153Z", 13, 20]} | 5562
10279251 | 2024-01-02 18:30:10.452659 | {"Folds": [13, false, null, null]} | 5562
10279252 | 2024-01-02 18:30:10.457114 | {"Remind": [20000, 1000, "2024-01-03T01:30:30.451252218Z", 14, 20]} | 5562
10279255 | 2024-01-02 18:30:11.50588 | {"RaisesNtoM": [14, 600, 1600, null, false, 1600]} | 5562
...
mb2=> select id, created_at at time zone 'mst' from tables where event_id = 4960;
id | timezone
------+----------------------------
5560 | 2024-01-02 18:05:00.559839
5561 | 2024-01-02 18:12:43.213452
5562 | 2024-01-02 18:30:03.356152
(3 rows)
My guess is if I review where the values come from for Dealing
and Blinds
, the source of the bug will be obvious.
Dealing
comes from the Table's game
, whereas Blinds
comes from the Table's game_keeper
. Normally those are in sync, and to be honest, if it weren't for this bug, I'd think they always would have to be in sync, but it turns out, dup
has this super poor bit of code:
let mut game_keeper = self.game_keeper.clone();
let (game, _) = game_keeper.new_game();
which I wrote long before I gave serious thoughts about splitting tables. Git blame claims:
f0807093f mb2/src/table.rs (Clifford T. Matthews 2021-01-23 15:22:30 -0700 1000) let (game, _) = game_keeper.new_game();
and so that means the line in question dates back to at least January 23rd, 2021.
FWIW, I made that hack because game is a trait object and as such it can't be cloned. new_game
did what I wanted at the time and … what's a little mutation between friends?!
Obviously, mutating during dup
is a really bad idea, so I'll eliminate it and hence eliminate this bug.
[master]% git show
commit 2fec23a271ec2b81dd90f5e6353e2c9be57412c1 (HEAD -> master)
Author: Clifford T. Matthews <ctm@devctm.com>
Date: Wed Jan 3 14:42:39 2024 -0700
[Bug] fixes bug that caused weird hand yesterday evening. Closes #1270.
diff --git a/mb2/src/game_keeper.rs b/mb2/src/game_keeper.rs
index 7a0dc54b..eaabc6ea 100644
--- a/mb2/src/game_keeper.rs
+++ b/mb2/src/game_keeper.rs
@@ -183,7 +183,11 @@ impl GameKeeper {
}
}
self.update_ante();
- (self.game_info.new_game(self.stakes()), changed)
+ (self.same_game(), changed)
+ }
+
+ pub(crate) fn same_game(&self) -> Box<dyn GameGroup> {
+ self.game_info.new_game(self.stakes())
}
pub(crate) fn temporary_new_game(&mut self, game_info: &GameInfo) -> Box<dyn GameGroup> {
diff --git a/mb2/src/table.rs b/mb2/src/table.rs
index 28de7487..d8119a70 100644
--- a/mb2/src/table.rs
+++ b/mb2/src/table.rs
@@ -996,8 +996,8 @@ impl Table {
let action_out = self.action_out.clone();
let action_timer = None;
let pool = self.pool.clone();
- let mut game_keeper = self.game_keeper.clone();
- let (game, _) = game_keeper.new_game();
+ let game_keeper = self.game_keeper.clone();
+ let game = game_keeper.same_game();
let revealable = None;
let die = self.die.clone();
#[cfg(feature = "force-status")]
Deploying now, albeit with a bag over my head so nobody will recognize me.