Create an account

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

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:

[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:

'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:

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:

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:


import re

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

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


... 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:

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*:

ls -1tr *txt | while read $file
> do
> ./xs_submit -url "" -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?

Oh my
[Image: 237.png]

You're just a human as well!

Still: Hail King of Stats!

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."

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 )

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

Possibly Related Threads…
Thread Author Replies Views Last Post
Wink What a typo can lead to CuBe0wL 9 8,454 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-