From 64cf4ee5dcbfe9ace7a933aaf92561fd15455eef Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 2 Jul 2016 08:41:29 -0700 Subject: [PATCH 1/2] Fixes to the production code made directly on the server --- bin/remotePush.py | 5 +---- emission/net/usercache/builtin_usercache_handler.py | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/remotePush.py b/bin/remotePush.py index 4f9afa10d..cd3a497b4 100644 --- a/bin/remotePush.py +++ b/bin/remotePush.py @@ -3,13 +3,10 @@ config_data = json.load(open('conf/net/ext_service/parse.json')) -interval = sys.argv[1] +interval = "interval_%s" % sys.argv[1] print "pushing for interval %s" % interval silent_push_msg = { - "where": { - "deviceType": "ios" - }, "channels": [ interval ], diff --git a/emission/net/usercache/builtin_usercache_handler.py b/emission/net/usercache/builtin_usercache_handler.py index c236ccf93..f063e98ba 100644 --- a/emission/net/usercache/builtin_usercache_handler.py +++ b/emission/net/usercache/builtin_usercache_handler.py @@ -76,7 +76,10 @@ def moveToLongTerm(self): except Exception as e: logging.exception("Backtrace time") logging.warn("Got error %s while saving entry %s -> %s"% (e, entry, unified_entry)) - ts.insert_error(entry_doc) + try: + ts.insert_error(entry_doc) + except pymongo.errors.DuplicateKeyError as e: + logging.info("document already present in error timeseries, skipping since read-only") logging.debug("Deleting all entries for query %s" % time_query) uc.clearProcessedMessages(time_query) esp.mark_usercache_done(self.user_id, last_ts_processed) From 0250e1a283995ec43f6f92f473fc1f5e9766f363 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Sat, 2 Jul 2016 08:41:29 -0700 Subject: [PATCH 2/2] Fixes to the production code made directly on the server - If we are using a channel, we cannot use a where search - If an error has been previous handled, and we get a duplicate error message, we should ignore and continue. This is what we do when we get an error while inserting the original message --- bin/remotePush.py | 5 +---- emission/net/usercache/builtin_usercache_handler.py | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/remotePush.py b/bin/remotePush.py index 4f9afa10d..cd3a497b4 100644 --- a/bin/remotePush.py +++ b/bin/remotePush.py @@ -3,13 +3,10 @@ config_data = json.load(open('conf/net/ext_service/parse.json')) -interval = sys.argv[1] +interval = "interval_%s" % sys.argv[1] print "pushing for interval %s" % interval silent_push_msg = { - "where": { - "deviceType": "ios" - }, "channels": [ interval ], diff --git a/emission/net/usercache/builtin_usercache_handler.py b/emission/net/usercache/builtin_usercache_handler.py index c236ccf93..f063e98ba 100644 --- a/emission/net/usercache/builtin_usercache_handler.py +++ b/emission/net/usercache/builtin_usercache_handler.py @@ -76,7 +76,10 @@ def moveToLongTerm(self): except Exception as e: logging.exception("Backtrace time") logging.warn("Got error %s while saving entry %s -> %s"% (e, entry, unified_entry)) - ts.insert_error(entry_doc) + try: + ts.insert_error(entry_doc) + except pymongo.errors.DuplicateKeyError as e: + logging.info("document already present in error timeseries, skipping since read-only") logging.debug("Deleting all entries for query %s" % time_query) uc.clearProcessedMessages(time_query) esp.mark_usercache_done(self.user_id, last_ts_processed)