[SERVER-9502] Using regex in _id breaks replication Created: 29/Apr/13  Updated: 26/Jan/24  Resolved: 15/May/13

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 2.4.3
Fix Version/s: 2.4.4, 2.5.0

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Eric Milkie
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-16339 Updating by _id field with a regex br... Closed
related to SERVER-16359 Upserting a document where the _id fi... Closed
related to SERVER-12536 Only allow shard key types which can ... Backlog
related to DOCS-1459 Warn users not to use regex in _id Closed
is related to SERVER-21863 map/reduce permits documents larger t... Closed
Operating System: ALL
Participants:

 Description   

Steps to reproduce:

db.user.insert({ _id: 'DA' })
db.user.insert({ _id: /^D/ })

And watch secondaries exit with:

 m31001| Mon Apr 29 11:50:07.883 [repl writer worker 1] ERROR: writer worker caught exception: cannot change _id of a document old:{ _id: "DA" } new:{ _id: /^D/ } on: { ts: Timestamp 1367250607000|1, h: 6712383419440993268, v: 2, op: "i", ns: "test.user", o: { _id: /^D/ } }
 m31001| Mon Apr 29 11:50:07.883 [repl writer worker 1]   Fatal Assertion 16360
 m31001| 0x1012d732b 0x1012b1e07 0x1011cc7cf 0x1012b9368 0x101309c25 0x7fff92e9b8bf 0x7fff92e9eb75 
 m31001|  0   mongod                              0x00000001012d732b _ZN5mongo15printStackTraceERSo + 43
 m31001|  1   mongod                              0x00000001012b1e07 _ZN5mongo13fassertFailedEi + 151
 m31001|  2   mongod                              0x00000001011cc7cf _ZN5mongo7replset14multiSyncApplyERKSt6vectorINS_7BSONObjESaIS2_EEPNS0_8SyncTailE + 271
 m31001|  3   mongod                              0x00000001012b9368 _ZN5mongo10threadpool6Worker4loopEv + 138
 m31001|  4   mongod                              0x0000000101309c25 thread_proxy + 229
 m31001|  5   libsystem_c.dylib                   0x00007fff92e9b8bf _pthread_start + 335
 m31001|  6   libsystem_c.dylib                   0x00007fff92e9eb75 thread_start + 13
 m31001| Mon Apr 29 11:50:07.912 [repl writer worker 1] 
 m31001| 
 m31001| ***aborting after fassert() failure
 m31001| 
 m31001| 
 m31001| Mon Apr 29 11:50:07.912 Got signal: 6 (Abort trap: 6).
 m31001| 
 m31001| Mon Apr 29 11:50:07.914 Backtrace:
 m31001| 0x1012d732b 0x100e6fab1 0x7fff92eefcfa 0 0x7fff92e8ea7a 0x1012b1e45 0x1011cc7cf 0x1012b9368 0x101309c25 0x7fff92e9b8bf 0x7fff92e9eb75 
 m31001|  0   mongod                              0x00000001012d732b _ZN5mongo15printStackTraceERSo + 43
 m31001|  1   mongod                              0x0000000100e6fab1 _ZN5mongo10abruptQuitEi + 225
 m31001|  2   libsystem_c.dylib                   0x00007fff92eefcfa _sigtramp + 26
 m31001|  3   ???                                 0x0000000000000000 0x0 + 0
 m31001|  4   libsystem_c.dylib                   0x00007fff92e8ea7a abort + 143
 m31001|  5   mongod                              0x00000001012b1e45 _ZN5mongo13fassertFailedEi + 213
 m31001|  6   mongod                              0x00000001011cc7cf _ZN5mongo7replset14multiSyncApplyERKSt6vectorINS_7BSONObjESaIS2_EEPNS0_8SyncTailE + 271
 m31001|  7   mongod                              0x00000001012b9368 _ZN5mongo10threadpool6Worker4loopEv + 138
 m31001|  8   mongod                              0x0000000101309c25 thread_proxy + 229
 m31001|  9   libsystem_c.dylib                   0x00007fff92e9b8bf _pthread_start + 335
 m31001|  10  libsystem_c.dylib                   0x00007fff92e9eb75 thread_start + 13

Similarly if you have the two documents above in your primary and do:

db.user.remove({ $type: 11 }, false);

It will be converted into an oplog entry:

{ "ts" : Timestamp(1367252013, 1), "h" : NumberLong("-2940784610233179223"), "v" : 2, "op" : "d", "ns" : "test.user", "b" : true, "o" : { "_id" : /^D/ } }

And deletes the documents matching the regex in the secondaries!



 Comments   
Comment by auto [ 17/May/13 ]

Author:

{u'date': u'2013-05-15T20:40:45Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 fix assert code in unit test
Branch: v2.4
https://github.com/mongodb/mongo/commit/cf139b7cb6a3f619fc4577f4f0cd1b773d6e5ec2

Comment by auto [ 17/May/13 ]

Author:

{u'date': u'2013-05-15T18:34:13Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 fix assert code
Branch: v2.4
https://github.com/mongodb/mongo/commit/664284634b36bc7c89a30ec60a5e81063b6013f8

Comment by auto [ 17/May/13 ]

Author:

{u'date': u'2013-05-13T21:25:41Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 prohibit _id as RegEx

Otherwise, this breaks when replication attempts to do a query with the regular expression as _id.
Branch: v2.4
https://github.com/mongodb/mongo/commit/cb25ea3bb5d9a20378da9d72077573715b57c1c6

Comment by auto [ 15/May/13 ]

Author:

{u'date': u'2013-05-15T20:40:45Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 fix assert code in unit test
Branch: master
https://github.com/mongodb/mongo/commit/ce9e5626a8c7c10c4292a20cbaa9ab61888b1064

Comment by auto [ 15/May/13 ]

Author:

{u'date': u'2013-05-15T18:34:13Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 fix assert code
Branch: master
https://github.com/mongodb/mongo/commit/e810419be9102315c4b2f0720b2c640ef58827fc

Comment by auto [ 15/May/13 ]

Author:

{u'date': u'2013-05-13T21:25:41Z', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-9502 prohibit _id as RegEx

Otherwise, this breaks when replication attempts to do a query with the regular expression as _id.
Branch: master
https://github.com/mongodb/mongo/commit/7030cc8148131c8ac4910dd316929019f1909468

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