MDEV-25282 Auto-shutdown on idle when socket-activated
Adds max_idle_execution system variable with a UINT_MAX
default value that corresponds to the time in seconds
under which the mariadbd executable will run in an idle state
with no connections.
Under systemd socket activiation this variable will get a 10 minute
default value. 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.
A global variable of server_last_activity is updated on
accepted connections (where max_idle_execution < UINT_MAX)
and when the connection count (standard or extra) is down
to <= 1 to keep the number of updates on a single variable
low (an not create another performance MDEV-21212 problem).
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 main accept loop moved code to
handle_new_socket_connection that encompases 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.
Before any committed DDL operation returns control to the caller,
we must ensure that it will have been durably committed before the
ddl_log state may be changed, no matter if
innodb_flush_log_at_trx_commit=0 is being used.
Operations that would involve deleting files were already safe,
because the durable write of the FILE_DELETE record that would precede
the file deletion would also have made the commit durable.
Furthermore, when we clean up ADD INDEX stubs that were left behind
by a previous ha_innobase::commit_inplace_alter_table(commit=false)
when MDL could not be acquired, we will use the same interface as
for dropping indexes. This safety measure should be dead code,
because ADD FULLTEXT INDEX is not supported online, and dropping indexes
only involves file deletion for FULLTEXT INDEX.
MDEV-25910: Make ALTER TABLE...ALGORITHM=COPY durable again
ha_innobase::extra(HA_EXTRA_END_ALTER_COPY): Flush the redo log
because the main transaction will not have written any log and
thus will not initiate any log write either. But the DDL recovery
layer expects that the operation will have been committed.
1. work around MDEV-25912 to not apply assert
at wsrep running time;
2. handle wsrep mode of the server recovery
3. convert hton calls to static binlog_commit ones.
4. satisfy MSAN complain on uninitialized std::pair
- Replace strncpy() with strmake() to ensure things are \0 terminated
- Initialized some variables that caused compiler warnings
- Increased buffer that caused warnings from strncpy