C100DBA MongoDB DBA认证考题讲解 FsyncLock() command

单选题

Which of the following is true after the fsyncLock() command is run ( before fsyncUnlock() is run)?

  1. Writes to the database may succeed
  2. Writes to the database may return an error.
  3. All reads on the database will return an error
  4. Reads on the database may succeed
  5. Profiling will continue .

 

db.fsyncLock()

Forces the mongod to flush all pending write operations to the disk and locks the entire mongodinstance to prevent additional writes until the user releases the lock with the db.fsyncUnlock()command. db.fsyncLock() is an administrative command.

 

 

https://docs.mongodb.org/v3.0/reference/method/db.fsyncLock/

 

db.fsyncLock()应当是锁定 mongod实例使其不再接受任何写操作,

 

 

MongoDB shell version: 2.6.7

connecting to: test

> db.fsyncLock();

{

“info” : “now locked against writes, use db.fsyncUnlock() to unlock”,

“seeAlso” : “http://dochub.mongodb.org/core/fsynccommand”,

“ok” : 1

}

 

 

 

 

 

 

在其他session中操作读和写均被阻塞

 

 

> db.dbdao.find();

> db.dbdao.insert({A:1});

 

 

 

文档中的解释是:db.fsyncLock() may block reads, including those necessary to verify authentication. Such reads are necessary to establish new connections to a mongod that enforces authorization checks.

所以db.fsyncLock() 后可能会阻塞读,但不是100%阻塞。  注意这里仅仅是阻塞 所以不会有报错,所以  return an error.的答案全错。

 

所以 答案D Reads on the database may succeed  正确。

 

 

 

Comment

*

沪ICP备14014813号-2

沪公网安备 31010802001379号