Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

run Gratipay 135 #3045

Closed
chadwhitacre opened this issue Jan 1, 2015 · 38 comments
Closed

run Gratipay 135 #3045

chadwhitacre opened this issue Jan 1, 2015 · 38 comments

Comments

@chadwhitacre
Copy link
Contributor

134

@chadwhitacre
Copy link
Contributor Author

Droplet spun up and updated.

@chadwhitacre
Copy link
Contributor Author

47 (37) accounts reviewed.

@chadwhitacre
Copy link
Contributor Author

Backup taken and verified.

@chadwhitacre
Copy link
Contributor Author

Script started.

@chadwhitacre
Copy link
Contributor Author

Thu Jan  1 17:46:52 UTC 2015
pid-1785 thread-139755151517440 (MainThread) Starting a new payday.
pid-1785 thread-139755151517440 (MainThread) Payday started at 2015-01-01 17:47:07.498402+00:00.
pid-1785 thread-139755151517440 (MainThread) Greetings, program! It's PAYDAY!!!!
pid-1785 thread-139755151517440 (MainThread) Prepared the DB.
pid-1785 thread-139755151517440 (MainThread) Traceback (most recent call last):
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/cli.py", line 28, in payday
pid-1785 thread-139755151517440 (MainThread)     Payday.start().run()
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 133, in run
pid-1785 thread-139755151517440 (MainThread)     self.payin()
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 157, in payin
pid-1785 thread-139755151517440 (MainThread)     holds = self.create_card_holds(cursor)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 427, in create_card_holds
pid-1785 thread-139755151517440 (MainThread)     holds = self.fetch_card_holds(participant_ids)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 407, in fetch_card_holds
pid-1785 thread-139755151517440 (MainThread)     cancel_card_hold(hold)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/exchanges.py", line 236, in cancel_card_hold
pid-1785 thread-139755151517440 (MainThread)     hold.save()
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/balanced/resources.py", line 177, in save
pid-1785 thread-139755151517440 (MainThread)     resp = method(href, data=attrs)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 460, in put
pid-1785 thread-139755151517440 (MainThread)     return self._op(self.interface.put, uri, data=data, **kwargs)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 512, in _op
pid-1785 thread-139755151517440 (MainThread)     handle_error(ex)
pid-1785 thread-139755151517440 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 489, in handle_error
pid-1785 thread-139755151517440 (MainThread)     raise ex
pid-1785 thread-139755151517440 (MainThread) HTTPError: HTTPError(status='Not Found', category_code='not-found', description='<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHM43439a0691de11e484ce02b1203540

Looks like we're picking up an old card hold or something?

@chadwhitacre
Copy link
Contributor Author

I have about 30 minutes before I have to leave to pick up @clone1018 @seanlinsley.

@chadwhitacre
Copy link
Contributor Author

So what's the URL we tried to hit and why? And why is it 404?

@chadwhitacre
Copy link
Contributor Author

So CardHold.query.filter(CardHold.f.meta.state == 'new') returned something. What? Why?

@chadwhitacre
Copy link
Contributor Author

$ heroku run python
>>> from gratipay import wireup
>>> wireup.billing(wireup.env())
>>> from balanced import CardHold
>>> holds = list(CardHold.query.filter(CardHold.f.meta.state == 'new'))
>>> len(holds)
568

@chadwhitacre
Copy link
Contributor Author

All of these holds are from last week, and are all status='failed':

>>> list(set([h.created_at[:10] for h in holds]))
['2014-12-25']
>>> list(set([h.status for h in holds]))
['failed']
>>>

@chadwhitacre
Copy link
Contributor Author

Some were updated this week. Presumably those before which ever one was 404.

>>> list(set([h.updated_at[:10] for h in holds]))
['2015-01-01', '2014-12-25']
>>>

@chadwhitacre
Copy link
Contributor Author

At this point I'm in a rush. I say we hotpatch to return silently if canceling a hold 404s.

@chadwhitacre
Copy link
Contributor Author

>>> updated = [h.updated_at[:10] for h in holds]
>>> updated.count('2015-01-01')
2
>>> updated.count('2014-12-25')
566
>>>

@chadwhitacre
Copy link
Contributor Author

Sent my brother and dad to pick up @clone1018 and @seanlinsley.

@chadwhitacre
Copy link
Contributor Author

So I'm in a bit less of a rush. :-)

@Changaco
Copy link
Contributor

Changaco commented Jan 1, 2015

The problem is that these holds are marked as failed but they don't have a failure_reason, which is what the fetch_card_holds() uses to detect failure.

>>> list(set([h.failure_reason for h in holds]))
[None]

@chadwhitacre
Copy link
Contributor Author

Hypothesis: this is a regression introduced in #3011.

@chadwhitacre
Copy link
Contributor Author

@Changaco Hypothesis is that the Balanced API changed subtly here?

@Changaco
Copy link
Contributor

Changaco commented Jan 1, 2015

Upstream issue: balanced/balanced-api#461.

@chadwhitacre
Copy link
Contributor Author

Do we perhaps clobber failure_reason somehow when setting state='failed'?

@chadwhitacre
Copy link
Contributor Author

Ah, I see: h.status == 'failed' is core Balanced API, and `h.meta['state'] == 'failed' is Gratipay API.

@chadwhitacre
Copy link
Contributor Author

@Changaco So it seems that we should look for h.status == 'failed' instead of h.failure_reason when propagating to h.meta['state']. Yes?

@chadwhitacre
Copy link
Contributor Author

I'm gonna try that.

@Changaco
Copy link
Contributor

Changaco commented Jan 1, 2015

@whit537 I think we should look for either one.

@chadwhitacre
Copy link
Contributor Author

Rerunning with this patch:

diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py                                    
index 9095491..197f32f 100644                                                                           
--- a/gratipay/billing/payday.py                                                                        
+++ b/gratipay/billing/payday.py                                                                        
@@ -390,7 +390,7 @@ class Payday(object):                                                               
         holds = {}                                                                                     
         for hold in CardHold.query.filter(CardHold.f.meta.state == 'new'):                             
             state = 'new'                                                                              
-            if hold.failure_reason:                                                                    
+            if hold.status == 'failed':                                                                
                 state = 'failed'                                                                       
             elif hold.voided_at:                                                                       
                 state = 'cancelled' 

@chadwhitacre
Copy link
Contributor Author

Though I'm still not satisfied as to why we're seeing this now: balanced/balanced-api#461 is from a year ago.

@chadwhitacre
Copy link
Contributor Author

Why do we have 568 holds left over from last week? Is that normal behavior? Do we have a leak of some kind?

@chadwhitacre
Copy link
Contributor Author

Rerunning ...

@chadwhitacre
Copy link
Contributor Author

pid-2086 thread-140048078632704 (MainThread) Picking up with an existing payday.
pid-2086 thread-140048078632704 (MainThread) Payday started at 2015-01-01 17:47:07.498402+00:00.
pid-2086 thread-140048078632704 (MainThread) Greetings, program! It's PAYDAY!!!!
pid-2086 thread-140048078632704 (MainThread) Prepared the DB.
pid-2086 thread-140048078632704 (MainThread) Traceback (most recent call last):
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/gratipay/cli.py", line 28, in payday
pid-2086 thread-140048078632704 (MainThread)     Payday.start().run()
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 133, in run
pid-2086 thread-140048078632704 (MainThread)     self.payin()
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 157, in payin
pid-2086 thread-140048078632704 (MainThread)     holds = self.create_card_holds(cursor)
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 427, in create_card_holds
pid-2086 thread-140048078632704 (MainThread)     holds = self.fetch_card_holds(participant_ids)
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 401, in fetch_card_holds
pid-2086 thread-140048078632704 (MainThread)     hold.save()
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/balanced/resources.py", line 177, in save
pid-2086 thread-140048078632704 (MainThread)     resp = method(href, data=attrs)
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 460, in put
pid-2086 thread-140048078632704 (MainThread)     return self._op(self.interface.put, uri, data=data, **kwargs)
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 512, in _op
pid-2086 thread-140048078632704 (MainThread)     handle_error(ex)
pid-2086 thread-140048078632704 (MainThread)   File "/home/whit537/gratipay.com/env/lib/python2.7/site-packages/wac.py", line 489, in handle_error
pid-2086 thread-140048078632704 (MainThread)     raise ex
pid-2086 thread-140048078632704 (MainThread) HTTPError: HTTPError(status='Not Found', category_code='not-found', description='<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHMbc180a8491e811e49dde06429171ffad.', status_code=404, category_type='request', request_id='OHMbc180a8491e811e49dde06429171ffad', response=None)

@chadwhitacre
Copy link
Contributor Author

This time it's in the other hold.save() call.

@chadwhitacre
Copy link
Contributor Author

How the heck are we given a hold from CardHold.query.filter that then is 404 when we turn right around and try to save it?

@Changaco
Copy link
Contributor

Changaco commented Jan 1, 2015

@whit537 I suggest rerunning with fetch_card_holds() bypassed entirely:

--- a/gratipay/billing/payday.py
+++ b/gratipay/billing/payday.py
@@ -424,7 +424,7 @@ class Payday(object):

         # Fetch existing holds
         participant_ids = set(p.id for p in participants)
-        holds = self.fetch_card_holds(participant_ids)
+        holds = {}

         # Create new holds and check amounts of existing ones
         def f(p):

@chadwhitacre
Copy link
Contributor Author

Restarted with ...

diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py                                    
index 9095491..307d128 100644                                                                           
--- a/gratipay/billing/payday.py                                                                        
+++ b/gratipay/billing/payday.py                                                                        
@@ -423,8 +423,8 @@ class Payday(object):                                                               
             return {}                                                                                  

         # Fetch existing holds                                                                         
-        participant_ids = set(p.id for p in participants)                                              
-        holds = self.fetch_card_holds(participant_ids)                                                 
+        #participant_ids = set(p.id for p in participants)                                             
+        holds = {} # self.fetch_card_holds(participant_ids)                                            

         # Create new holds and check amounts of existing ones                                          
         def f(p):

@chadwhitacre
Copy link
Contributor Author

Script ran for 11 minutes (0:11:06.399468).

@chadwhitacre
Copy link
Contributor Author

@chadwhitacre
Copy link
Contributor Author

Logs downloaded and uploaded. Droplet destroyed.

@chadwhitacre
Copy link
Contributor Author

MassPay done and posted back for 76 users.

@chadwhitacre
Copy link
Contributor Author

Escrow shuffled.

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

2 participants