Bug #84304 The connection control plugin will not compile with performance schema disabled
Submitted: 22 Dec 2016 1:10 Modified: 3 Mar 2017 19:35
Reporter: Jay Edgar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:mysql-5.6.35, 5.6.35 OS:Any
Assigned to: CPU Architecture:Any
Tags: connection control, performance schema

[22 Dec 2016 1:10] Jay Edgar
Description:
The new connection control plugin introduced in 5.6.35, does not contain the #ifdef HAVE_PSI_INTERFACE/#endif lines needed to compile when performance schema is not being built.

How to repeat:
cmake -DWITHOUT_PERFSCHEMA_STORAGE_ENGINE=1
make -j32

Suggested fix:
diff --git a/plugin/connection_control/connection_delay.cc b/plugin/connection_control/connection_delay.cc
index e7172ba..c8bafee 100644
--- a/plugin/connection_control/connection_delay.cc
+++ b/plugin/connection_control/connection_delay.cc
@@ -57,11 +57,13 @@ namespace connection_control

   /** variables used by connection_delay.cc */
   static mysql_rwlock_t connection_event_delay_lock;
+#ifdef HAVE_PSI_INTERFACE
   static PSI_rwlock_key key_connection_event_delay_lock;
   static PSI_rwlock_info all_rwlocks[]=
   {
     {&key_connection_event_delay_lock, "connection_event_delay_lock", 0}
   };
+#endif

   static opt_connection_control opt_enums[]=
   {
@@ -518,7 +520,9 @@ namespace connection_control
                                             ulonglong wait_time)
   {
     DBUG_ENTER("Connection_delay_action::conditional_wait");
+#ifdef HAVE_PSI_INTERFACE
     const char * category= "connection_delay";
+#endif

     /** mysql_cond_timedwait requires wait time in timespec format */
     struct timespec abstime;
@@ -532,6 +536,7 @@ namespace connection_control

     /** Initialize mutex required for mysql_cond_timedwait */
     mysql_mutex_t connection_delay_mutex;
+#ifdef HAVE_PSI_INTERFACE
     PSI_mutex_key key_connection_delay_mutex;
     PSI_mutex_info connection_delay_mutex_info[]=
     {
@@ -541,9 +546,13 @@ namespace connection_control
     PSI_server->register_mutex(category, connection_delay_mutex_info, count_mutex);
     mysql_mutex_init(key_connection_delay_mutex, &connection_delay_mutex,
                      MY_MUTEX_INIT_FAST);
+#else
+    mysql_mutex_init(0, &connection_delay_mutex, MY_MUTEX_INIT_FAST);
+#endif

     /* Initialize condition to wait for */
     mysql_cond_t connection_delay_wait_condition;
+#ifdef HAVE_PSI_INTERFACE
     PSI_cond_key key_connection_delay_wait;
     PSI_cond_info connection_delay_wait_info[]=
     {
@@ -552,6 +561,9 @@ namespace connection_control
     int count_cond= array_elements(connection_delay_wait_info);
     PSI_server->register_cond(category, connection_delay_wait_info, count_cond);
     mysql_cond_init(key_connection_delay_wait, &connection_delay_wait_condition, NULL);
+#else
+    mysql_cond_init(0, &connection_delay_wait_condition, NULL);
+#endif

     /** Register wait condition with THD */
     mysql_mutex_lock(&connection_delay_mutex);
@@ -917,11 +929,15 @@ namespace connection_control
     /*
       1. Initialize lock(s)
     */
+#ifdef HAVE_PSI_INTERFACE
     const char *category= "conn_control";
     int count= array_elements(all_rwlocks);
     mysql_rwlock_register(category, all_rwlocks, count);
     mysql_rwlock_init(key_connection_event_delay_lock,
                       &connection_event_delay_lock);
+#else
+    mysql_rwlock_init(0, &connection_event_delay_lock);
+#endif
     g_max_failed_connection_handler= new Connection_delay_action(g_variables.failed_connections_threshold,
                                                                  g_variables.min_connection_delay,
                                                                  g_variables.max_connection_delay,
[22 Dec 2016 5:43] MySQL Verification Team
Hello Jay Edgar,

Thank you for the report.
Verified as described with 5.6.35 source build.

Thanks,
Umesh
[28 Dec 2016 21:28] Jay Edgar
Even after the fixes I suggested are in place, the connection control plugin does not run with perfschema disabled.  It gets the following error running connection_control.status_variables.

t line 3: query 'INSTALL PLUGIN connection_control SONAME '$CONNECTION_CONTROL_PLUGIN'' failed: 1126: Can't open shared library '/home/jkedgar/Oracle-MySQL/5.6/build_ps/plugin/connection_control/connection_control.so' (errno: 2 /home/jkedgar/Oracle-MySQL/5.6/build_ps/plugin/connectio
n_control/connection_control.so: undefined symbol: lf_hash_insert)

Since perfschema is not compiled in, the lf_* functions are not being pulled in either.
[3 Mar 2017 19:35] Paul DuBois
Posted by developer:
 
Noted in 5.6.36, 5.7.18, 8.0.1 changelogs.

The connection_control plugin failed to compile if the Performance
Schema was disabled.