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

run Gratipay 130 #2964

Closed
chadwhitacre opened this issue Nov 27, 2014 · 22 comments
Closed

run Gratipay 130 #2964

chadwhitacre opened this issue Nov 27, 2014 · 22 comments

Comments

@chadwhitacre
Copy link
Contributor

129

@chadwhitacre
Copy link
Contributor Author

Reviewed 36 (26) accounts.

@chadwhitacre
Copy link
Contributor Author

Droplet spun up and updated.

@chadwhitacre
Copy link
Contributor Author

Backup taken and verified.

@chadwhitacre
Copy link
Contributor Author

Script started ... aaaaaaaand it crashed:

pid-1731 thread-140389752571648 (MainThread) Traceback (most recent call last):
pid-1731 thread-140389752571648 (MainThread)   File "/home/whit537/gratipay.com/gratipay/cli.py", line 28, in payday
pid-1731 thread-140389752571648 (MainThread)     Payday.start().run()
pid-1731 thread-140389752571648 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 119, in run
pid-1731 thread-140389752571648 (MainThread)     self.payin()
pid-1731 thread-140389752571648 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 143, in payin
pid-1731 thread-140389752571648 (MainThread)     holds = self.create_card_holds(cursor)
pid-1731 thread-140389752571648 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 404, in create_card_holds
pid-1731 thread-140389752571648 (MainThread)     threaded_map(f, participants)
pid-1731 thread-140389752571648 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 35, in threaded_map
pid-1731 thread-140389752571648 (MainThread)     r = pool.map(func, iterable)
pid-1731 thread-140389752571648 (MainThread)   File "/usr/lib/python2.7/multiprocessing/pool.py", line 227, in map
pid-1731 thread-140389752571648 (MainThread)     return self.map_async(func, iterable, chunksize).get()
pid-1731 thread-140389752571648 (MainThread)   File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
pid-1731 thread-140389752571648 (MainThread)     raise self._value
pid-1731 thread-140389752571648 (MainThread) ProgrammingError: syntax error at or near "G"
pid-1731 thread-140389752571648 (MainThread) LINE 1: G
pid-1731 thread-140389752571648 (MainThread)         ^
pid-1731 thread-140389752571648 (MainThread)

@chadwhitacre
Copy link
Contributor Author

ProgrammingError looks to me like something from Postgres, but the multithreading masks the actual exception.

@chadwhitacre
Copy link
Contributor Author

I mean, WTF? G!?

@chadwhitacre
Copy link
Contributor Author

Yeah, ack in env/lib shows ProgrammingError to be from psycopg2.

@chadwhitacre
Copy link
Contributor Author

Since we didn't make it out of the card holds loop, we should be able to rerun without any modifications (we should be able to rerun without modifications no matter when we crash, but that's another story).

@Changaco
Copy link
Contributor

I have a hack for the tracebacks in threaded_map that I didn't put in the original PR, for a reason that I can't remember:

import sys
import traceback

def threaded_map(func, iterable, threads=5):
    pool = ThreadPool(threads)
    def g(*a, **kw):
        try:
            return func(*a, **kw)
        except Exception:
            raise sys.exc_info()[0](traceback.format_exc())
    r = pool.map(g, iterable)
    pool.close()
    pool.join()
    return r

@chadwhitacre
Copy link
Contributor Author

@Changaco We might also consider using tell_sentry at that point. It's helpful to be able to browse the context for all the stack frames, e.g.

@chadwhitacre
Copy link
Contributor Author

At this point that info is lost and I think our options are to try to debug this blind or simply rerun.

@chadwhitacre
Copy link
Contributor Author

@Changaco Rerunning with your hack for now ...

@chadwhitacre
Copy link
Contributor Author

diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py
index 0063642..28525e8 100644
--- a/gratipay/billing/payday.py
+++ b/gratipay/billing/payday.py
@@ -32,7 +32,12 @@ with open('fake_payday.sql') as f:

 def threaded_map(func, iterable, threads=5):
     pool = ThreadPool(threads)
-    r = pool.map(func, iterable)
+    def g(*a, **kw):
+        try:
+            return func(*a, **kw)
+        except Exception:
+            raise sys.exc_info()[0](traceback.format_exc())
+    r = pool.map(g, iterable)
     pool.close()
     pool.join()
     return r

@chadwhitacre
Copy link
Contributor Author

Oops. :-)

pid-1936 thread-140001328940800 (MainThread) Traceback (most recent call last):
pid-1936 thread-140001328940800 (MainThread)   File "/home/whit537/gratipay.com/gratipay/cli.py", line 28, in payday
pid-1936 thread-140001328940800 (MainThread)     Payday.start().run()
pid-1936 thread-140001328940800 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 124, in run
pid-1936 thread-140001328940800 (MainThread)     self.payin()
pid-1936 thread-140001328940800 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 148, in payin
pid-1936 thread-140001328940800 (MainThread)     holds = self.create_card_holds(cursor)
pid-1936 thread-140001328940800 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 409, in create_card_holds
pid-1936 thread-140001328940800 (MainThread)     threaded_map(f, participants)
pid-1936 thread-140001328940800 (MainThread)   File "/home/whit537/gratipay.com/gratipay/billing/payday.py", line 40, in threaded_map
pid-1936 thread-140001328940800 (MainThread)     r = pool.map(g, iterable)
pid-1936 thread-140001328940800 (MainThread)   File "/usr/lib/python2.7/multiprocessing/pool.py", line 227, in map
pid-1936 thread-140001328940800 (MainThread)     return self.map_async(func, iterable, chunksize).get()
pid-1936 thread-140001328940800 (MainThread)   File "/usr/lib/python2.7/multiprocessing/pool.py", line 528, in get
pid-1936 thread-140001328940800 (MainThread)     raise self._value
pid-1936 thread-140001328940800 (MainThread) NameError: global name 'sys' is not defined

@chadwhitacre
Copy link
Contributor Author

diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py
index 0063642..95cad68 100644
--- a/gratipay/billing/payday.py
+++ b/gratipay/billing/payday.py
@@ -12,6 +12,8 @@ immediately affect the participant's balance.
 from __future__ import unicode_literals

 import itertools
+import sys
+import traceback
 from multiprocessing.dummy import Pool as ThreadPool

 from balanced import CardHold
@@ -32,7 +34,12 @@ with open('fake_payday.sql') as f:

 def threaded_map(func, iterable, threads=5):
     pool = ThreadPool(threads)
-    r = pool.map(func, iterable)
+    def g(*a, **kw):
+        try:
+            return func(*a, **kw)
+        except Exception:
+            raise sys.exc_info()[0](traceback.format_exc())
+    r = pool.map(g, iterable)
     pool.close()
     pool.join()
     return r

@chadwhitacre
Copy link
Contributor Author

Looks like it's running fine now. Kinda bummed that we apparently hit a second exception but my bad patch didn't catch it. :-(

@chadwhitacre
Copy link
Contributor Author

Script ran for 10 minutes (0:10:18.257751).

@chadwhitacre
Copy link
Contributor Author

Wow, lost another big giver this week. We're almost back to $10,000!

@chadwhitacre
Copy link
Contributor Author

@chadwhitacre
Copy link
Contributor Author

Log downloaded and droplet destroyed.

@chadwhitacre
Copy link
Contributor Author

MassPay done and posted back for 73 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