fsyncLock() does not stop files touched fs. mongo 3.2.10

28 views
Skip to first unread message

Bullandrock

unread,
Dec 6, 2016, 5:43:01 PM12/6/16
to mongodb-user
Hello

I am wanting to put a lock on a secondary server to do a tar backup of the mongo file system but with the lock inplace, the backup tar process says files have changed. Also using "find -cmin 1" shows this also. 


 mongo --version
MongoDB shell version: 3.2.10

devtest:SECONDARY> use admin
switched to db admin
devtest:SECONDARY> db.fsyncLock()
{
        "info" : "now locked against writes, use db.fsyncUnlock() to unlock",
        "ok" : 1
}

Find files modified a minute or more ago.
:/var/lib/mongo # find -cmin 1
.
./WiredTiger.turtle
./WiredTiger.wt
./diagnostic.data
./diagnostic.data/metrics.interim

If I stop mongo the find command has no result. 

/etc/mongo.conf
storage:
  directoryPerDB: true
  dbPath: /var/lib/mongo
  engine: "wiredTiger"
  wiredTiger:
    engineConfig:
      directoryForIndexes: true
    collectionConfig:
      blockCompressor: snappy
  journal:
    enabled: true

Any help is greatly appreciated.

Kevin Adistambha

unread,
Dec 18, 2016, 8:53:07 PM12/18/16
to mongodb-user

Hi,

You are correct that db.fsyncLock() could be used to lock the database against writes for backup purposes. This is mentioned in Back Up with cp or rsync

However, there are a couple things that may explain what you observed:

  1. The db.fsyncLock() command only locks data files. The diagnostic.data directory contains internal statistics collected by the mongod process for troubleshooting purposes, and doesn’t contain any data.

  2. The cmin parameter is in minutes. Have you waited for at least a minute after issuing the db.fsyncLock() command? From my cursory test, after a minute, the data directory only shows changes in the diagnostic.data directory (which is expected, since the mongod process is still running despite the data files being locked).

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages