diff --git a/log_shipper.py b/log_shipper.py index 5a23fde..847fdd9 100755 --- a/log_shipper.py +++ b/log_shipper.py @@ -202,13 +202,15 @@ async def uploader(coll, queue): if not messages: continue try: - # TODO: Don't retry submitting messages commit by bulk insert above then = time() await coll.insert_many(messages) histogram_database_operation_latency.labels("insert-many").observe(time() - then) except pymongo.errors.ServerSelectionTimeoutError: counter_bulk_insertions.labels("timed-out").inc() continue + except pymongo.errors.NotPrimaryError: + counter_bulk_insertions.labels("not-primary").inc() + continue except pymongo.errors.BulkWriteError as e: counter_bulk_insertions.labels("retried-as-singles").inc() j = "%s.%s" % (e.__class__.__module__, e.__class__.__name__)