Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

run Gratipay 274 #1149

Closed
15 tasks
gratipay-bot opened this issue Aug 31, 2017 · 69 comments
Closed
15 tasks

run Gratipay 274 #1149

gratipay-bot opened this issue Aug 31, 2017 · 69 comments

Comments

@gratipay-bot
Copy link

gratipay-bot commented Aug 31, 2017

← Payday 273


Runbook

http://inside.gratipay.com/howto/run-payday

Checklist

  • Review accounts
  • Trigger backup
  • Run payday script
  • Commit payday logs
  • Run masspay
    • DB query to update broken paypal fees
    • Generate paypal inputs
    • Verify there is no fee mismatch
    • Submit masspay on paypal
    • Post back masspay
  • Commit masspay logs
  • Shuffle escrow
  • Review decline rate
Rotation
Month Pilot Copilot
September @whit537 ✈️ @clone1018
October rohitpaulk whit537
November clone1018 rohitpaulk
December whit537 clone1018
January rohitpaulk whit537
February clone1018 rohitpaulk
March whit537 clone1018
April rohitpaulk whit537
May clone1018 rohitpaulk
June whit537 clone1018
July rohitpaulk whit537
August clone1018 rohitpaulk
@chadwhitacre
Copy link
Contributor

Accounts reviewed.

@chadwhitacre
Copy link
Contributor

/me sets his clock to Honolulu time ... 😁

screen shot 2017-08-31 at 10 12 51 pm

@chadwhitacre
Copy link
Contributor

chadwhitacre commented Sep 1, 2017

Problem taking backup:

pg_dump: error reading large object 21839: SSL SYSCALL error: Operation timed out

It was pretty much done, too. :-/

And now my comment won't post.

whit537.org won't load.

Wireless on my laptop is dead?

It's off but it shows as on in the status bar?

screen shot 2017-08-31 at 10 21 55 pm

Restarting computer.

Now getting "Wi-Fi: No hardware installed". I saw this for the first time a week ago. Re-restart cleared it up, iirc?

screen shot 2017-08-31 at 10 23 30 pm

@chadwhitacre
Copy link
Contributor

😓

@chadwhitacre
Copy link
Contributor

Backup restarted ...

@chadwhitacre
Copy link
Contributor

Backup finished and verified.

@chadwhitacre
Copy link
Contributor

Started script, saw Sept 1 and killed it. UTC! Restarted ...

[gratipay] $ ./payday.sh 274 for_real_please
Run payday #274? (y/N) y
Run payday #274 FOR REAL?!?!?!??!?!? (y/N) y
Logging to ../logs/payday/gratipay-274.log.

Fri Sep  1 08:39:21 UTC 2017
^C
[gratipay] $ ./payday.sh 274 for_real_please
Rerun payday #274? (y/N) y
Rerun payday #274 FOR REAL?!?!?!??!?!? (y/N) y

@chadwhitacre
Copy link
Contributor

Saw a TypeError, realized I might not be on master, killed it right after "Greetings, program! It's Payday!"

@chadwhitacre
Copy link
Contributor

But now it looks like the script kept running? 😞

[gratipay] $ tail -n19 ../logs/payday/gratipay-274.log
pid-1658 thread-140737185432512 (MainThread) Captured 39 card holds.
pid-1658 thread-140737185432512 (MainThread) Canceling card holds.
pid-1658 thread-140737185432512 (MainThread) Canceled 0 card holds.
pid-1658 thread-140737185432512 (MainThread) Updating balances.
pid-1658 thread-140737185432512 (MainThread) Updated the balances of 270 participants.
pid-1658 thread-140737185432512 (MainThread) Taking over balances.
pid-1658 thread-140737185432512 (MainThread) Updating stats.
pid-1658 thread-140737185432512 (MainThread) Updated payday stats.
pid-1658 thread-140737185432512 (MainThread) Notifying participants.
pid-1658 thread-140737185432512 (MainThread) Traceback (most recent call last):
pid-1658 thread-140737185432512 (MainThread)   File "/Users/whit537/personal/gratipay/gratipay.com/gratipay/cli/payday.py", line 11, in main
pid-1658 thread-140737185432512 (MainThread)     Application().payday_runner.run_payday()
pid-1658 thread-140737185432512 (MainThread)   File "/Users/whit537/personal/gratipay/gratipay.com/gratipay/payday_runner.py", line 27, in run_payday
pid-1658 thread-140737185432512 (MainThread)     self._start_payday().run()
pid-1658 thread-140737185432512 (MainThread)   File "/Users/whit537/personal/gratipay/gratipay.com/gratipay/billing/payday.py", line 90, in run
pid-1658 thread-140737185432512 (MainThread)     self.notify_participants()
pid-1658 thread-140737185432512 (MainThread)   File "/Users/whit537/personal/gratipay/gratipay.com/gratipay/billing/payday.py", line 480, in notify_participants
pid-1658 thread-140737185432512 (MainThread)     _user_initiated=False
pid-1658 thread-140737185432512 (MainThread) TypeError: put() takes exactly 5 arguments (3 given)

