-
Notifications
You must be signed in to change notification settings - Fork 308
run Gittip #7 #169
Comments
|
There's a typecheck on |
Per schema.sql, balance can be NULL but should default to 0.0:
|
Two out of 3,178 records in the participants table have balance NULL. |
The only places I see where balance is set explicitly are in billing.py:
|
It turns out that NULL + number is NULL:
|
This first one smells worse to me than the other two:
|
Is it guaranteed that pending in the first assignment is the value of pending before the second assignment? Sure sounds like it:
|
Let's go look at history for those two NULL balances ... |
Interesting! One joined a week ago, the other is unclaimed but was created right after the first joined. I bet the first tipped the second. Hypothesis: the memory errors that caused #143 also factored into this. |
Oh wow! So it turns out both balance NULL accounts were created during payday last week!
I double-checked, and a GitHub user gets an entry in the participants table simply when anyone visits https://www.gittip.com/github/{login}/ for the first time. I cross-checked the tips table, and indeed the two participants in this case are unrelated, other than they both were "upserted" in Gittip while payday was running. So how exactly did this happen? |
Ah! It's because when they were created, their pending value was set to NULL. Then when this was added to their 0.0 balance at the end of payday, balance became NULL. QED. |
So how do we repair the existing database, and how do we close this hole? Ack! This means that anyone creating an account RIGHT NOW will fall prey to the same bug. :-( |
And in fact we do have three new participants, with pending NULL. Hmm ... |
FixThe repair is to set balance to 0.0 where it is NULL. Right? My concern is that this would clobber someone's positive balance. But since they joined during the immediately prior payday, it's guaranteed that they couldn't possibly have a positive balance at the start of this payday, although they may of course receive tips during this payday (although the two cases in question aren't this week). For the three ... I mean four (you turkeys!) participants that are created during the current payday, we should let them go until the end of this payday run. Their balance will become NULL during the ending of payday (as with the two from last week), at which point we should reset their balance to 0.0. RepairThe first fix is to put a NOT NULL constraint on balance (see #35, and rue the day), so we would catch this the week it first happened instead of the next week. The second fix is to add a
That will ensure that participants created after payday starts are not clobbered at the end of payday. We then need to tweak the queries at the start of payday to guarantee that any participants that were created after the start of payday will not be included in the list of participants to include in this payday. That means adding Of course now that we have a test suite for billing (#44) we should also write a test for this before fixing. Here's another question: What happens if someone who signed up before payday tips an account that's created during payday? I believe we need to take steps to protect against that as well. |
The people who joined during the first (aborted) payday run were picked up in the second, meaning they had their pending value set to 0.0 before proceeding, and balance survived the event intact. No-one else joined during the second run, so there's no further need to repair the db at this point relative to this issue. |
Fix for root cause of failure reticketed as #170. Case closed. |
Care must be taken to use the old Stripe code one more time instead of the new Balanced code. We didn't get data migrated from Stripe to Balanced in time to use Balanced this week.
The text was updated successfully, but these errors were encountered: