Skip to content

Commit 9ea03a7

Browse files
committed
Prevent exceptions in check_quota from killing a write
Since the quota has already been 'checked' we shouldn't let the generation of informational statistics kill the write
1 parent d8a1ba5 commit 9ea03a7

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Bugfix: #450 fix error in chunkstore delete when chunk range produces empty df
66
* Bugfix: #442 fix incorrect segment values in multi segment chunks in chunkstore
77
* Feature: #457 enchances fix for #442 via segment_id_repair tool
8+
* Bugfix: #385 exceptions during quota statistics no longer kill a write
89

910
### 1.54 (2017-10-18)
1011
* Bugfix: #440 Fix read empty MultiIndex+tz Series

arctic/arctic.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -495,23 +495,26 @@ def to_gigabytes(bytes_):
495495
to_gigabytes(self.quota)))
496496

497497
# Quota not exceeded, print an informational message and return
498-
avg_size = size // count if count > 1 else 100 * 1024
499-
remaining = self.quota - size
500-
remaining_count = remaining / avg_size
501-
if remaining_count < 100 or float(remaining) / self.quota < 0.1:
502-
logger.warning("Mongo Quota: %s %.3f / %.0f GB used" % (
503-
'.'.join([self.database_name, self.library]),
504-
to_gigabytes(size),
505-
to_gigabytes(self.quota)))
506-
else:
507-
logger.info("Mongo Quota: %s %.3f / %.0f GB used" % (
508-
'.'.join([self.database_name, self.library]),
509-
to_gigabytes(size),
510-
to_gigabytes(self.quota)))
511-
512-
# Set-up a timer to prevent us for checking for a few writes.
513-
# This will check every average half-life
514-
self.quota_countdown = int(max(remaining_count // 2, 1))
498+
try:
499+
avg_size = size // count if count > 1 else 100 * 1024
500+
remaining = self.quota - size
501+
remaining_count = remaining / avg_size
502+
if remaining_count < 100 or float(remaining) / self.quota < 0.1:
503+
logger.warning("Mongo Quota: %s %.3f / %.0f GB used" % (
504+
'.'.join([self.database_name, self.library]),
505+
to_gigabytes(size),
506+
to_gigabytes(self.quota)))
507+
else:
508+
logger.info("Mongo Quota: %s %.3f / %.0f GB used" % (
509+
'.'.join([self.database_name, self.library]),
510+
to_gigabytes(size),
511+
to_gigabytes(self.quota)))
512+
513+
# Set-up a timer to prevent us for checking for a few writes.
514+
# This will check every average half-life
515+
self.quota_countdown = int(max(remaining_count // 2, 1))
516+
except Exception as e:
517+
logger.warning("Encountered an exception while calculating quota statistics: %s" % str(e))
515518

516519
def get_library_type(self):
517520
return self.get_library_metadata(ArcticLibraryBinding.TYPE_FIELD)

0 commit comments

Comments
 (0)