RUBY-184 Connection#locked?
This commit is contained in:
parent
2ed0adbbc6
commit
7ad280c2cb
|
@ -222,6 +222,13 @@ module Mongo
|
|||
self['admin'].command(cmd)
|
||||
end
|
||||
|
||||
# Is this database locked against writes?
|
||||
#
|
||||
# @return [Boolean]
|
||||
def locked?
|
||||
self['admin']['$cmd.sys.inprog'].find_one['fsyncLock'] == 1
|
||||
end
|
||||
|
||||
# Unlock a previously fsync-locked mongod process.
|
||||
#
|
||||
# @return [BSON::OrderedHash] command response
|
||||
|
|
|
@ -144,7 +144,9 @@ class TestConnection < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_fsync_lock
|
||||
assert !@mongo.locked?
|
||||
@mongo.lock!
|
||||
assert @mongo.locked?
|
||||
assert_equal 1, @mongo['admin']['$cmd.sys.inprog'].find_one['fsyncLock'], "Not fsync-locked"
|
||||
assert_equal "unlock requested", @mongo.unlock!['info']
|
||||
unlocked = false
|
||||
|
@ -158,6 +160,7 @@ class TestConnection < Test::Unit::TestCase
|
|||
counter += 1
|
||||
end
|
||||
end
|
||||
assert !@mongo.locked?
|
||||
assert unlocked, "mongod failed to unlock"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue