Closed cgolubi1 closed 8 years ago
This is in http://dev.buttonweavers.com/ui/game.html?game=1111 and it's persistent. I've asked Jota not to touch it. It is an old game, but what?
The API contains:
"activeDieArray":[
{"value":2,"sides":8,"skills":[],"properties":[],"recipe":"(8)","description":"8-sided die"},
{"value":null,"sides":24,"skills":[],"properties":["Twin"],"recipe":"(12,12)","description":"Twin Die (both with 12 sides)","subdieArray":[{"sides":12},{"sides":12}]}
]
so the backend is sending this for some reason. I'm pretty sure the die was showing 17 before i made that power attack i just made --- it certainly wasn't showing null, i'm nearly positive i would have noticed.
Labelling as prod-blocker at least until we figure out what happened; i can't investigate further atm.
Should this game be set to BROKEN, so we don't accidentally advance it?
In the die table:
+--------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+--------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
| 621399 | 1 | 1 | 1111 | 1 | (8) | 0 | 2 | NULL | NULL |
| 621400 | 1 | 1 | 1111 | 1 | (12,12) | 1 | NULL | 24 | Twin__{"sides":[12,12],"values":[null,null]} |
| 621401 | 4 | 4 | 1111 | 1 | d(4) | 0 | 1 | NULL | NULL |
| 621402 | 4 | 4 | 1111 | 1 | h(8) | 1 | 7 | NULL | NULL |
| 621403 | 1 | 4 | 1111 | 2 | fs(10) | 0 | 8 | NULL | NULL |
| 621404 | 1 | 4 | 1111 | 2 | zs(8) | 1 | 5 | NULL | WasJustCaptured |
| 621405 | 4 | 1 | 1111 | 2 | (10) | 0 | 4 | NULL | NULL |
| 621406 | 4 | 1 | 1111 | 2 | h(X) | 1 | 1 | 7 | NULL |
| 621407 | 4 | 1 | 1111 | 2 | (6) | 2 | 3 | NULL | NULL |
+--------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
I know what's happened here.
Initially, our representation of twin dice did not store the individual subdie values. We introduced that later in #1470.
Apparently, I've failed to correctly deal with the case where we still have database entries that do not have subdie values.
Running the following query on dev
select * from die where flags like 'Twin\_\_%,"values":[null,null]%';
we get
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
| 440027 | 21 | 21 | 376 | 1 | dg(4,4) | 1 | 8 | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 480428 | 1 | 1 | 1462 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 480451 | 15 | 15 | 1465 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 480528 | 1 | 1 | 1478 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 605970 | 9 | 9 | 190 | 1 | d(2,2) | 2 | 3 | 4 | Twin__{"sides":[2,2],"values":[null,null]} |
| 605971 | 9 | 9 | 190 | 1 | d(26,26) | 3 | 19 | 52 | Twin__{"sides":[26,26],"values":[null,null]} |
| 606984 | 13 | 13 | 533 | 1 | (4,10) | 3 | 5 | 14 | Twin__{"sides":[4,10],"values":[null,null]} |
| 606998 | 1 | 1 | 1093 | 1 | dgH(4,4) | 1 | 4 | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 607005 | 13 | 13 | 1093 | 1 | (6,6) | 4 | 6 | 12 | Twin__{"sides":[6,6],"values":[null,null]} |
| 618817 | 1 | 4 | 1188 | 2 | %Ho(1,2) | 0 | 2 | 3 | Twin__{"sides":[1,2],"values":[null,null]} |
| 621400 | 1 | 1 | 1111 | 1 | (12,12) | 1 | NULL | 24 | Twin__{"sides":[12,12],"values":[null,null]} |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
Running the same query on prod, we get:
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+--------------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+--------------------------------------------------+
| 2324663 | 33 | 33 | 348 | 1 | (8,8) | 1 | 9 | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 2324664 | 40 | 33 | 348 | 2 | (10,10) | 0 | 16 | 20 | Twin__{"sides":[10,10],"values":[null,null]} |
| 2324665 | 40 | 33 | 348 | 2 | (W,W) | 1 | 8 | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 2324716 | 33 | 4 | 827 | 2 | (2,2) | 2 | 4 | 4 | Twin__{"sides":[2,2],"values":[null,null]} |
| 2925645 | 6 | 6 | 8925 | 1 | (T,T) | 4 | NULL | NULL | Twin__{"sides":[null,null],"values":[null,null]} |
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+--------------------------------------------------+
Of those games on prod,
348 could be fixed manually 827 is a game involving Fog, and is currently at the last turn in the round, so the issue would resolve itself anyway 8925 has the subdie values NULL because the game is currently between rounds, so the dice haven't been rolled yet.
Of the games on dev, the following games are between rounds or at the start of game: 376, 1462, 1465, 1478
The following games are potentially going to break or have broken: 190, 533, 1093, 1111, 1188
So, I would suggest the following fix for the live site: UPDATE die SET flags='Twin{"sides":[8,8],"values":[8,1]} WHERE id=2324663; UPDATE die SET flags='Twin{"sides":[10,10],"values":[10,6]} WHERE id=2324664; UPDATE die SET flags='Twin{"sides":[8,8],"values":[7,1]} WHERE id=2324665; UPDATE die SET flags='Twin{"sides":[2,2],"values":[2,2]} WHERE id=2324716;
Is that acceptable to you, Chaos?
A similar fix for dev would be: UPDATE die SET flags='Twin{"sides":[2,2],"values":[2,1]} WHERE id=605970; UPDATE die SET flags='Twin{"sides":[26,26],"values":[18,1]} WHERE id=605971; UPDATE die SET flags='Twin{"sides":[4,10],"values":[4,1]} WHERE id=606984; UPDATE die SET flags='Twin{"sides":[4,4],"values":[3,1]} WHERE id=605998; UPDATE die SET flags='Twin{"sides":[6,6],"values":[5,1]} WHERE id=607005; UPDATE die SET flags='Twin{"sides":[1,2],"values":[1,1]} WHERE id=618817; UPDATE die SET flags='Twin__{"sides":[12,12],"values":[12,5]} WHERE id=605970; UPDATE die SET value=17 WHERE id=605970;
FYI, shadowshade, i edited your comments on this post to put triple-backticks around all the SQL results --- being monospaced makes that output a lot more readable.
Ah, thanks. :)
Okay, i'm going to go ahead and wrap this up.
On the dev site:
mysql> select * from die where flags like 'Twin\_\_%,"values":[null,null]%' order by game_id;
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
| 605970 | 9 | 9 | 190 | 1 | d(2,2) | 2 | 3 | 4 | Twin__{"sides":[2,2],"values":[null,null]} |
| 605971 | 9 | 9 | 190 | 1 | d(26,26) | 3 | 19 | 52 | Twin__{"sides":[26,26],"values":[null,null]} |
| 440027 | 21 | 21 | 376 | 1 | dg(4,4) | 1 | 8 | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624131 | 1 | 1 | 1093 | 1 | dgH(4,4) | 1 | NULL | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624137 | 13 | 13 | 1093 | 1 | (6,6) | 3 | NULL | 12 | Twin__{"sides":[6,6],"values":[null,null]} |
| 621400 | 1 | 1 | 1111 | 1 | (12,12) | 1 | NULL | 24 | Twin__{"sides":[12,12],"values":[null,null]} |
| 480428 | 1 | 1 | 1462 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 480451 | 15 | 15 | 1465 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 480528 | 1 | 1 | 1478 | 1 | z(8,8)? | 2 | NULL | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+----------------------------------------------+
9 rows in set (0.00 sec)
mysql>
Hmm, it seems to me that many of the dice with value=NULL should be non-errors because those games are in non-playing states or whatnot. Let's look:
What did James say?
Alright, i think this search is in fact the correct one:
mysql> select d.* from die as d,game as g where d.game_id = g.id and d.flags like '%Twin\_\_%,"values":[null,null]%' and g.game_state > 24 order by d.game_id;
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
| 605971 | 9 | 9 | 190 | 1 | d(26,26) | 3 | 19 | 52 | Twin__{"sides":[26,26],"values":[null,null]} |
| 605977 | 13 | 9 | 190 | 2 | d(8,8) | 0 | 15 | 16 | WasJustCaptured;Twin__{"sides":[8,8],"values":[null,null]} |
| 605970 | 9 | 9 | 190 | 1 | d(2,2) | 2 | 3 | 4 | Twin__{"sides":[2,2],"values":[null,null]} |
| 440027 | 21 | 21 | 376 | 1 | dg(4,4) | 1 | 8 | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624128 | 1 | 13 | 533 | 2 | (4,10) | 1 | NULL | 14 | WasJustCaptured;Twin__{"sides":[4,10],"values":[null,null]} |
| 624131 | 1 | 1 | 1093 | 1 | dgH(4,4) | 1 | NULL | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624137 | 13 | 13 | 1093 | 1 | (6,6) | 3 | NULL | 12 | Twin__{"sides":[6,6],"values":[null,null]} |
| 621400 | 1 | 1 | 1111 | 1 | (12,12) | 1 | NULL | 24 | Twin__{"sides":[12,12],"values":[null,null]} |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
8 rows in set (0.01 sec)
mysql>
and that shows 8 dice in 5 games on the dev site which need fixing.
Okay, so, given that, here's a modified proposed fix for dev:
# fix game 190
UPDATE die SET flags='Twin__{"sides":[26,26],"values":[18,1]}' WHERE id=605971 AND game_id=190;
UPDATE die SET flags='WasJustCaptured;Twin__{"sides":[8,8],"values":[7,8]}' WHERE id=605977 AND game_id=190;
UPDATE die SET flags='Twin__{"sides":[2,2],"values":[2,1]}' WHERE id=605970 AND game_id=190;
# fix game 376
UPDATE die SET flags='Twin__{"sides":[4,4],"values":[4,4]}' WHERE id=440027 AND game_id=376;
# fix game 533
UPDATE die SET flags='WasJustCaptured;Twin__{"sides":[4,10],"values":[2,3]}',value=5 WHERE id=624128 AND game_id=533;
# fix game 1093
UPDATE die SET flags='Twin__{"sides":[4,4],"values":[2,2]}',value=4 WHERE id=624131 AND game_id=1093;
UPDATE die SET flags='Twin__{"sides":[6,6],"values":[3,3]}',value=6 WHERE id=624137 AND game_id=1093;
# fix game 1111
UPDATE die SET flags='Twin__{"sides":[12,12],"values":[12,5]}',value=17 WHERE id=621400 AND game_id=1111;
I'm going to go ahead and try that.
Game 190:
mysql> UPDATE die SET flags='Twin__{"sides":[26,26],"values":[18,1]}' WHERE id=605971 AND game_id=190;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='WasJustCaptured;Twin__{"sides":[8,8],"values":[7,8]}' WHERE id=605977 AND game_id=190;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[2,2],"values":[2,1]}' WHERE id=605970 AND game_id=190;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
That game no longer shows up in the broken list:
mysql> select d.* from die as d,game as g where d.game_id = g.id and d.flags like '%Twin\_\_%,"values":[null,null]%' and g.game_state > 24 order by d.game_id;
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
| 440027 | 21 | 21 | 376 | 1 | dg(4,4) | 1 | 8 | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624128 | 1 | 13 | 533 | 2 | (4,10) | 1 | NULL | 14 | WasJustCaptured;Twin__{"sides":[4,10],"values":[null,null]} |
| 624131 | 1 | 1 | 1093 | 1 | dgH(4,4) | 1 | NULL | 8 | Twin__{"sides":[4,4],"values":[null,null]} |
| 624137 | 13 | 13 | 1093 | 1 | (6,6) | 3 | NULL | 12 | Twin__{"sides":[6,6],"values":[null,null]} |
| 621400 | 1 | 1 | 1111 | 1 | (12,12) | 1 | NULL | 24 | Twin__{"sides":[12,12],"values":[null,null]} |
+--------+----------+-------------------+---------+-----------+----------+----------+-------+------------+-------------------------------------------------------------+
5 rows in set (0.00 sec)
mysql>
and still appears loadable. I'll fix the other four now.
mysql> UPDATE die SET flags='Twin__{"sides":[4,4],"values":[4,4]}' WHERE id=440027 AND game_id=376;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='WasJustCaptured;Twin__{"sides":[4,10],"values":[2,3]}',value=5 WHERE id=624128 AND game_id=533;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[4,4],"values":[2,2]}',value=4 WHERE id=624131 AND game_id=1093;
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[6,6],"values":[3,3]}',value=6 WHERE id=624137 AND game_id=1093;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[12,12],"values":[12,5]}',value=17 WHERE id=621400 AND game_id=1111;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select d.* from die as d,game as g where d.game_id = g.id and d.flags like '%Twin\_\_%,"values":[null,null]%' and g.game_state > 24 order by d.game_id;
Empty set (0.01 sec)
mysql>
All games can now be loaded in the UI without internal errors on the backend, and i don't see any nulls. So i think dev is fixed.
Okay, on prod, that same search gives:
mysql> select d.* from die as d,game as g where d.game_id = g.id and d.flags like '%Twin\_\_%,"values":[null,null]%' and g.game_state > 24 order by d.game_id;
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
| id | owner_id | original_owner_id | game_id | status_id | recipe | position | value | actual_max | flags |
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
| 2324663 | 33 | 33 | 348 | 1 | (8,8) | 1 | 9 | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 2324664 | 40 | 33 | 348 | 2 | (10,10) | 0 | 16 | 20 | Twin__{"sides":[10,10],"values":[null,null]} |
| 2324665 | 40 | 33 | 348 | 2 | (W,W) | 1 | 8 | 16 | Twin__{"sides":[8,8],"values":[null,null]} |
| 2324716 | 33 | 4 | 827 | 2 | (2,2) | 2 | 4 | 4 | Twin__{"sides":[2,2],"values":[null,null]} |
+---------+----------+-------------------+---------+-----------+---------+----------+-------+------------+----------------------------------------------+
4 rows in set (0.01 sec)
mysql>
I think it should be pretty harmless to just fix those --- did James identify any other games on prod? Nope, that was it except a false positive which my search excluded (or that game has moved states).
So here are the prod fixes:
# game 348
UPDATE die SET flags='Twin__{"sides":[8,8],"values":[8,1]}' WHERE id=2324663 AND game_id=348;
UPDATE die SET flags='Twin__{"sides":[10,10],"values":[10,6]}' WHERE id=2324664 AND game_id=348;
UPDATE die SET flags='Twin__{"sides":[8,8],"values":[7,1]}' WHERE id=2324665 AND game_id=348;
# game 827
UPDATE die SET flags='Twin__{"sides":[2,2],"values":[2,2]}' WHERE id=2324716 AND game_id=827;
That's exactly what James suggested (the extra AND condition on the select is just to discourage typoes), so i'll go ahead and do that.
mysql> UPDATE die SET flags='Twin__{"sides":[8,8],"values":[8,1]}' WHERE id=2324663 AND game_id=348;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[10,10],"values":[10,6]}' WHERE id=2324664 AND game_id=348;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[8,8],"values":[7,1]}' WHERE id=2324665 AND game_id=348;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE die SET flags='Twin__{"sides":[2,2],"values":[2,2]}' WHERE id=2324716 AND game_id=827;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select d.* from die as d,game as g where d.game_id = g.id and d.flags like '%Twin\_\_%,"values":[null,null]%' and g.game_state > 24 order by d.game_id;
Empty set (0.01 sec)
mysql>
Those games are still loadable with no more internal errors. That's it for this one --- sorry for the delay in applying the fix.
What?