From 0c01926735e681b1afd1958b1696ff5a877c3a37 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 10 Jul 2020 11:04:19 -0500 Subject: [PATCH] create indexes in background, to not prevent startup --- file_catalog/mongo.py | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/file_catalog/mongo.py b/file_catalog/mongo.py index 3e3a295..11bc38d 100644 --- a/file_catalog/mongo.py +++ b/file_catalog/mongo.py @@ -32,30 +32,30 @@ def __init__(self, host=None, port=None, authSource=None, username=None, passwor authSource=authSource, username=username, password=password).file_catalog - self.client.files.create_index('uuid', unique=True) - self.client.files.create_index('logical_name', unique=True) - self.client.files.create_index([('logical_name',pymongo.HASHED)]) - self.client.files.create_index('locations', unique=True) - self.client.files.create_index([('locations.site',pymongo.DESCENDING),('locations.path',pymongo.DESCENDING)]) - self.client.files.create_index('locations.archive') - self.client.files.create_index('create_date') - self.client.files.create_index('content_status') - self.client.files.create_index('processing_level', sparse=True) - self.client.files.create_index('run_number', sparse=True) - self.client.files.create_index('start_datetime', sparse=True) - self.client.files.create_index('end_datetime', sparse=True) - self.client.files.create_index('offline_processing_metadata.first_event', sparse=True) - self.client.files.create_index('offline_processing_metadata.last_event', sparse=True) - self.client.files.create_index('offline.season', sparse=True) - self.client.files.create_index('iceprod.dataset', sparse=True) - - self.client.collections.create_index('uuid', unique=True) - self.client.collections.create_index('collection_name') - self.client.collections.create_index('owner') - - self.client.snapshots.create_index('uuid', unique=True) - self.client.snapshots.create_index('collection_id') - self.client.snapshots.create_index('owner') + self.client.files.create_index('uuid', unique=True, background=True) + self.client.files.create_index('logical_name', unique=True, background=True) + self.client.files.create_index([('logical_name',pymongo.HASHED)], background=True) + self.client.files.create_index('locations', unique=True, background=True) + self.client.files.create_index([('locations.site',pymongo.DESCENDING),('locations.path',pymongo.DESCENDING)], background=True) + self.client.files.create_index('locations.archive', background=True) + self.client.files.create_index('create_date', background=True) + self.client.files.create_index('content_status', background=True) + self.client.files.create_index('processing_level', sparse=True, background=True) + self.client.files.create_index('run_number', sparse=True, background=True) + self.client.files.create_index('start_datetime', sparse=True, background=True) + self.client.files.create_index('end_datetime', sparse=True, background=True) + self.client.files.create_index('offline_processing_metadata.first_event', sparse=True, background=True) + self.client.files.create_index('offline_processing_metadata.last_event', sparse=True, background=True) + self.client.files.create_index('offline_processing_metadata.season', sparse=True, background=True) + self.client.files.create_index('iceprod.dataset', sparse=True, background=True) + + self.client.collections.create_index('uuid', unique=True, background=True) + self.client.collections.create_index('collection_name', background=True) + self.client.collections.create_index('owner', background=True) + + self.client.snapshots.create_index('uuid', unique=True, background=True) + self.client.snapshots.create_index('collection_id', background=True) + self.client.snapshots.create_index('owner', background=True) self.executor = ThreadPoolExecutor(max_workers=10) logger.info('done setting up Mongo')