Skip to content

Commit 8ab6b63

Browse files
author
Joe Bennett
committed
#27345 removed drift option in favour or recommending setting TTL higher
2 parents 6b49f2d + 05aef6d commit 8ab6b63

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

components/lock.rst

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,13 @@ This store does not support blocking, and expects a TTL to avoid stalled locks::
239239

240240
The ``MongoDbStore`` takes the following ``$options``:
241241

242-
=============== =============== ===================================================================================
243-
Option Default Description
244-
=============== =============== ===================================================================================
245-
database The name of the database [Mandatory]
246-
collection ``lock`` The name of the collection
247-
resource_field ``_id`` The field name for storing the lock id **MUST be uniquely indexed if you chage it**
248-
token_field ``token`` The field name for storing the lock token
249-
acquired_field ``acquired_at`` The field name for storing the acquisition timestamp
250-
expiry_field ``expires_at`` The field name for storing the expiry-timestamp
251-
=============== =============== ===================================================================================
242+
========== ========= =============================================================
243+
Option Default Description
244+
========== ========= =============================================================
245+
database The name of the database [Mandatory]
246+
collection ``lock`` The name of the collection
247+
initialTtl ``300.0`` The expiration delay of locks in seconds
248+
========== ========= =============================================================
252249

253250
.. _lock-store-redis:
254251

@@ -469,23 +466,35 @@ method uses the Memcached's ``flush()`` method which purges and removes everythi
469466
MongoDbStore
470467
~~~~~~~~~~~~
471468

472-
The MongoDbStore relies on a unique index on the ``<resource_field>``. By default
473-
this is ``_id`` which already has a unique index being the collection identifier.
474-
It is strongly recommended to leave this as is. If you do need to change the
475-
``<resource_field>`` you **MUST** ensure you place a unique index on your filed.
469+
An indexed field's value in MongoDB can be a maximum of 1024 bytes in length
470+
inclusive of structural overhead.
471+
472+
For more details see: https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit
473+
474+
.. caution::
475+
476+
This store relies on all client and server nodes to have
477+
synchronized clocks for lock expiry to occur at the correct time.
478+
To ensure locks don't expire prematurely; the ttl's should be set with enough
479+
extra time to account for any clock drift between nodes.
480+
481+
A TTL index MUST BE used on MongoDB 2.2+ to automatically clean up expired locks.
476482

477-
A TTL index can be used on MongoDB 2.2+ to cleanup expired locks automatically.
478483
Such an index can for example look like this:
479484

480485
.. code-block:: javascript
481486
482-
db.<lock-collection>.ensureIndex(
483-
{ "<expiry-field>": 1 },
487+
db.lock.ensureIndex(
488+
{ "expires_at": 1 },
484489
{ "expireAfterSeconds": 0 }
485490
)
486491
487492
For more details see: http://docs.mongodb.org/manual/tutorial/expire-data/
488493

494+
writeConcern, readConcern and readPreference are not specified by MongoDbStore
495+
meaning the collection's settings will take effect.
496+
For more details see: https://docs.mongodb.com/manual/applications/replication/
497+
489498
RedisStore
490499
~~~~~~~~~~
491500

0 commit comments

Comments
 (0)