@chadwhitacre
Copy link
Contributor

chadwhitacre commented Sep 1, 2017

I've shelved my work on gratipay/gratipay.com#4548 and am back on master.

@chadwhitacre
Copy link
Contributor

I am reading payday.py to determine if I should re-run w/o any code changes (commenting out).

@chadwhitacre
Copy link
Contributor

gratipay::DATABASE=> select * from paydays order by ts_end desc limit 1;
┌─────┬───────────────────────────────┬───────────────────────────────┬────────┬────────┬───────┬────────┐
│ id  │           ts_start            │            ts_end             │ volume │ nusers │ stage │ nteams │
├─────┼───────────────────────────────┼───────────────────────────────┼────────┼────────┼───────┼────────┤
│ 340 │ 2017-09-01 08:39:53.223145+00 │ 2017-09-01 08:40:37.939528+00 │ 654.94 │    499 │     2 │    231 │
└─────┴───────────────────────────────┴───────────────────────────────┴────────┴────────┴───────┴────────┘
(1 row)

gratipay::DATABASE=>

@chadwhitacre
Copy link
Contributor

chadwhitacre commented Sep 1, 2017

Since stage is 2 a re-rerun will skip payin and update_stats. We'll hit end a second time, but that'll be a no-op since there's no payday with ts_end 1970.

@chadwhitacre
Copy link
Contributor

Okay, that sucked.

I re-ran ... and it started a new payday! And so I ctrl-c'd right at "It's payday!" ... and then remembered that that wasn't enough to kill the script last time! So I did a ps and kill 1823 as fast as I could ... and I think it was enough?

gratipay::DATABASE=> select * from paydays order by ts_end desc limit 1;
┌─────┬───────────────────────────────┬───────────────────────────────┬────────┬────────┬───────┬────────┐
│ id  │           ts_start            │            ts_end             │ volume │ nusers │ stage │ nteams │
├─────┼───────────────────────────────┼───────────────────────────────┼────────┼────────┼───────┼────────┤
│ 340 │ 2017-09-01 08:39:53.223145+00 │ 2017-09-01 08:40:37.939528+00 │ 654.94 │    499 │     2 │    231 │
└─────┴───────────────────────────────┴───────────────────────────────┴────────┴────────┴───────┴────────┘
(1 row)

gratipay::DATABASE=>

@chadwhitacre
Copy link
Contributor

There is no log for 275. Why not? 👀

[gratipay] $ less ../logs/payday/gratipay-27
gratipay-270.log  gratipay-274.log  

@chadwhitacre
Copy link
Contributor

Because I ran it as 274, so new messages are appended to 274.

[gratipay] $ ./payday.sh 274 for_real_please

@chadwhitacre
Copy link
Contributor

Thankfully, it appears that I killed the process in the nick of time. I see card holds but no captures. 😓 💦

@chadwhitacre
Copy link
Contributor

Sooooo, we will want to cancel all of those card holds, but we can do that later today.

@chadwhitacre
Copy link
Contributor

For now we need to get back on track with notifications.

@chadwhitacre
Copy link
Contributor

And then finish running payday.

@chadwhitacre
Copy link
Contributor

There it is:

gratipay::DATABASE=> select * from paydays order by ts_start desc limit 2;
┌─────┬───────────────────────────────┬───────────────────────────────┬────────┬────────┬───────┬────────┐
│ id  │           ts_start            │            ts_end             │ volume │ nusers │ stage │ nteams │
├─────┼───────────────────────────────┼───────────────────────────────┼────────┼────────┼───────┼────────┤
│ 341 │ 2017-09-01 08:52:48.150756+00 │ 1970-01-01 00:00:00+00        │   0.00 │      0 │     0 │      0 │
│ 340 │ 2017-09-01 08:39:53.223145+00 │ 2017-09-01 08:40:37.939528+00 │ 654.94 │    499 │     2 │    231 │
└─────┴───────────────────────────────┴───────────────────────────────┴────────┴────────┴───────┴────────┘
(2 rows)

@chadwhitacre
Copy link
Contributor

We'll have to clean that up later as well. 😞

@chadwhitacre
Copy link
Contributor

... or now? I believe in order to rerun without picking up the new, wrong payday, what we need to do is delete 341, and reset ts_end on 340 back to 1970-01-01 00:00:00+00.

@chadwhitacre
Copy link
Contributor

gratipay::DATABASE=> update paydays set ts_end='1970-01-01 00:00:00+00' where id=340;
ERROR:  duplicate key value violates unique constraint "paydays_ts_end_key"
DETAIL:  Key (ts_end)=(1970-01-01 00:00:00+00) already exists.
gratipay::DATABASE=> delete from paydays where id=341;
DELETE 1
gratipay::DATABASE=> update paydays set ts_end='1970-01-01 00:00:00+00' where id=340;
UPDATE 1
gratipay::DATABASE=>

@chadwhitacre
Copy link
Contributor

gratipay::DATABASE=> select * from paydays order by ts_start desc limit 2;
┌─────┬───────────────────────────────┬───────────────────────────────┬────────┬────────┬───────┬────────┐
│ id  │           ts_start            │            ts_end             │ volume │ nusers │ stage │ nteams │
├─────┼───────────────────────────────┼───────────────────────────────┼────────┼────────┼───────┼────────┤
│ 340 │ 2017-09-01 08:39:53.223145+00 │ 1970-01-01 00:00:00+00        │ 654.94 │    499 │     2 │    231 │
│ 339 │ 2017-08-24 21:48:50.552623+00 │ 2017-08-24 21:49:28.799672+00 │ 680.26 │    501 │     2 │    230 │
└─────┴───────────────────────────────┴───────────────────────────────┴────────┴────────┴───────┴────────┘
(2 rows)

gratipay::DATABASE=>

@chadwhitacre
Copy link
Contributor

Okay! So now a rerun will pick up 340, see stage 2, skip payin and update_stats, and proceed to end and then notify_participants.

@chadwhitacre
Copy link
Contributor

😅

pid-1947 thread-140737185432512 (MainThread) Picking up with an existing payday.
pid-1947 thread-140737185432512 (MainThread) Payday started at 2017-09-01 08:39:53.223145+00:00.
count#npm-sync-lag=1
pid-1947 thread-140737185432512 (MainThread) Greetings, program! It's PAYDAY!!!!
pid-1947 thread-140737185432512 (MainThread) Notifying participants.
pid-1947 thread-140737185432512 (MainThread) Script ran for six seconds (0:00:06.933801).

@chadwhitacre
Copy link
Contributor

I really don't like that we're installing cron jobs during payday (could we be flushing email from local!?), but that's another story as well.

@chadwhitacre
Copy link
Contributor

Gosh! Okay!

@chadwhitacre chadwhitacre reopened this Sep 1, 2017
@rohitpaulk
Copy link
Contributor

That was eventful..

@chadwhitacre
Copy link
Contributor

I'm working on canceling the card holds.

screen shot 2017-09-01 at 6 45 19 am

@chadwhitacre
Copy link
Contributor

There are only ~30 card holds. I might cancel manually in the Braintree dashboard instead of trying to script it in API.

@chadwhitacre
Copy link
Contributor

Although, looking at fetch_card_holds ... it's a static method and if we pass it an empty list of participant_ids it should do what we want.

I think we can just do:

$ heroku run python
[...]
>>> from gratipay.billing.payday import Payday
>>> Payday.fetch_card_holds([])
[]

@chadwhitacre
Copy link
Contributor

[gratipay] $ honcho run -e defaults.env,local.env env/bin/python < cancel-holds.py 
pid-3003 thread-140737185432512 (MainThread) Fetching card holds.
[gratipay] $
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from gratipay import wireup
from gratipay.billing.payday import Payday

wireup.billing(wireup.env())

Payday.fetch_card_holds([])

@chadwhitacre
Copy link
Contributor

Sooo ...

$ heroku run python < cancel-holds.py

You okay with that, @rohitpaulk?

@chadwhitacre
Copy link
Contributor

I don't see a side-effect to importing Payday, and wireup.billing also looks safe.

@chadwhitacre
Copy link
Contributor

[gratipay] $ heroku run python < cancel-holds.py > cancel-holds.log 
Running python on gratipay... up, run.5784 (Hobby)
^C[gratipay] $ cat cancel-holds.log 
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from gratipay import wireup

wireup.billing(wireup.env())

print('Greetings, program!')
Python 2.7.11 (default, Oct 26 2016, 16:32:16) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # -*- coding: utf-8 -*-
teralsom __future__ import absolute_import, division, print_function, unicode_li 
>>> 
>>> from gratipay import wireup
>>> 
>>> wireup.billing(wireup.env())
>>> 
>>> print('Greetings, program!')
Greetings, program!
>>> [gratipay] $

@chadwhitacre
Copy link
Contributor

Better method:

[gratipay] $ heroku run python -c "`cat greetings.py`"
Running python -c "# -*- coding: utf-8 -*-
Running python -c "# -*- coding: utf-8 -*-
Running python -c "# -*- coding: utf-8 -*-
Running python -c "# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

print('Greetings, program!')" on ⬢ gratipay... up, run.8444 (Hobby)
Greetings, program!
[gratipay] $

@chadwhitacre
Copy link
Contributor

Okay, getting ready to pull the trigger on:

[gratipay] $ heroku run python -c "`cat cancel-holds.py`" 2>&1 | tee cancel-holds.log
from gratipay import wireup
from gratipay.billing.payday import Payday
wireup.billing(wireup.env())
Payday.fetch_card_holds([])

@chadwhitacre
Copy link
Contributor

3 ...

@chadwhitacre
Copy link
Contributor

2 ...

@chadwhitacre
Copy link
Contributor

1 ...

@chadwhitacre
Copy link
Contributor

0!

@chadwhitacre
Copy link
Contributor

Running python -c "from gratipay import wireup
from gratipay.billing.payday import Payday
wireup.billing(wireup.env())
Payday.fetch_card_holds([])" on gratipay... starting, run.4177 (Hobby)
Running python -c "from gratipay import wireup
from gratipay.billing.payday import Payday
wireup.billing(wireup.env())
Payday.fetch_card_holds([])" on gratipay... connecting, run.4177 (Hobby)
Running python -c "from gratipay import wireup
from gratipay.billing.payday import Payday
wireup.billing(wireup.env())
Payday.fetch_card_holds([])" on gratipay... up, run.4177 (Hobby)
pid-4 thread-139695064790784 (MainThread) Fetching card holds.
pid-4 thread-139695064790784 (MainThread) Canceled a $11.13 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.10 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $103.30 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $11.64 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $20.91 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $13.70 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $20.91 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.36 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $12.67 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $12.05 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $11.64 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.87 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $12.67 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.00 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.82 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $12.67 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.61 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $103.30 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $11.52 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $16.79 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.51 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $11.13 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $19.10 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $12.67 hold for [].
pid-4 thread-139695064790784 (MainThread) Canceled a $10.10 hold for [].

@chadwhitacre
Copy link
Contributor

cancel-holds.log appended to gratipay-274.log in https://github.com/gratipay/logs/commit/aa24ac447d7ed8ac165531e881a9805586ca914f.

@chadwhitacre
Copy link
Contributor

Still held in my bank account per bank's web interface. Will check back later on that.

@chadwhitacre
Copy link
Contributor

We canceled one extra hold for 12.05 that must've been left over from ... last time? Or something? Otherwise the amounts all line up for the 31 we accidentally created.

@chadwhitacre
Copy link
Contributor

Oh! Hold placement is multi-threaded so we could've created the 12.05 hold but not logged it.

@chadwhitacre
Copy link
Contributor

chadwhitacre commented Sep 1, 2017

Alright! Things to reticket:

@chadwhitacre
Copy link
Contributor

Reticketed! Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants