Permalink
Browse files

Support compile-time disabling of setpriority().

This is to support running on systems such as Snappy Ubuntu Core,
e.g. heavily confined using seccomp filters. In such a situation,
without this commit, MySQL is aborted as soon as it tries to call
setpriority(). With this commit, MySQL can be built without
setpriority() by using -DWITH_INNODB_PAGE_CLEANER_PRIORITY=OFF,
thus supporting such systems.

Signed-off-by: Kyle Fazzari <oracle@status.e4ward.com>
  • Loading branch information...
Kyle Fazzari
Kyle Fazzari committed Mar 25, 2016
1 parent 67d52e7 commit dd0e4e497794da2650536097655f4bf732b261a9
Showing with 11 additions and 6 deletions.
  1. +6 −6 storage/innobase/buf/buf0flu.cc
  2. +5 −0 storage/innobase/innodb.cmake
@@ -2952,7 +2952,7 @@ pc_wait_finished(
return(all_succeeded);
}

#ifdef UNIV_LINUX
#if defined(UNIV_LINUX) && defined(SET_PAGE_CLEANER_PRIORITY)
/**
Set priority for page_cleaner threads.
@param[in] priority priority intended to set
@@ -2967,7 +2967,7 @@ buf_flush_page_cleaner_set_priority(
return(getpriority(PRIO_PROCESS, (pid_t)syscall(SYS_gettid))
== priority);
}
#endif /* UNIV_LINUX */
#endif /* UNIV_LINUX && SET_PAGE_CLEANER_PRIORITY */

#ifdef UNIV_DEBUG
/** Loop used to disable page cleaner threads. */
@@ -3113,7 +3113,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(
<< os_thread_pf(os_thread_get_curr_id());
#endif /* UNIV_DEBUG_THREAD_CREATION */

#ifdef UNIV_LINUX
#if defined(UNIV_LINUX) && defined(SET_PAGE_CLEANER_PRIORITY)
/* linux might be able to set different setting for each thread.
worth to try to set high priority for page cleaner threads */
if (buf_flush_page_cleaner_set_priority(
@@ -3126,7 +3126,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(
" page cleaner thread priority can be changed."
" See the man page of setpriority().";
}
#endif /* UNIV_LINUX */
#endif /* UNIV_LINUX && SET_PAGE_CLEANER_PRIORITY */

buf_page_cleaner_is_active = true;

@@ -3481,7 +3481,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)(
page_cleaner->n_workers++;
mutex_exit(&page_cleaner->mutex);

#ifdef UNIV_LINUX
#if defined(UNIV_LINUX) && defined(SET_PAGE_CLEANER_PRIORITY)
/* linux might be able to set different setting for each thread
worth to try to set high priority for page cleaner threads */
if (buf_flush_page_cleaner_set_priority(
@@ -3490,7 +3490,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_worker)(
ib::info() << "page_cleaner worker priority: "
<< buf_flush_page_cleaner_priority;
}
#endif /* UNIV_LINUX */
#endif /* UNIV_LINUX && SET_PAGE_CLEANER_PRIORITY */

while (true) {
os_event_wait(page_cleaner->is_requested);
@@ -42,6 +42,11 @@ IF(UNIX)
LINK_LIBRARIES(numa)
ENDIF()

OPTION(WITH_INNODB_PAGE_CLEANER_PRIORITY "Set a high priority for page cleaner threads" ON)
IF(WITH_INNODB_PAGE_CLEANER_PRIORITY)
ADD_DEFINITIONS("-DSET_PAGE_CLEANER_PRIORITY")
ENDIF()

ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
ADD_DEFINITIONS("-DUNIV_SOLARIS")
ENDIF()

0 comments on commit dd0e4e4

Please sign in to comment.