Skip to content

Commit 0c01926

Browse files
committed
create indexes in background, to not prevent startup
1 parent 299766f commit 0c01926

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

file_catalog/mongo.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ def __init__(self, host=None, port=None, authSource=None, username=None, passwor
3232
authSource=authSource,
3333
username=username, password=password).file_catalog
3434

35-
self.client.files.create_index('uuid', unique=True)
36-
self.client.files.create_index('logical_name', unique=True)
37-
self.client.files.create_index([('logical_name',pymongo.HASHED)])
38-
self.client.files.create_index('locations', unique=True)
39-
self.client.files.create_index([('locations.site',pymongo.DESCENDING),('locations.path',pymongo.DESCENDING)])
40-
self.client.files.create_index('locations.archive')
41-
self.client.files.create_index('create_date')
42-
self.client.files.create_index('content_status')
43-
self.client.files.create_index('processing_level', sparse=True)
44-
self.client.files.create_index('run_number', sparse=True)
45-
self.client.files.create_index('start_datetime', sparse=True)
46-
self.client.files.create_index('end_datetime', sparse=True)
47-
self.client.files.create_index('offline_processing_metadata.first_event', sparse=True)
48-
self.client.files.create_index('offline_processing_metadata.last_event', sparse=True)
49-
self.client.files.create_index('offline.season', sparse=True)
50-
self.client.files.create_index('iceprod.dataset', sparse=True)
51-
52-
self.client.collections.create_index('uuid', unique=True)
53-
self.client.collections.create_index('collection_name')
54-
self.client.collections.create_index('owner')
55-
56-
self.client.snapshots.create_index('uuid', unique=True)
57-
self.client.snapshots.create_index('collection_id')
58-
self.client.snapshots.create_index('owner')
35+
self.client.files.create_index('uuid', unique=True, background=True)
36+
self.client.files.create_index('logical_name', unique=True, background=True)
37+
self.client.files.create_index([('logical_name',pymongo.HASHED)], background=True)
38+
self.client.files.create_index('locations', unique=True, background=True)
39+
self.client.files.create_index([('locations.site',pymongo.DESCENDING),('locations.path',pymongo.DESCENDING)], background=True)
40+
self.client.files.create_index('locations.archive', background=True)
41+
self.client.files.create_index('create_date', background=True)
42+
self.client.files.create_index('content_status', background=True)
43+
self.client.files.create_index('processing_level', sparse=True, background=True)
44+
self.client.files.create_index('run_number', sparse=True, background=True)
45+
self.client.files.create_index('start_datetime', sparse=True, background=True)
46+
self.client.files.create_index('end_datetime', sparse=True, background=True)
47+
self.client.files.create_index('offline_processing_metadata.first_event', sparse=True, background=True)
48+
self.client.files.create_index('offline_processing_metadata.last_event', sparse=True, background=True)
49+
self.client.files.create_index('offline_processing_metadata.season', sparse=True, background=True)
50+
self.client.files.create_index('iceprod.dataset', sparse=True, background=True)
51+
52+
self.client.collections.create_index('uuid', unique=True, background=True)
53+
self.client.collections.create_index('collection_name', background=True)
54+
self.client.collections.create_index('owner', background=True)
55+
56+
self.client.snapshots.create_index('uuid', unique=True, background=True)
57+
self.client.snapshots.create_index('collection_id', background=True)
58+
self.client.snapshots.create_index('owner', background=True)
5959

6060
self.executor = ThreadPoolExecutor(max_workers=10)
6161
logger.info('done setting up Mongo')

0 commit comments

Comments
 (0)