Skip to content

Commit 446c101

Browse files
author
Erdenezul Batmunkh
committed
dont call ensure_indexes on slave #1338
1 parent 3654591 commit 446c101

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mongoengine/document.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ def _get_collection(cls):
195195

196196
# Ensure indexes on the collection unless auto_create_index was
197197
# set to False.
198-
if cls._meta.get('auto_create_index', True):
198+
# Also there is no need to ensure indexes on slave.
199+
if cls._meta.get('auto_create_index', True) and\
200+
db.client.is_primary:
199201
cls.ensure_indexes()
200202

201203
return cls._collection

0 commit comments

Comments
 (0)