-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support changing OS thread priorities
Summary: Support changing priorities of threads associated with user connections. This change enables 3 ways to change thread priories: 1. **Change current thread priority** : `set thread_priority=<priority_value>`. 2. **Set default priority for all new threads** : `set global thread_priority=<priority_value>`. 3. **Change any thread priority** : `set global thread_priority_str=<os-thread-id>:<priority_value>`. - Priority values take a range of -20 to 19 (the same as nice). - Non-default priority threads are not leaked into the thread cache: Threads which have non-zero priority will be reset to 0 priority at the end of the connection. The threads will be terminated in the case where such priority-reset is not possible. Automation will mostly make use of the 1st scenario to change the current connection/thread's priority before starting work, say a backup or a large scan. - Added a new session variable `thread_priority`. - Renamed `thread_nice_value` var to `thread_priority_str`. - a new information_schema table, `thread_priorities` to track the priority of all the threads. `thread_priority` sysvar: - takes an integer value, in the range similar to nice. - If this is set at the session level, the current thread's priority is modified. - If this is set at the global level, all **new** threads will inherit the modified priority. `thread_priority_str` sysvar: - input string format: <os-thread-id>:<priority-value> INFORMATION_SCHEMA.THREAD_PRIORITIES schema: ``` mysql> describe information_schema.threads; +------------------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+---------------------+------+-----+---------+-------+ | ID | bigint(21) unsigned | NO | | 0 | | | SYSTEM_THREAD_ID | bigint(21) unsigned | NO | | 0 | | | PRIORITY | bigint(5) | NO | | 0 | | +------------------+---------------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) ``` - ID is the connection id as seen in `show processlist`. - SYSTEM_THREAD_ID is the unix thread id as seen in `ps`. - PRIORITY is the thread priority (nice value). Notable changes: - CAP_SYS_NICE capability is acquired before changing the thread priority, and dropped after the action is done. - libcap library is a dependency for this change. - setuid changed to setresuid. Reviewed By: mzait Differential Revision: D22046019 fbshipit-source-id: 372586a058f
- Loading branch information
1 parent
7fdfd32
commit f912b38
Showing
29 changed files
with
1,070 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (!$MYSQL_TEST_ROOT){ | ||
skip Run as root; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.