From aaa6f50b92e5dad94c351fd5efb8145a98174b87 Mon Sep 17 00:00:00 2001 From: shashank khare Date: Mon, 29 Apr 2019 22:59:33 +0100 Subject: [PATCH] Add details to bulk write failures --- arctic/store/_ndarray_store.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arctic/store/_ndarray_store.py b/arctic/store/_ndarray_store.py index 569dc254b584d..d71dc9aa1fedb 100644 --- a/arctic/store/_ndarray_store.py +++ b/arctic/store/_ndarray_store.py @@ -5,7 +5,7 @@ import numpy as np import pymongo from bson.binary import Binary -from pymongo.errors import OperationFailure, DuplicateKeyError +from pymongo.errors import OperationFailure, DuplicateKeyError, BulkWriteError from six.moves import xrange from ._version_store_utils import checksum, version_base_or_id, _fast_check_corruption @@ -699,7 +699,11 @@ def _do_write(self, collection, version, symbol, item, previous_version, segment # This helps with performance as we update as less documents as necessary if bulk: - collection.bulk_write(bulk, ordered=False) + try: + collection.bulk_write(bulk, ordered=False) + except BulkWriteError as bwe: + logger.error("Bulk write failed with details: %s (Exception: %s)" % (bwe.details, bwe)) + raise segment_index = self._segment_index(item, existing_index=existing_index, start=segment_offset, new_segments=segment_index)