[SERVER-40052] Shutdown in mongos can trigger BatchWriteOp invariant Created: 08/Mar/19  Updated: 29/Oct/23  Resolved: 24/Apr/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 3.6.13, 4.1.11, 4.0.11

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Blake Oler
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-40184 Crash in server after bulk write error Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6
Steps To Reproduce:

Taken from SERVER-40184:

  1. startTransaction in session 0
  2. execute insertOne on collection
  3. startTransaction in session 1
  4. execute insertOne on collection (WriteConflict error expected)
Sprint: Sharding 2019-05-06
Participants:
Case:
Linked BF Score: 5

 Description   

Invariant failure _targeted.empty() src\mongo\s\write_ops\batch_write_op.cpp 255

Scenario:

  1. ARS next calls makeProgress, calls pop and this can cause it to throw shutdownInProgress if no response has been pushed for remote.
  2. This will get caught and cancel all the pending requests. However, what this actually does is mark the task as 'cancelled' and tell the task executor to schedule them right away. Or, in the worse case when the executor is in shutdown, it might just get ignored.
  3. Right before the task executor is able to actually cancel and push the response, if ARS calls makeProgress again, it will trigger the shutdownInProgress error again, exiting the next() call and trigerring the destructor of BatchWriteOp with _targeted not fully consumed.


 Comments   
Comment by Githook User [ 04/Jun/19 ]

Author:

{'name': 'Blake Oler', 'email': 'blake.oler@mongodb.com', 'username': 'BlakeIsBlake'}

Message: SERVER-40052 Remove unnecessary invariant in BatchWriteOp invariant

(cherry picked from commit da806668926bcbdddbdc3d1aa86216810e4041d5)
Branch: v3.6
https://github.com/mongodb/mongo/commit/db3c76679b7a3d9b443a0e1b3e45ed02b88c539f

Comment by Githook User [ 04/Jun/19 ]

Author:

{'name': 'Blake Oler', 'email': 'blake.oler@mongodb.com', 'username': 'BlakeIsBlake'}

Message: SERVER-40052 Remove unnecessary invariant in BatchWriteOp invariant

(cherry picked from commit c8debc4dbb35689fc79e036f6ee51d0c6f51e5fe)
Branch: v4.0
https://github.com/mongodb/mongo/commit/da806668926bcbdddbdc3d1aa86216810e4041d5

Comment by Githook User [ 24/Apr/19 ]

Author:

{'name': 'Blake Oler', 'username': 'BlakeIsBlake', 'email': 'blake.oler@mongodb.com'}

Message: SERVER-40052 Remove unnecessary invariant in BatchWriteOp invariant
Branch: master
https://github.com/mongodb/mongo/commit/c8debc4dbb35689fc79e036f6ee51d0c6f51e5fe

Comment by Bruce Lucas (Inactive) [ 01/Apr/19 ]

Typical log message:

2019-03-01T04:11:23.192+0100 F -        [conn20] Invariant failure _targeted.empty() src/mongo/s/write_ops/batch_write_op.cpp 215

Generated at Thu Feb 08 04:53:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.