[SERVER-21341] Periodic query yield timer incorrectly includes last lock acquisition time in calculation of whether to trigger yield Created: 07/Nov/15  Updated: 05/Feb/16  Resolved: 20/Nov/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.1.7
Fix Version/s: 3.2.0-rc3

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-19374 TTL Monitor does not yield while dele... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QuInt C (11/23/15)
Participants:

 Description   

Each query operation with a YIELD_AUTO yield policy incurs a time-based yield after every 10ms of active operation. However, the "start time" for the 10ms calculation is incorrectly considered to be before the last yield started, as opposed to after the last yield finished. This can lead to a scenario where a query will repeatedly yield after only one unit of work has completed, if the query needs to wait in line more than 10ms for a writer to yield the lock.

This is a regression introduced in 3.1.7 by SERVER-19374 (affects development versions 3.1.7 through 3.2.0-rc2 only).

Reproduce with the following script, and confirming the "numYields" value displayed in the diagnostic log. The query is expected to yield 2 times, but it instead yields 8 times.

db.foo.drop();
for (i=0; i<10; ++i) {
    assert.writeOK(db.foo.insert({}));
}
assert.commandWorked(db.adminCommand({configureFailPoint: "setYieldAllLocksWait", mode: "alwaysOn", data: {waitForMillis: 1000}}));
assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 5}));
db.foo.find().itcount();



 Comments   
Comment by J Rassi [ 20/Nov/15 ]

Resolving with fix version of 3.2.0-rc3 (release associated with the bugfix commit).

Comment by Githook User [ 20/Nov/15 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-21341 Add regression test query_yield_reset_timer.js
Branch: master
https://github.com/mongodb/mongo/commit/28b2447052b24d77f628c10be68a5ed69a276610

Comment by Githook User [ 07/Nov/15 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-21341 PlanYieldPolicy::resetTimer() call should be post-yield
Branch: master
https://github.com/mongodb/mongo/commit/11b757cc07e85f6a1b47ba1b2810f773003217be

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