Skip to content

Commit

Permalink
Add yields to Item_func::fix_fields
Browse files Browse the repository at this point in the history
Summary:
When resolving an expression with many arguments (e.g. a long `IN (...)` list) we may not yield the scheduler in a timely fashion.

This should resolve stalls like
```
W0127 03:04:04.517819 2608142 TpScheduler::checkStall: Conn state: acExitLevel=0 isGoverned=1 readmissionMode=0 admitCount=1 waitEvents=0xa7 acFilter=0x0
W0127 03:04:04.517819 2608142 TpScheduler::checkStall: Collect time 748751 nsec, symbolize time 6554425 nsec, digest dc6129f5efe09474cfacb020cdc3521b
W0127 03:04:04.517819 2608142 TpScheduler::checkStall: Stack trace for 1 thread(s) [2608144 tp_conn-0]:
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002c134bd Item_func_in::resolve_type(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002839275 Item_func::fix_fields(THD*, Item**)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002eca7d5 Item_func_in::fix_fields(THD*, Item**)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000295fd80 Query_block::setup_conds(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002ca4b77 Sql_cmd_delete::prepare_inner(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000282d295 Sql_cmd_dml::prepare(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002827053 Sql_cmd_dml::execute(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000282177d mysql_execute_command(THD*, bool, unsigned long long*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 0000000002807d26 dispatch_sql_command(THD*, Parser_state*, unsigned long long*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 00000000027f8238 dispatch_command(THD*, COM_DATA const*, enum_server_command)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 00000000027f6d20 do_command(THD*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 00000000062dedd7 mysql::thread_pool::TpConnHandler::processEvent(void*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 00000000062f01f6 mysql::thread_pool::TpWorkerPool::processWorker(void*)
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000475447a pfs_spawn_thread(void*) [clone .__uniq.73903348312165179054628174044725776814] [clone .llvm.15823314186845019609]
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000009abae start_thread
W0127 03:04:04.517819 2608142 TpScheduler::checkStall:     @ 000000000012d17b __clone3
```

Test Plan: mtr

Reviewers: sunxiayi, greynya, #mysql_eng, #dms

Reviewed By: greynya

Subscribers: avandever

Differential Revision: https://phabricator.intern.facebook.com/D53241252

Tasks: T175421977
  • Loading branch information
alexbudfb committed Jan 31, 2024
1 parent ed9c6db commit 7fee664
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sql/item_func.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ bool Item_func::fix_fields(THD *thd, Item **) {
if (arg_count) { // Print purify happy
for (arg = args, arg_end = args + arg_count; arg != arg_end; arg++) {
if (fix_func_arg(thd, arg)) return true;

// In case there are many arguments to resolve, yield periodically.
thd->check_yield();
}
}

Expand Down

0 comments on commit 7fee664

Please sign in to comment.