Antibody's adventures in typo-land - Printable Version +- Xonotic Forums (https://forums.xonotic.org) +-- Forum: Community (https://forums.xonotic.org/forumdisplay.php?fid=6) +--- Forum: Xonotic - General (https://forums.xonotic.org/forumdisplay.php?fid=18) +--- Thread: Antibody's adventures in typo-land (/showthread.php?tid=4498) |
Antibody's adventures in typo-land - Antibody - 10-02-2013 A few folks notified me of a problem with XonStat yesterday. After looking into the logs I couldn't diagnose the issue, so I tabled it for further investigation. Upon arriving home, I dug more into the issue, finding this in my log: Code: [xonstat.views.submission][MainThread] Error (non-fatal): elo processing failed. Uh oh. What is causing that? I grabbed an example submission through VIM and ran it through my local instance of XonStat on my desktop, which promptly told me more: Code: 'Date out of range. Fix the team_game_stats_ins() trigger!' Ahhh, so that's what it is. Thanks former self for writing informative error messages! Looking into the trigger code*, Here's the offending line: Code: ELSIF (NEW.create_dt >= DATE '2013-10-01' AND NEW.create_dt < DATE '2013-01-01') Anyone spot the flaw in this line of code? Yep, you've got it - a date can never be both greater than October 1st and less than January 1st of the same year! The result was that PostgreSQL couldn't find the right spot to put an incoming row, so it puked. All because I'd typed 2013 instead of 2014. Awesome. Go, me. So having identified and resolved the issue, I checked to see how many games were affected: Code: grep -i "elo processing failed" xonstat.log.old | wc -l Yikes! 216! That meant over 200 games didn't make it into the database throughout the day yesterday because of this error. Crap. I resolved myself to grab these submissions and (re)apply them to the database. To do this, I had to extract the submissions into text files. Before I could get there, I first had to know the affected match_ids (a unique number per server that prevents duplicate submissions). I started with the parsing code: Code: #!/usr/bin/python ... which gave me a list of 216 match_ids. I then took those match_ids and extracted out their submissions via a utility of mine that was already written: Code: cat bad_match_ids.log | while read match_id Now I have all of the text files containing the submissions missing from the database. Now to apply them to the database *in order*: Code: ls -1tr *txt | while read $file My terminal was happily spitting out HTTP-200 (success) statuses for about five minutes, after which I called it a night. 209 of the 216 requests were valid (the others being malformed in one way or another), so we now have those in the database for your viewing pleasure. The two things to note are that the dates and IPs are off for these submissions. The dates are going to be when I submitted them in batch, and the server IPs will *temporarily* be set to the stats server IP. That's something I couldn't work around for the time being, but it will sort itself out anyway. Cheers! tl;dr: Antibody makes typo, resubmits over 200 games to XonStat manually. Great success. *For those of you not familiar with databases, triggers are pieces of code in databases that fire when you do certain things. In this case we have an insert trigger that fires when a row is inserted into the team game stats table. This particular one is in place to shepherd rows heading for the master table - team_game_stats - into one of several child tables (aka partitions). RE: Antibody's adventures in typo-land - dizzy - 10-02-2013 Oh my RE: Antibody's adventures in typo-land - Mirio - 10-02-2013 You're just a human as well! Still: Hail King of Stats! RE: Antibody's adventures in typo-land - CuBe0wL - 10-02-2013 I didn't understand a word, but nevertheless, good job fixing it! RE: Antibody's adventures in typo-land - machine! - 10-02-2013 Makes a stupid mistake, solves it in such a way that everyone else feels stupid. (I admire the post, not trying to be negative ) RE: Antibody's adventures in typo-land - kammy - 10-02-2013 |