-
Daniel Black authored
Adds max_idle_execution system variable that corresponds to the time in seconds under which the mariadbd executable will run in an idle state (since last query) with no connections. Under systemd socket activation this variable will get a 10 minute default value, otherwise 0, representing no timeout. This will enable a service to be activated on connection and fall back to a shutdown state after 10 minutes of no queries. The systemd socket activation can restart the service on the next connection transparently. The maximum max_idle_execution is given by the following factors given its dependence on the OS system calls. Windows WaitForMultipleObjects takes a DWORD (unsigned) measure in milliseconds. Poll takes a signed int milliseconds, and negative values are treated as infinite so we can't overflow. Select, the fall back if poll isn't there, takes a seconds value in a timeval.time_t structure. As such the interface maximums are: Windows: UINT_MAX / 1000 Poll: INT_MAX / 1000 Select: UINT_MAX (or higher) As even the smallest value here, INT_MAX(32) / 1000 is ~25 days, sufficient for the typical use case, its used in all environment for simplicity of documentation and test cases. A (non-exposed) global variable of server_last_activity is updated on accepted connections (when max_idle_execution !=0) and when the connection count (standard or extra) is down to <= 1 to keep the number of updates on a single variable low. When the main accept loop times out on the max_idle_execution seconds, and then the server_last_activity is checked along with if current connection count (standard + extra) is 0 (in case a recently started connection hasn't finished a query). To make this neater, in non-Windows main accept loop moved code to handle_new_socket_connection that encompasses accepting a connection and the timeout mechanism has been separated too. Changed when looping though possible connections, loop until the end of the connection list and hereby assume two connection can occur on the same poll/select call and both will be accepted. The interactive_timeout and wait_timeout inherit the max_idle_execution time (if set) compared to their previous defaults. Thanks Sergei for the review.
06080865