-
Notifications
You must be signed in to change notification settings - Fork 308
history is screwed up, negative balance #1116
Comments
I checked with the backup I took before payday yesterday (#1107) and it's a problem there too. So this isn't something that snuck in yesterday during payday. |
This may yet be a payday bug though. The history page starts with your current balance and adds/subtracts from that for each record in the transfers and exchanges table. |
According to |
I count 58 affected accounts as of Gittip 56. |
So we've got a bug. |
(Though I guess we knew that.) |
One implication we'll have to follow up on is that I've used the balance as reported on the history page to drive manual payouts. |
I have a series of weekly backups from the past year. A good next step might be to run my checker script against each week's backup to find out when this behavior started. |
Here's the number of affected record for each backup I've got:
|
So the problem seems to have been with us the whole time(!). It grew through week 7, which was a bit of a clusterhuck (#169). We apparently hit the reset button in cleaning that up, but it has since grown again. It is currently affecting 90 accounts out of 1559 with a balance (6%). Presumably once an account is corrupted then the corruption carries through (rather than some accounts being corrupted some weeks, others the next). The growth in corruption doesn't appear to line up with instances of the payday script crashing. We've had a handful of instances of that, and none in the past few months until this week, which isn't even represented above. The corruption appears to be part of payday in general and not triggered by crash-and-rerun. |
We should make sure we're accounting for fees properly in the check script. I don't see that fees could be implicated in the corruption itself, because @pjz has zero exchanges and great corruption. |
Phew. I wasn't subtracting payout fees from exchange amounts (the
|
One interesting datum is that for the four accounts affected, three of them get corrupted only once. @pjz got corrupted twice. But in other words it's only happening to a few users (4 / 1559 = 0.2%) and it's only happened five times total. It's a rare event, thankfully. What is it? Do these corruptions line up with payday crashes? |
The second in 2013-01-24 is explained by a blip in my handling of a manual payout. |
Last payday 'worked'... in that it adjusted from my previous balance correctly. I'm still down the $220ish amount, though. |
We picked up another corrupt record last week. We crashed two weeks ago 2013-07-04 (#1107). Each backup above generally is from immediately before payday is run, so the 2013-07-04 row above is the state of the db just before the 2013-07-04 payday, etc. 2013-07-11 went off without a hitch (#1131), except that after it we now have an additional corrupt record. When we first experienced corruption during payday (#169) it turned out that the corruption entered in one week but didn't manifest until the next week. Is that the pattern here as well? How do the manifestations here line up with payday crashes? |
(I manually added in the dates corresponding to the Gittip week number.)
|
Well, I'd say that rules out crashing as the root cause! Back to the drawing board. :-) |
I believe pachinko first hit in Gittip 46 (#857). The frequency of corruption has increased since then, but we have that one case way back in week 29. Maybe there are multiple causes? |
Here's the data for @pjz:
P.S. |
What is the pattern here? It's interesting that |
Okay! I believe (in @pjz's case at least) that this is due to a bug where we record an ach credit locally even if the Balanced API call fails. The reason we attempt to credit @pjz in the first place here is because he has a Balanced account connected (even though he has no credit card or bank account on file). In other words, Gittip believes that @pjz has been withdrawing money all along. The stairstep effect is due to the minimum payout threshold of $10. |
I keep logs for each payday. I inferred the above after seeing a |
The fix is somewhat tricky because we do want to call into |
So is it fixed? Is it going to happen again? Can you fix my balance yet? |
I have an idea for an easy fix, but I want to write a test first. I put a |
We're at 75% coverage on |
Now to repair the damage ... |
Okay! Database repaired with the 1116.py script. Affected users were: @colindean @nexxy @nicksergeant @richleland @pjz. For those just joining us, we had a bug where we corrupted your balance on Gittip, because we mishandled the case where you attached a Balanced bank account (or credit card?) and then detached the bank account. We were still treating you as having a bank account attached, so Gittip was decrementing your balance each week even though there was no actual deposit happening. Sorry! :-( |
yay, fixed! |
!m @whit537 |
this must have been a difficult one @whit537 and thanks for handling it so well (and in such an open manner) |
@tshepang Having the weekly backups and payday log files for the past year certainly helped. :-) |
@pjz noticed, not sure yet who else might be affected.
The text was updated successfully, but these errors were encountered: