Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Antibody's adventures in typo-land

#1
Wink 
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

import re

f = open("xonstat.log.old")

for line in f:
    match = re.search("I ([\d\.]+)\s*", line)
    if match:
        match_id = match.group(1)
    if re.search('elo processing failed', line):
        print(match_id)

f.close()

... 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
> do
> ./xs_parselog -file xonstat.log.old -match $match_id
> done

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
> do
> ./xs_submit -url "http://stats.xonotic.org/stats/submit" -file $file
> sleep 1
> done

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).
asyyy^ | are you releated to chuck norris?
Reply

#2
Oh my
[Image: 237.png]
Reply

#3
You're just a human as well!

Still: Hail King of Stats!
Reply

#4
I didn't understand a word, but nevertheless, good job fixing it! Big Grin
[Image: 561.png]
"One should strive to achieve; not sit in bitter regret."
Reply

#5
Makes a stupid mistake, solves it in such a way that everyone else feels stupid.

(I admire the post, not trying to be negative Wink )
Reply

#6
[Image: 3qb98y.jpg]
[Image: 12766.png]
Sucks at weapons
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink What a typo can lead to CuBe0wL 9 8,779 09-24-2013, 07:13 AM
Last Post: bitbomb

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-