Skip to content

Commit 9351cde

Browse files
author
Andrew Leung
committed
migrating information from wiki
1 parent 2a55dd1 commit 9351cde

File tree

2 files changed

+56
-23
lines changed

2 files changed

+56
-23
lines changed

source/reference/commands.txt

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,44 +1347,77 @@ Administration
13471347

13481348
.. dbcommand:: fsync
13491349

1350-
:dbcommand:`fsync` is an *administrative command* that forces the
1351-
:program:`mongod` process to flush all pending writes to the data
1352-
files. :program:`mongod` is always writing data to disk, and
1353-
guarantees that it will write all data to disk within the
1354-
:setting:`syncdelay` interval, which is 60 seconds by default. You
1355-
do not need to run :dbcommand:`fsync` in the course of normal
1356-
operations. The primary use of :dbcommand:`fsync` is to flush and
1357-
lock the database for backups.
1350+
The :dbcommand:`fsync` command forces the :program:`mongod` process
1351+
to flush all pending writes to the storage layer. :program:`mongod`
1352+
is always writing data to the storage layer within the
1353+
:setting:`syncdelay` interval, which is 60 seconds by default.
13581354

1359-
The :dbcommand:`fsync` operation blocks all other write operations
1360-
for a while it runs. To toggle a write-lock using
1361-
:dbcommand:`fsync`, add a lock argument, as follows:
1355+
.. code-block:: javascript
1356+
1357+
{ fsync: 1 }
1358+
1359+
The :dbcommand:`fsync` operation is synchronous by default, to run
1360+
:dbcommand:`fsync` asynchronously, the command is:
1361+
1362+
.. code-block:: javascript
1363+
1364+
{ fsync: 1, async: true }
1365+
1366+
Database backups can be performed using :dbcommand:`fsync` with the
1367+
``lock`` operator, know as fsync lock. This will flush all data to
1368+
the data storage layer and block all write operations until the
1369+
database is unlocked. To set fsync lock for a database, use the
1370+
following command:
13621371

13631372
.. code-block:: javascript
13641373

13651374
{ fsync: 1, lock: true }
13661375

1367-
This will sync the data files and lock the database against writes. Later,
1368-
you must run the following query to unlock the database:
1376+
.. note::
1377+
1378+
Read operations are allowed on a database that is fsync locked
1379+
until the next write operation, which will cause read operations
1380+
to be blocked. The database will then be locked until it is
1381+
unlocked.
1382+
1383+
To check on the current state of the fsync lock, use
1384+
:func:`db.currentOp()`.
1385+
1386+
To unlock the database, make a request for an unlock using the
1387+
following command:
13691388

13701389
.. code-block:: javascript
13711390

13721391
db.getSiblingDB("admin").$cmd.sys.unlock.findOne();
13731392

1374-
In the shell, you may use the following helpers to simplify
1375-
the process:
1393+
.. versionadded:: 1.9.0
1394+
The :func:`db.fsyncLock()` and :func:`db.fsyncUnlock()`
1395+
helpers in the shell.
1396+
1397+
In the shell, you may use the following shell helpers to simplify the
1398+
:dbcommand:`fsync` lock and unlock process:
13761399

13771400
.. code-block:: javascript
13781401

13791402
db.fsyncLock();
13801403
db.fsyncUnlock();
13811404

1382-
.. versionadded:: 1.9.0
1383-
The :func:`db.fsyncLock()` and :func:`db.fsyncUnlock()`
1384-
helpers in the shell.
1405+
.. note::
1406+
1407+
:dbcommand:`fsync` lock is only possible on individual shards of
1408+
a shard cluster, not on the entire shard cluster. To backup an
1409+
entire shard cluster, please read: :ref:`Shard cluster
1410+
considerations for backups
1411+
<backups-with-sharding-and-replication>`
1412+
1413+
.. note::
1414+
1415+
With :term:`journaling <journal>` enabled, there are :ref:`other
1416+
methods<backup-with-journaling>` to create a backup.
13851417

13861418
.. include:: /includes/note-disable-profiling-fsynclock.rst
13871419

1420+
13881421
.. dbcommand:: dropDatabase
13891422

13901423
The :dbcommand:`dropDatabase` command drops a database, deleting

source/reference/configuration-options.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,11 @@ Settings
510510

511511
*Default:* 60
512512

513-
This setting controls the maximum number of seconds between disk
514-
syncs. While :program:`mongod` is always writing data to disk, this
515-
setting controls the maximum guaranteed interval between a
516-
successful write operation and the next time the database flushes
517-
data to disk.
513+
This setting controls the maximum number of seconds between flushes
514+
of pending writes to disk. While :program:`mongod` is always
515+
writing data to disk, this setting controls the maximum guaranteed
516+
interval between a successful write operation and the next time the
517+
database flushes data to disk.
518518

519519
In many cases, the actual interval between write operations and
520520
disk flushes is much shorter than the value

0 commit comments

Comments
 (0)