[SERVER-19374] TTL Monitor does not yield while deleting expired documents Created: 13/Jul/15  Updated: 07/Nov/15  Resolved: 27/Jul/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.1.3
Fix Version/s: 3.1.7

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Qingyang Chen
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-17984 TTL Monitor doesn't modify query to m... Closed
is related to SERVER-21341 Periodic query yield timer incorrectl... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Quint Iteration 7
Participants:

 Description   

The TTL Monitor resets the timer on the cursor after every individual document is deleted, which means it never hits the yield point, which is meant to hit after every 10ms or 100 works.



 Comments   
Comment by Githook User [ 28/Jul/15 ]

Author:

{u'username': u'coollog', u'name': u'Qingyang Chen', u'email': u'qingyang.chen@10gen.com'}

Message: SERVER-19374 Fix TTL Monitor does not yield when deleting expired docs
Branch: master
https://github.com/mongodb/mongo/commit/daadcec8db3f0021b95cb410458ab7ae176515e3

Comment by Githook User [ 27/Jul/15 ]

Author:

{u'username': u'coollog', u'name': u'Qingyang Chen', u'email': u'qingyang.chen@10gen.com'}

Message: SERVER-19374 Fix TTL Monitor does not yield when deleting expired docs
Branch: master
https://github.com/mongodb/mongo/commit/daadcec8db3f0021b95cb410458ab7ae176515e3

Comment by Geert Bosch [ 13/Jul/15 ]

I can confirm that this was introduced by SERVER-17984. The issue is that restoreState resets the timer, and we call this function in the delete loop of doTTLForIndex:

(gdb) bt
#0  mongo::ElapsedTracker::resetLastTime (this=0x12b07a58) at src/mongo/util/elapsed_tracker.cpp:62
#1  0x0000000000c7ac5e in mongo::PlanYieldPolicy::resetTimer (this=<optimized out>) at src/mongo/db/query/plan_yield_policy.cpp:57
#2  0x0000000000c75024 in mongo::PlanExecutor::restoreStateWithoutRetrying (this=this@entry=0x119d88f0, opCtx=opCtx@entry=0x7f371147d870)
    at src/mongo/db/query/plan_executor.cpp:290
#3  0x0000000000c75091 in mongo::PlanExecutor::restoreState (this=0x119d88f0, opCtx=opCtx@entry=0x7f371147d870) at src/mongo/db/query/plan_executor.cpp:272
#4  0x0000000000eb8b61 in mongo::TTLMonitor::doTTLForIndex (this=this@entry=0x3341ba0, txn=txn@entry=0x7f371147d870, dbName=..., idx=...) at src/mongo/db/ttl.cpp:307
#5  0x0000000000eb9b92 in mongo::TTLMonitor::doTTLPass (this=this@entry=0x3341ba0) at src/mongo/db/ttl.cpp:145
#6  0x0000000000eba1f8 in mongo::TTLMonitor::run (this=0x3341ba0) at src/mongo/db/ttl.cpp:113
#7  0x000000000105da07 in mongo::BackgroundJob::jobBody (this=0x3341ba0) at src/mongo/util/background.cpp:152
#8  0x00007f3716b15b60 in std::(anonymous namespace)::execute_native_thread_routine (__p=<optimized out>) at ../../../../../libstdc++-v3/src/c++11/thread.cc:84
#9  0x00007f3716328182 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#10 0x00007f3716052fbd in clone () from /lib/x86_64-linux-gnu/libc.so.6

As a result the TTL monitor never yields.

Comment by J Rassi [ 13/Jul/15 ]

It looks like this is a regression introduced by SERVER-17984. Geert, can you confirm?

Per discussion, I'd suggest:

  • Removing the call to resetTimer() from PlanExecutor::restoreStateWithoutRetrying().
  • Adding a call to resetTimer() from PlanYieldPolicy::yield().
  • Adding a call to resetTimer() from PlanExecutor::attachToOperationContext(), once that method (or equivalent) is introduced in SERVER-17364.
Generated at Thu Feb 08 03:50:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.