Found by https://github.com/mongodb/mongo-python-driver/pull/363.
>>> client.db.test.ensure_index("key1") u'key1_1' >>> client._MongoClient__index_cache {u'db': {u'test': {u'key1_1': datetime.datetime(2018, 7, 24, 20, 41, 15, 406487)}}} >>> client.db.test.ensure_index("key2") u'key2_1' >>> client._MongoClient__index_cache {u'db': {u'test': {u'key2_1': datetime.datetime(2018, 7, 24, 20, 41, 29, 681537)}}}
This bug was introduced in PyMongo 3.0 (by this commit).
Note this has no effect on correctness. The only side effect is that an application that calls ensure_index on different indexes multiple times (on the same database) will unnecessarily send multiple createIndex commands to the server.