Skip to content

Commit 05aef6d

Browse files
author
Joe Bennett
committed
#27345 moved clock discrepancy handling to a constructor option 'drift'
1 parent 84b7e96 commit 05aef6d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

components/lock.rst

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

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

241-
=========== ========= ====================================
242-
Option Default Description
243-
=========== ========= ====================================
244-
database The name of the database [Mandatory]
245-
collection ``lock`` The name of the collection
246-
=========== ========= ====================================
241+
========== ======== =============================================================
242+
Option Default Description
243+
========== ======== =============================================================
244+
database The name of the database [Mandatory]
245+
collection ``lock`` The name of the collection
246+
drift ``0.0`` Seconds to extend expiries to account for clock discrepancies
247+
========== ======== =============================================================
247248

248249
.. _lock-store-redis:
249250

@@ -469,24 +470,27 @@ inclusive of structural overhead.
469470

470471
For more details see: https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit
471472

473+
Please be aware, MongoDbStore relies on clock syncronisation between
474+
the application nodes and mongodb servers. The ``drift`` option can be used
475+
to extend expiries to account for clock discrepancies.
476+
472477
A TTL index MUST BE used on MongoDB 2.2+ to automatically clean up expired locks.
473-
Please be aware any clock drift between the application and mongo servers could
474-
cause locks to be released prematurely. To account for any drift;
475-
expireAfterSeconds can be set to a value higher than 0. The logical expiry of
476-
locks is handled by the application so setting a higher ``expireAfterSeconds``
477-
has no effect other than keeping stale data for longer.
478478

479479
Such an index can for example look like this:
480480

481481
.. code-block:: javascript
482482
483483
db.lock.ensureIndex(
484484
{ "expires_at": 1 },
485-
{ "expireAfterSeconds": 60 }
485+
{ "expireAfterSeconds": 0 }
486486
)
487487
488488
For more details see: http://docs.mongodb.org/manual/tutorial/expire-data/
489489

490+
writeConcern, readConcern and readPreference are not specified by MongoDbStore
491+
meaning the collection's settings will take effect.
492+
For more details see: https://docs.mongodb.com/manual/applications/replication/
493+
490494
RedisStore
491495
~~~~~~~~~~
492496

0 commit comments

Comments
 (0)