[SERVER-13750] ConvertToCapped on empty collection aborts after invariant() failure Created: 25/Apr/14  Updated: 11/Mar/15  Resolved: 28/Apr/14

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: 2.6.1
Fix Version/s: 2.6.2, 2.7.0

Type: Bug Priority: Major - P3
Reporter: Michael Grundy Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-15282 Collection is not replicated to the s... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   
Issue Status as of Jun 09, 2014

ISSUE SUMMARY
A bug in the convertToCapped command causes the server to abort with an assertion failure if the collection does not exist.

USER IMPACT
Server defensively quits when hitting the assertion, which can affect replica set quorum and in the worst case availability of the replica set.

WORKAROUNDS
Check first if a collection exists before running the convertToCapped command.

AFFECTED VERSIONS
Versions 2.6.0 and 2.6.1 are affected by this issue.

FIX VERSION
The fix is included in the 2.6.2 production release.

RESOLUTION DETAILS
We now check if the collection exists before executing the command.

Original description

Run convertToCapped on empty collection:

db.runCommand({convertToCapped: 'a.a', size: 4096});

and mongod will abort

***aborting after invariant() failure
 
 
2014-04-25T21:22:02.844+0000 [conn11] SEVERE: Got signal: 6 (Aborted).
Backtrace:0xf81006 0xf80de0 0x7fc6fa242920 0x7fc6fa2428a5 0x7fc6fa244085 0xf1802b 0xab9e2f 0x9077ab 0x905e7d 0x9b4174 0x9b5c25 0x9b645e 0xc4da55 0xac964e 0xace300 0x7bae2f 0xf3f189 0x7fc6fb59c851 0x7fc6fa2f76dd 
 mongod(mongo::printStackTrace(std::basic_ostream<char, std::char_traits<char> >&)+0x26) [0xf81006]
 mongod() [0xf80de0]
 /lib64/libc.so.6(+0x32920) [0x7fc6fa242920]
 /lib64/libc.so.6(gsignal+0x35) [0x7fc6fa2428a5]
 /lib64/libc.so.6(abort+0x175) [0x7fc6fa244085]
 mongod(mongo::invariantFailed(char const*, char const*, unsigned int)+0x1eb) [0xf1802b]
 mongod() [0xab9e2f]
 mongod(mongo::CmdConvertToCapped::stopIndexBuilds(mongo::Database*, mongo::BSONObj const&)+0x10b) [0x9077ab]
 mongod(mongo::CmdConvertToCapped::run(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mongo::BSONObj&, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, mongo::BSONObjBuilder&, bool)+0x7d) [0x905e7d]
 mongod(mongo::_execCommand(mongo::Command*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, mongo::BSONObj&, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, mongo::BSONObjBuilder&, bool)+0x34) [0x9b4174]
 mongod(mongo::Command::execCommand(mongo::Command*, mongo::Client&, int, char const*, mongo::BSONObj&, mongo::BSONObjBuilder&, bool)+0xfa5) [0x9b5c25]
 mongod(mongo::_runCommands(char const*, mongo::BSONObj&, mongo::_BufBuilder<mongo::TrivialAllocator>&, mongo::BSONObjBuilder&, bool, int)+0x2be) [0x9b645e]
 mongod(mongo::newRunQuery(mongo::Message&, mongo::QueryMessage&, mongo::CurOp&, mongo::Message&)+0xa55) [0xc4da55]
 mongod() [0xac964e]
 mongod(mongo::assembleResponse(mongo::Message&, mongo::DbResponse&, mongo::HostAndPort const&)+0x4b0) [0xace300]
 mongod(mongo::MyMessageHandler::process(mongo::Message&, mongo::AbstractMessagingPort*, mongo::LastError*)+0xef) [0x7bae2f]
 mongod(mongo::PortMessageServer::handleIncomingMsg(void*)+0x5a9) [0xf3f189]
 /lib64/libpthread.so.0(+0x7851) [0x7fc6fb59c851]
 /lib64/libc.so.6(clone+0x6d) [0x7fc6fa2f76dd]

(via mongod-user list)



 Comments   
Comment by Githook User [ 15/May/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-13750 prevent invariant failure when ConvertToCappeding a nonexistent collection
(cherry picked from commit ff276366a823fdbd73be5594244b4bdb4e63e1a0)
Branch: v2.6
https://github.com/mongodb/mongo/commit/0661a4fa335f200b07c2a6afa6e5d0922bae60d6

Comment by Githook User [ 28/Apr/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-13750 prevent invariant failure when ConvertToCappeding a nonexistent collection
Branch: master
https://github.com/mongodb/mongo/commit/ff276366a823fdbd73be5594244b4bdb4e63e1a0

Generated at Thu Feb 08 03:32:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.