summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/catalog.h4
-rw-r--r--storage/connect/mysql-test/connect/r/mysql.result11
-rw-r--r--storage/connect/mysql-test/connect/t/mysql.test15
-rw-r--r--storage/connect/myutil.cpp2
-rw-r--r--storage/connect/reldef.cpp26
-rw-r--r--storage/connect/tabbson.cpp47
-rw-r--r--storage/connect/tabdos.cpp61
-rw-r--r--storage/connect/tabext.cpp57
-rw-r--r--storage/connect/tabfmt.cpp38
-rw-r--r--storage/connect/tabjdbc.cpp45
-rw-r--r--storage/connect/tabjson.cpp54
-rw-r--r--storage/connect/value.cpp8
-rw-r--r--storage/connect/value.h2
-rw-r--r--storage/innobase/btr/btr0btr.cc2
-rw-r--r--storage/innobase/btr/btr0cur.cc4
-rw-r--r--storage/innobase/buf/buf0buf.cc14
-rw-r--r--storage/innobase/buf/buf0dblwr.cc43
-rw-r--r--storage/innobase/buf/buf0dump.cc2
-rw-r--r--storage/innobase/buf/buf0flu.cc133
-rw-r--r--storage/innobase/buf/buf0lru.cc15
-rw-r--r--storage/innobase/buf/buf0rea.cc25
-rw-r--r--storage/innobase/dict/drop.cc1
-rw-r--r--storage/innobase/fil/fil0fil.cc75
-rw-r--r--storage/innobase/fsp/fsp0file.cc2
-rw-r--r--storage/innobase/fsp/fsp0space.cc24
-rw-r--r--storage/innobase/fsp/fsp0sysspace.cc12
-rw-r--r--storage/innobase/fts/fts0fts.cc325
-rw-r--r--storage/innobase/fts/fts0opt.cc56
-rw-r--r--storage/innobase/gis/gis0rtree.cc3
-rw-r--r--storage/innobase/handler/ha_innodb.cc93
-rw-r--r--storage/innobase/handler/handler0alter.cc8
-rw-r--r--storage/innobase/handler/i_s.cc8
-rw-r--r--storage/innobase/include/buf0buf.h16
-rw-r--r--storage/innobase/include/buf0dblwr.h45
-rw-r--r--storage/innobase/include/fil0fil.h4
-rw-r--r--storage/innobase/include/fts0fts.h9
-rw-r--r--storage/innobase/include/fts0types.h32
-rw-r--r--storage/innobase/include/ha_prototypes.h10
-rw-r--r--storage/innobase/include/log0log.h10
-rw-r--r--storage/innobase/include/mtr0mtr.h14
-rw-r--r--storage/innobase/include/os0file.h32
-rw-r--r--storage/innobase/include/srv0srv.h3
-rw-r--r--storage/innobase/include/trx0purge.h7
-rw-r--r--storage/innobase/include/trx0rseg.h3
-rw-r--r--storage/innobase/include/trx0undo.h10
-rw-r--r--storage/innobase/log/log0log.cc10
-rw-r--r--storage/innobase/log/log0recv.cc43
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc12
-rw-r--r--storage/innobase/os/os0file.cc115
-rw-r--r--storage/innobase/page/page0zip.cc5
-rw-r--r--storage/innobase/rem/rem0cmp.cc5
-rw-r--r--storage/innobase/rem/rem0rec.cc10
-rw-r--r--storage/innobase/row/row0import.cc1
-rw-r--r--storage/innobase/row/row0ins.cc48
-rw-r--r--storage/innobase/row/row0merge.cc5
-rw-r--r--storage/innobase/row/row0mysql.cc26
-rw-r--r--storage/innobase/row/row0purge.cc5
-rw-r--r--storage/innobase/row/row0quiesce.cc2
-rw-r--r--storage/innobase/row/row0uins.cc5
-rw-r--r--storage/innobase/row/row0vers.cc28
-rw-r--r--storage/innobase/srv/srv0mon.cc40
-rw-r--r--storage/innobase/srv/srv0srv.cc34
-rw-r--r--storage/innobase/srv/srv0start.cc39
-rw-r--r--storage/innobase/trx/trx0purge.cc307
-rw-r--r--storage/innobase/trx/trx0rec.cc10
-rw-r--r--storage/innobase/trx/trx0rseg.cc3
-rw-r--r--storage/innobase/trx/trx0trx.cc27
-rw-r--r--storage/innobase/trx/trx0undo.cc120
-rw-r--r--storage/maria/ha_maria.cc5
-rw-r--r--storage/myisammrg/ha_myisammrg.cc25
-rw-r--r--storage/perfschema/CMakeLists.txt2
-rw-r--r--storage/perfschema/cursor_by_account.cc2
-rw-r--r--storage/perfschema/cursor_by_account.h2
-rw-r--r--storage/perfschema/cursor_by_host.cc2
-rw-r--r--storage/perfschema/cursor_by_host.h2
-rw-r--r--storage/perfschema/cursor_by_thread.cc2
-rw-r--r--storage/perfschema/cursor_by_thread.h2
-rw-r--r--storage/perfschema/cursor_by_thread_connect_attr.cc2
-rw-r--r--storage/perfschema/cursor_by_thread_connect_attr.h2
-rw-r--r--storage/perfschema/cursor_by_user.cc2
-rw-r--r--storage/perfschema/cursor_by_user.h2
-rw-r--r--storage/perfschema/ha_perfschema.cc2
-rw-r--r--storage/perfschema/ha_perfschema.h2
-rw-r--r--storage/perfschema/pfs.cc5
-rw-r--r--storage/perfschema/pfs.h2
-rw-r--r--storage/perfschema/pfs_account.cc2
-rw-r--r--storage/perfschema/pfs_account.h2
-rw-r--r--storage/perfschema/pfs_atomic.h2
-rw-r--r--storage/perfschema/pfs_autosize.cc2
-rw-r--r--storage/perfschema/pfs_buffer_container.cc2
-rw-r--r--storage/perfschema/pfs_buffer_container.h2
-rw-r--r--storage/perfschema/pfs_builtin_memory.cc2
-rw-r--r--storage/perfschema/pfs_builtin_memory.h2
-rw-r--r--storage/perfschema/pfs_column_types.h2
-rw-r--r--storage/perfschema/pfs_column_values.cc2
-rw-r--r--storage/perfschema/pfs_column_values.h2
-rw-r--r--storage/perfschema/pfs_con_slice.cc2
-rw-r--r--storage/perfschema/pfs_con_slice.h2
-rw-r--r--storage/perfschema/pfs_defaults.cc2
-rw-r--r--storage/perfschema/pfs_defaults.h2
-rw-r--r--storage/perfschema/pfs_digest.cc2
-rw-r--r--storage/perfschema/pfs_digest.h2
-rw-r--r--storage/perfschema/pfs_engine_table.cc2
-rw-r--r--storage/perfschema/pfs_engine_table.h2
-rw-r--r--storage/perfschema/pfs_events.h2
-rw-r--r--storage/perfschema/pfs_events_stages.cc2
-rw-r--r--storage/perfschema/pfs_events_stages.h2
-rw-r--r--storage/perfschema/pfs_events_statements.cc2
-rw-r--r--storage/perfschema/pfs_events_transactions.cc2
-rw-r--r--storage/perfschema/pfs_events_transactions.h2
-rw-r--r--storage/perfschema/pfs_events_waits.cc2
-rw-r--r--storage/perfschema/pfs_events_waits.h2
-rw-r--r--storage/perfschema/pfs_global.cc2
-rw-r--r--storage/perfschema/pfs_global.h2
-rw-r--r--storage/perfschema/pfs_host.cc2
-rw-r--r--storage/perfschema/pfs_host.h2
-rw-r--r--storage/perfschema/pfs_instr.cc2
-rw-r--r--storage/perfschema/pfs_instr.h2
-rw-r--r--storage/perfschema/pfs_instr_class.cc2
-rw-r--r--storage/perfschema/pfs_instr_class.h2
-rw-r--r--storage/perfschema/pfs_lock.h2
-rw-r--r--storage/perfschema/pfs_memory.cc2
-rw-r--r--storage/perfschema/pfs_memory.h2
-rw-r--r--storage/perfschema/pfs_prepared_stmt.cc2
-rw-r--r--storage/perfschema/pfs_prepared_stmt.h2
-rw-r--r--storage/perfschema/pfs_program.cc2
-rw-r--r--storage/perfschema/pfs_program.h2
-rw-r--r--storage/perfschema/pfs_server.cc2
-rw-r--r--storage/perfschema/pfs_server.h2
-rw-r--r--storage/perfschema/pfs_setup_actor.cc2
-rw-r--r--storage/perfschema/pfs_setup_actor.h2
-rw-r--r--storage/perfschema/pfs_setup_object.cc2
-rw-r--r--storage/perfschema/pfs_setup_object.h2
-rw-r--r--storage/perfschema/pfs_stat.h2
-rw-r--r--storage/perfschema/pfs_status.cc2
-rw-r--r--storage/perfschema/pfs_status.h2
-rw-r--r--storage/perfschema/pfs_timer.cc2
-rw-r--r--storage/perfschema/pfs_timer.h2
-rw-r--r--storage/perfschema/pfs_user.cc2
-rw-r--r--storage/perfschema/pfs_user.h2
-rw-r--r--storage/perfschema/pfs_variable.cc2
-rw-r--r--storage/perfschema/pfs_variable.h2
-rw-r--r--storage/perfschema/pfs_visitor.cc2
-rw-r--r--storage/perfschema/pfs_visitor.h2
-rw-r--r--storage/perfschema/table_accounts.cc2
-rw-r--r--storage/perfschema/table_accounts.h2
-rw-r--r--storage/perfschema/table_all_instr.cc2
-rw-r--r--storage/perfschema/table_all_instr.h2
-rw-r--r--storage/perfschema/table_esgs_by_account_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esgs_by_account_by_event_name.h2
-rw-r--r--storage/perfschema/table_esgs_by_host_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esgs_by_host_by_event_name.h2
-rw-r--r--storage/perfschema/table_esgs_by_thread_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esgs_by_thread_by_event_name.h2
-rw-r--r--storage/perfschema/table_esgs_by_user_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esgs_by_user_by_event_name.h2
-rw-r--r--storage/perfschema/table_esgs_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esgs_global_by_event_name.h2
-rw-r--r--storage/perfschema/table_esms_by_account_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esms_by_account_by_event_name.h2
-rw-r--r--storage/perfschema/table_esms_by_digest.cc2
-rw-r--r--storage/perfschema/table_esms_by_digest.h2
-rw-r--r--storage/perfschema/table_esms_by_host_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esms_by_host_by_event_name.h2
-rw-r--r--storage/perfschema/table_esms_by_program.cc2
-rw-r--r--storage/perfschema/table_esms_by_program.h2
-rw-r--r--storage/perfschema/table_esms_by_thread_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esms_by_thread_by_event_name.h2
-rw-r--r--storage/perfschema/table_esms_by_user_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esms_by_user_by_event_name.h2
-rw-r--r--storage/perfschema/table_esms_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_esms_global_by_event_name.h2
-rw-r--r--storage/perfschema/table_ets_by_account_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ets_by_account_by_event_name.h2
-rw-r--r--storage/perfschema/table_ets_by_host_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ets_by_host_by_event_name.h2
-rw-r--r--storage/perfschema/table_ets_by_thread_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ets_by_thread_by_event_name.h2
-rw-r--r--storage/perfschema/table_ets_by_user_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ets_by_user_by_event_name.h2
-rw-r--r--storage/perfschema/table_ets_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ets_global_by_event_name.h2
-rw-r--r--storage/perfschema/table_events_stages.cc2
-rw-r--r--storage/perfschema/table_events_stages.h2
-rw-r--r--storage/perfschema/table_events_statements.cc2
-rw-r--r--storage/perfschema/table_events_statements.h2
-rw-r--r--storage/perfschema/table_events_transactions.cc2
-rw-r--r--storage/perfschema/table_events_transactions.h2
-rw-r--r--storage/perfschema/table_events_waits.cc2
-rw-r--r--storage/perfschema/table_events_waits.h2
-rw-r--r--storage/perfschema/table_events_waits_summary.cc2
-rw-r--r--storage/perfschema/table_events_waits_summary.h2
-rw-r--r--storage/perfschema/table_ews_by_account_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_by_account_by_event_name.h2
-rw-r--r--storage/perfschema/table_ews_by_host_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_by_host_by_event_name.h2
-rw-r--r--storage/perfschema/table_ews_by_thread_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_by_thread_by_event_name.h2
-rw-r--r--storage/perfschema/table_ews_by_user_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_by_user_by_event_name.h2
-rw-r--r--storage/perfschema/table_ews_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_ews_global_by_event_name.h2
-rw-r--r--storage/perfschema/table_file_instances.cc2
-rw-r--r--storage/perfschema/table_file_instances.h2
-rw-r--r--storage/perfschema/table_file_summary_by_event_name.cc2
-rw-r--r--storage/perfschema/table_file_summary_by_event_name.h2
-rw-r--r--storage/perfschema/table_file_summary_by_instance.cc2
-rw-r--r--storage/perfschema/table_file_summary_by_instance.h2
-rw-r--r--storage/perfschema/table_global_status.cc2
-rw-r--r--storage/perfschema/table_global_status.h2
-rw-r--r--storage/perfschema/table_global_variables.cc2
-rw-r--r--storage/perfschema/table_global_variables.h2
-rw-r--r--storage/perfschema/table_helper.cc2
-rw-r--r--storage/perfschema/table_helper.h2
-rw-r--r--storage/perfschema/table_host_cache.cc2
-rw-r--r--storage/perfschema/table_host_cache.h2
-rw-r--r--storage/perfschema/table_hosts.cc2
-rw-r--r--storage/perfschema/table_hosts.h2
-rw-r--r--storage/perfschema/table_md_locks.cc2
-rw-r--r--storage/perfschema/table_md_locks.h2
-rw-r--r--storage/perfschema/table_mems_by_account_by_event_name.cc2
-rw-r--r--storage/perfschema/table_mems_by_account_by_event_name.h2
-rw-r--r--storage/perfschema/table_mems_by_host_by_event_name.cc2
-rw-r--r--storage/perfschema/table_mems_by_host_by_event_name.h2
-rw-r--r--storage/perfschema/table_mems_by_thread_by_event_name.cc2
-rw-r--r--storage/perfschema/table_mems_by_thread_by_event_name.h2
-rw-r--r--storage/perfschema/table_mems_by_user_by_event_name.cc2
-rw-r--r--storage/perfschema/table_mems_by_user_by_event_name.h2
-rw-r--r--storage/perfschema/table_mems_global_by_event_name.cc2
-rw-r--r--storage/perfschema/table_mems_global_by_event_name.h2
-rw-r--r--storage/perfschema/table_os_global_by_type.cc2
-rw-r--r--storage/perfschema/table_os_global_by_type.h2
-rw-r--r--storage/perfschema/table_performance_timers.cc2
-rw-r--r--storage/perfschema/table_performance_timers.h2
-rw-r--r--storage/perfschema/table_prepared_stmt_instances.cc2
-rw-r--r--storage/perfschema/table_prepared_stmt_instances.h2
-rw-r--r--storage/perfschema/table_processlist.cc2
-rw-r--r--storage/perfschema/table_processlist.h2
-rw-r--r--storage/perfschema/table_replication_applier_configuration.cc2
-rw-r--r--storage/perfschema/table_replication_applier_configuration.h2
-rw-r--r--storage/perfschema/table_replication_applier_status.cc2
-rw-r--r--storage/perfschema/table_replication_applier_status.h2
-rw-r--r--storage/perfschema/table_replication_applier_status_by_coordinator.cc2
-rw-r--r--storage/perfschema/table_replication_applier_status_by_coordinator.h2
-rw-r--r--storage/perfschema/table_replication_applier_status_by_worker.cc2
-rw-r--r--storage/perfschema/table_replication_applier_status_by_worker.h2
-rw-r--r--storage/perfschema/table_replication_connection_configuration.cc2
-rw-r--r--storage/perfschema/table_replication_connection_configuration.h2
-rw-r--r--storage/perfschema/table_replication_connection_status.cc2
-rw-r--r--storage/perfschema/table_replication_connection_status.h2
-rw-r--r--storage/perfschema/table_replication_group_member_stats.cc2
-rw-r--r--storage/perfschema/table_replication_group_member_stats.h2
-rw-r--r--storage/perfschema/table_replication_group_members.cc2
-rw-r--r--storage/perfschema/table_replication_group_members.h2
-rw-r--r--storage/perfschema/table_session_account_connect_attrs.cc2
-rw-r--r--storage/perfschema/table_session_account_connect_attrs.h2
-rw-r--r--storage/perfschema/table_session_connect.cc2
-rw-r--r--storage/perfschema/table_session_connect.h2
-rw-r--r--storage/perfschema/table_session_connect_attrs.cc2
-rw-r--r--storage/perfschema/table_session_connect_attrs.h2
-rw-r--r--storage/perfschema/table_session_status.cc2
-rw-r--r--storage/perfschema/table_session_status.h2
-rw-r--r--storage/perfschema/table_session_variables.cc2
-rw-r--r--storage/perfschema/table_session_variables.h2
-rw-r--r--storage/perfschema/table_setup_actors.cc2
-rw-r--r--storage/perfschema/table_setup_actors.h2
-rw-r--r--storage/perfschema/table_setup_consumers.cc2
-rw-r--r--storage/perfschema/table_setup_consumers.h2
-rw-r--r--storage/perfschema/table_setup_instruments.cc2
-rw-r--r--storage/perfschema/table_setup_instruments.h2
-rw-r--r--storage/perfschema/table_setup_objects.cc2
-rw-r--r--storage/perfschema/table_setup_objects.h2
-rw-r--r--storage/perfschema/table_setup_timers.cc2
-rw-r--r--storage/perfschema/table_setup_timers.h2
-rw-r--r--storage/perfschema/table_socket_instances.cc2
-rw-r--r--storage/perfschema/table_socket_instances.h2
-rw-r--r--storage/perfschema/table_socket_summary_by_event_name.cc2
-rw-r--r--storage/perfschema/table_socket_summary_by_event_name.h2
-rw-r--r--storage/perfschema/table_socket_summary_by_instance.cc2
-rw-r--r--storage/perfschema/table_socket_summary_by_instance.h2
-rw-r--r--storage/perfschema/table_status_by_account.cc2
-rw-r--r--storage/perfschema/table_status_by_account.h2
-rw-r--r--storage/perfschema/table_status_by_host.cc2
-rw-r--r--storage/perfschema/table_status_by_host.h2
-rw-r--r--storage/perfschema/table_status_by_thread.cc2
-rw-r--r--storage/perfschema/table_status_by_thread.h2
-rw-r--r--storage/perfschema/table_status_by_user.cc2
-rw-r--r--storage/perfschema/table_status_by_user.h2
-rw-r--r--storage/perfschema/table_sync_instances.cc2
-rw-r--r--storage/perfschema/table_sync_instances.h2
-rw-r--r--storage/perfschema/table_table_handles.cc2
-rw-r--r--storage/perfschema/table_table_handles.h2
-rw-r--r--storage/perfschema/table_threads.cc2
-rw-r--r--storage/perfschema/table_threads.h2
-rw-r--r--storage/perfschema/table_tiws_by_index_usage.cc2
-rw-r--r--storage/perfschema/table_tiws_by_index_usage.h2
-rw-r--r--storage/perfschema/table_tiws_by_table.cc2
-rw-r--r--storage/perfschema/table_tiws_by_table.h2
-rw-r--r--storage/perfschema/table_tlws_by_table.cc2
-rw-r--r--storage/perfschema/table_tlws_by_table.h2
-rw-r--r--storage/perfschema/table_users.cc2
-rw-r--r--storage/perfschema/table_users.h2
-rw-r--r--storage/perfschema/table_uvar_by_thread.cc2
-rw-r--r--storage/perfschema/table_uvar_by_thread.h2
-rw-r--r--storage/perfschema/table_variables_by_thread.cc2
-rw-r--r--storage/perfschema/table_variables_by_thread.h2
-rw-r--r--storage/perfschema/unittest/CMakeLists.txt2
-rw-r--r--storage/perfschema/unittest/conf.txt2
-rw-r--r--storage/perfschema/unittest/pfs-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_account-oom-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_connect_attr-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_host-oom-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_instr-oom-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_instr-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_instr_class-oom-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_instr_class-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_misc-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_noop-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_server_stubs.cc2
-rw-r--r--storage/perfschema/unittest/pfs_timer-t.cc2
-rw-r--r--storage/perfschema/unittest/pfs_user-oom-t.cc2
-rw-r--r--storage/perfschema/unittest/stub_global_status_var.h2
-rw-r--r--storage/perfschema/unittest/stub_pfs_defaults.h2
-rw-r--r--storage/perfschema/unittest/stub_pfs_global.h2
-rw-r--r--storage/perfschema/unittest/stub_print_error.h2
-rw-r--r--storage/rocksdb/CMakeLists.txt5
-rw-r--r--storage/rocksdb/build_rocksdb.cmake2
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test1
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test4
-rw-r--r--storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test4
-rw-r--r--storage/rocksdb/ut0counter.h2
-rw-r--r--storage/spider/ha_spider.cc16
-rw-r--r--storage/spider/ha_spider.h4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/disabled.def1
-rw-r--r--storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc8
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result1
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_29644.result41
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_29676.result47
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/mdev_29904.result4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result21
-rw-r--r--storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result4
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test2
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_29644.cnf3
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_29644.test56
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_29676.test41
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/mdev_29904.test6
-rw-r--r--storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test29
-rw-r--r--storage/spider/mysql-test/spider/r/slave_trx_isolation.result4
-rw-r--r--storage/spider/spd_conn.cc148
-rw-r--r--storage/spider/spd_copy_tables.cc2
-rw-r--r--storage/spider/spd_db_include.h12
-rw-r--r--storage/spider/spd_db_mysql.cc994
-rw-r--r--storage/spider/spd_db_mysql.h10
-rw-r--r--storage/spider/spd_err.h2
-rw-r--r--storage/spider/spd_include.h57
-rw-r--r--storage/spider/spd_param.cc2
-rw-r--r--storage/spider/spd_param.h1
-rw-r--r--storage/spider/spd_ping_table.cc2
-rw-r--r--storage/spider/spd_sys_table.cc107
-rw-r--r--storage/spider/spd_sys_table.h7
-rw-r--r--storage/spider/spd_table.cc2017
-rw-r--r--storage/spider/spd_table.h22
-rw-r--r--storage/spider/spd_trx.cc51
366 files changed, 3309 insertions, 3296 deletions
diff --git a/storage/connect/catalog.h b/storage/connect/catalog.h
index 2649a50cf76..a46615f5d6e 100644
--- a/storage/connect/catalog.h
+++ b/storage/connect/catalog.h
@@ -39,9 +39,9 @@ typedef struct _colinfo {
PCSZ Name;
int Type;
int Offset;
- int Length;
+ unsigned Length;
int Key;
- int Precision;
+ unsigned Precision;
int Scale;
int Opt;
int Freq;
diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result
index d3c244b277a..1dcbca88a7b 100644
--- a/storage/connect/mysql-test/connect/r/mysql.result
+++ b/storage/connect/mysql-test/connect/r/mysql.result
@@ -364,5 +364,16 @@ hex(col)
DROP TABLE t2;
DROP TABLE t1;
#
+# MDEV-29782 CONNECT engine converted YEAR to DATETIME, causing INSERT to fail
+#
+CREATE TABLE t1 (id year);
+CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT';
+INSERT INTO t2 VALUES (1999);
+SELECT * FROM t2;
+id
+1999
+DROP TABLE t2;
+DROP TABLE t1;
+#
# End of 10.3 tests
#
diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test
index a50db4a6457..cd52f78fb30 100644
--- a/storage/connect/mysql-test/connect/t/mysql.test
+++ b/storage/connect/mysql-test/connect/t/mysql.test
@@ -534,5 +534,20 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-29782 CONNECT engine converted YEAR to DATETIME, causing INSERT to fail
+--echo #
+
+CREATE TABLE t1 (id year);
+
+--replace_result $PORT PORT
+--eval CREATE TABLE t2 ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT'
+
+INSERT INTO t2 VALUES (1999);
+SELECT * FROM t2;
+
+DROP TABLE t2;
+DROP TABLE t1;
+
+--echo #
--echo # End of 10.3 tests
--echo #
diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp
index c49db48bfb3..45b2c46e217 100644
--- a/storage/connect/myutil.cpp
+++ b/storage/connect/myutil.cpp
@@ -183,6 +183,7 @@ int MYSQLtoPLG(int mytype, char *var)
switch (mytype) {
case MYSQL_TYPE_SHORT:
+ case MYSQL_TYPE_YEAR:
type = TYPE_SHORT;
break;
case MYSQL_TYPE_LONG:
@@ -209,7 +210,6 @@ int MYSQLtoPLG(int mytype, char *var)
case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_DATETIME:
- case MYSQL_TYPE_YEAR:
case MYSQL_TYPE_TIME:
type = TYPE_DATE;
break;
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index 114071b35fb..9af9faa333a 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -91,11 +91,11 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
/* directories are used (to make this even remotely secure). */
/*********************************************************************/
if (check_valid_path(module, strlen(module))) {
- strcpy(g->Message, "Module cannot contain a path");
+ safe_strcpy(g->Message, sizeof(g->Message), "Module cannot contain a path");
return NULL;
}
else if (strlen(subtype)+1+3 >= sizeof(getname)) {
- strcpy(g->Message, "Subtype string too long");
+ safe_strcpy(g->Message, sizeof(g->Message), "Subtype string too long");
return NULL;
}
else
@@ -118,7 +118,8 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char* tab, char* db, bool info)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
- strcat(strcat(g->Message, ": "), buf);
+ safe_strcat(g->Message, sizeof(g->Message), ": ");
+ safe_strcat(g->Message, sizeof(g->Message), buf);
return NULL;
} // endif hDll
@@ -281,7 +282,7 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef)
if (IsFileType(GetTypeID(ftype))) {
name= Hc->GetPartName();
sval= (char*)PlugSubAlloc(g, NULL, strlen(name) + 12);
- strcat(strcpy(sval, name), ".");
+ snprintf(sval, strlen(name) + 12, "%s.", name);
n= strlen(sval);
// Fold ftype to lower case
@@ -623,12 +624,11 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
/* directories are used (to make this even remotely secure). */
/*********************************************************************/
if (check_valid_path(Module, strlen(Module))) {
- strcpy(g->Message, "Module cannot contain a path");
+ safe_strcpy(g->Message, sizeof(g->Message), "Module cannot contain a path");
return NULL;
} else
// PlugSetPath(soname, Module, GetPluginDir()); // Crashes on Fedora
- strncat(strcpy(soname, GetPluginDir()), Module,
- sizeof(soname) - strlen(soname) - 1);
+ snprintf(soname, sizeof(soname), "%s%s", GetPluginDir(), Module);
#if defined(_WIN32)
// Is the DLL already loaded?
@@ -642,7 +642,8 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
- strcat(strcat(g->Message, ": "), buf);
+ safe_strcat(g->Message, sizeof(g->Message), ": ");
+ safe_strcat(g->Message, sizeof(g->Message), buf);
return NULL;
} // endif hDll
@@ -662,7 +663,8 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL);
- strcat(strcat(g->Message, ": "), buf);
+ safe_strcat(g->Message, sizeof(g->Message), ": ");
+ safe_strcat(g->Message, sizeof(g->Message), buf);
FreeLibrary((HMODULE)Hdll);
return NULL;
} // endif getdef
@@ -811,7 +813,7 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
else
txfp = new(g) ZLBFAM(defp);
#else // !GZ_SUPPORT
- strcpy(g->Message, "Compress not supported");
+ safe_strcpy(g->Message, sizeof(g->Message), "Compress not supported");
return NULL;
#endif // !GZ_SUPPORT
} else if (rfm == RECFM_VAR) {
@@ -834,7 +836,7 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
else
txfp = new(g) VCTFAM((PVCTDEF)defp);
#else // !VCT_SUPPORT
- strcpy(g->Message, "VCT no more supported");
+ safe_strcpy(g->Message, sizeof(g->Message), "VCT no more supported");
return NULL;
#endif // !VCT_SUPPORT
} // endif's
@@ -925,7 +927,7 @@ int COLDEF::Define(PGLOBAL g, void *, PCOLINFO cfp, int poff)
return -1;
} // endswitch
- strcpy(F.Type, GetFormatType(Buf_Type));
+ safe_strcpy(F.Type, sizeof(F.Type), GetFormatType(Buf_Type));
F.Length = cfp->Length;
F.Prec = cfp->Scale;
Offset = (cfp->Offset < 0) ? poff : cfp->Offset;
diff --git a/storage/connect/tabbson.cpp b/storage/connect/tabbson.cpp
index 4cbb0e44e19..dfaf2284a72 100644
--- a/storage/connect/tabbson.cpp
+++ b/storage/connect/tabbson.cpp
@@ -39,6 +39,7 @@
#include "checklvl.h"
#include "resource.h"
#include "mycat.h" // for FNC_COL
+#include "m_string.h"
/***********************************************************************/
/* This should be an option. */
@@ -80,7 +81,7 @@ PQRYRES BSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
} // endif info
if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
- strcpy(g->Message, "Cannot find column definition for multiple table");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot find column definition for multiple table");
return NULL;
} // endif Multiple
@@ -206,7 +207,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
tdp->Uri = (dsn && *dsn ? dsn : NULL);
if (!tdp->Fn && !tdp->Uri) {
- strcpy(g->Message, MSG(MISSING_FNAME));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(MISSING_FNAME));
return 0;
} else
topt->subtype = NULL;
@@ -318,7 +319,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
switch (tjnp->ReadDB(g)) {
case RC_EF:
- strcpy(g->Message, "Void json table");
+ safe_strcpy(g->Message, sizeof(g->Message), "Void json table");
case RC_FX:
goto err;
default:
@@ -328,7 +329,7 @@ int BSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} // endif pretty
if (!(row = (jsp) ? bp->GetObject(jsp) : NULL)) {
- strcpy(g->Message, "Can only retrieve columns from object rows");
+ safe_strcpy(g->Message, sizeof(g->Message), "Can only retrieve columns from object rows");
goto err;
} // endif row
@@ -405,7 +406,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
if (jvp && !bp->IsJson(jvp)) {
if (JsonAllPath() && !fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
jcol.Type = (JTYP)jvp->Type;
@@ -439,7 +440,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
jcol.Cbn = true;
} else if (j < lvl && !Stringified(strfy, colname)) {
if (!fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
p = fmt + strlen(fmt);
jsp = jvp;
@@ -510,11 +511,11 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
} else if (lvl >= 0) {
if (Stringified(strfy, colname)) {
if (!fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
- strcat(fmt, ".*");
+ safe_strcat(fmt, sizeof(fmt), ".*");
} else if (JsonAllPath() && !fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
jcol.Type = TYPE_STRG;
jcol.Len = sz;
@@ -961,7 +962,7 @@ PVAL BCUTIL::ExpandArray(PGLOBAL g, PBVAL arp, int n)
} // endif ars
if (!(bvp = GetArrayValue(arp, (nodes[n].Rx = nodes[n].Nx)))) {
- strcpy(g->Message, "Logical error expanding array");
+ safe_strcpy(g->Message, sizeof(g->Message), "Logical error expanding array");
throw 666;
} // endif jvp
@@ -1146,7 +1147,7 @@ PBVAL BCUTIL::GetRow(PGLOBAL g)
} else if (row->Type == TYPE_JAR) {
AddArrayValue(row, (nwr = NewVal(type)));
} else {
- strcpy(g->Message, "Wrong type when writing new row");
+ safe_strcpy(g->Message, sizeof(g->Message), "Wrong type when writing new row");
nwr = NULL;
} // endif's
@@ -1255,7 +1256,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
// Allocate the parse work memory
G = PlugInit(NULL, (size_t)Lrecl * (Pretty < 0 ? 3 : 5));
} else {
- strcpy(g->Message, "LRECL is not defined");
+ safe_strcpy(g->Message, sizeof(g->Message), "LRECL is not defined");
return NULL;
} // endif Lrecl
@@ -1295,7 +1296,7 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
} else if (m == MODE_INSERT) {
txfp = new(g) ZIPFAM(this);
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's m
#else // !ZIP_SUPPORT
@@ -1325,10 +1326,10 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
txfp = new(g) UNZFAM(this);
} else if (m == MODE_INSERT) {
- strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0");
+ safe_strcpy(g->Message, sizeof(g->Message), "INSERT supported only for zipped JSON when pretty=0");
return NULL;
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's m
#else // !ZIP_SUPPORT
@@ -1661,7 +1662,7 @@ bool TDBBSN::PrepareWriting(PGLOBAL g)
strcat(s, ",");
if ((signed)strlen(s) > Lrecl) {
- strncpy(To_Line, s, Lrecl);
+ safe_strcpy(To_Line, Lrecl, s);
snprintf(g->Message, sizeof(g->Message), "Line truncated (lrecl=%d)", Lrecl);
return PushWarning(g, this);
} else
@@ -1764,7 +1765,7 @@ bool BSONCOL::CheckExpand(PGLOBAL g, int i, PSZ nm, bool b)
Xpd = true; // Expandable object
Nodes[i].Op = OP_EXP;
} else if (b) {
- strcpy(g->Message, "Cannot expand more than one branch");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot expand more than one branch");
return true;
} // endif Xcol
@@ -1975,7 +1976,7 @@ bool BSONCOL::ParseJpath(PGLOBAL g)
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
return true;
else if (Xpd && Tbp->Mode == MODE_DELETE) {
- strcpy(g->Message, "Cannot delete expanded columns");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot delete expanded columns");
return true;
} // endif Xpd
@@ -2098,7 +2099,7 @@ void BSONCOL::ReadColumn(PGLOBAL g)
void BSONCOL::WriteColumn(PGLOBAL g)
{
if (Xpd && Tbp->Pretty < 2) {
- strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot write expanded column when Pretty is not 2");
throw 666;
} // endif Xpd
@@ -2128,7 +2129,7 @@ void BSONCOL::WriteColumn(PGLOBAL g)
char *s = Value->GetCharValue();
if (!(jsp = Cp->ParseJson(g, s, strlen(s)))) {
- strcpy(g->Message, s);
+ safe_strcpy(g->Message, sizeof(g->Message), s);
throw 666;
} // endif jsp
@@ -2314,7 +2315,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
if (!a && *p && *p != '[' && !IsNum(p)) {
// obj is a key
if (jsp->Type != TYPE_JOB) {
- strcpy(g->Message, "Table path does not match the json file");
+ safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file");
return RC_FX;
} // endif Type
@@ -2340,7 +2341,7 @@ int TDBBSON::MakeDocument(PGLOBAL g)
} // endif p
if (jsp->Type != TYPE_JAR) {
- strcpy(g->Message, "Table path does not match the json file");
+ safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file");
return RC_FX;
} // endif Type
@@ -2434,7 +2435,7 @@ void TDBBSON::ResetSize(void)
int TDBBSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool)
{
if (pxdf) {
- strcpy(g->Message, "JSON not indexable when pretty = 2");
+ safe_strcpy(g->Message, sizeof(g->Message), "JSON not indexable when pretty = 2");
return RC_FX;
} else
return RC_OK;
diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp
index 62eecb5e69e..0fdc182f6df 100644
--- a/storage/connect/tabdos.cpp
+++ b/storage/connect/tabdos.cpp
@@ -62,6 +62,7 @@
#include "tabmul.h"
#include "array.h"
#include "blkfil.h"
+#include "m_string.h"
/***********************************************************************/
/* DB static variables. */
@@ -258,7 +259,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
sep = GetBoolCatInfo("SepIndex", false);
if (!sep && pxdf) {
- strcpy(g->Message, MSG(NO_RECOV_SPACE));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(NO_RECOV_SPACE));
return true;
} // endif sep
@@ -293,7 +294,8 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
for (; pxdf; pxdf = pxdf->GetNext()) {
_splitpath(Ofn, drive, direc, fname, NULL);
- strcat(strcat(fname, "_"), pxdf->GetName());
+ safe_strcat(fname, sizeof(fname), "_");
+ safe_strcat(fname, sizeof(fname), pxdf->GetName());
_makepath(filename, drive, direc, fname, ftype);
PlugSetPath(filename, filename, GetPath());
#if defined(_WIN32)
@@ -312,7 +314,7 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
} else { // !sep
// Drop all indexes, delete the common file
PlugSetPath(filename, Ofn, GetPath());
- strcat(PlugRemoveType(filename, filename), ftype);
+ safe_strcat(PlugRemoveType(filename, filename), sizeof(filename), ftype);
#if defined(_WIN32)
if (!DeleteFile(filename))
rc = (GetLastError() != ERROR_FILE_NOT_FOUND);
@@ -365,7 +367,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
if (mode == MODE_READ || mode == MODE_ANY || mode == MODE_ALTER) {
txfp = new(g) UZDFAM(this);
} else {
- strcpy(g->Message, "Zipped DBF tables are read only");
+ safe_strcpy(g->Message, sizeof(g->Message), "Zipped DBF tables are read only");
return NULL;
} // endif's mode
@@ -386,7 +388,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
} else if (mode == MODE_INSERT) {
txfp = new(g) ZIPFAM(this);
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's mode
@@ -397,7 +399,7 @@ PTDB DOSDEF::GetTable(PGLOBAL g, MODE mode)
} else if (mode == MODE_INSERT) {
txfp = new(g) ZPXFAM(this);
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's mode
@@ -655,7 +657,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
if ((nrec = defp->GetElemt()) < 2) {
if (!To_Def->Partitioned()) {
// This may be wrong to do in some cases
- strcpy(g->Message, MSG(TABLE_NOT_OPT));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(TABLE_NOT_OPT));
return RC_INFO; // Not to be optimized
} else
return RC_OK;
@@ -675,7 +677,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
if ((block = (int)((MaxSize + (int)nrec - 1) / (int)nrec)) < 2) {
// This may be wrong to do in some cases
defp->RemoveOptValues(g);
- strcpy(g->Message, MSG(TABLE_NOT_OPT));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(TABLE_NOT_OPT));
return RC_INFO; // Not to be optimized
} // endif block
@@ -758,7 +760,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
// No optimised columns. Still useful for blocked variable tables.
if (!colp && defp->Recfm != RECFM_VAR) {
- strcpy(g->Message, "No optimised columns");
+ safe_strcpy(g->Message, sizeof(g->Message), "No optimised columns");
return RC_INFO;
} // endif colp
@@ -788,7 +790,8 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
/*********************************************************************/
char *p = (char *)PlugSubAlloc(g, NULL, 24 + strlen(Name));
- dup->Step = strcat(strcpy(p, MSG(OPTIMIZING)), Name);
+ snprintf(p, 24 + strlen(Name), "%s%s", MSG(OPTIMIZING), Name);
+ dup->Step = p;
dup->ProgMax = GetProgMax(g);
dup->ProgCur = 0;
#endif // SOCKET_MODE || THREAD
@@ -805,7 +808,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
} else {
if (++curnum >= nrec) {
if (++curblk >= block) {
- strcpy(g->Message, MSG(BAD_BLK_ESTIM));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(BAD_BLK_ESTIM));
goto err;
} else
curnum = 0;
@@ -833,7 +836,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
#if defined(PROG_INFO)
if (!dup->Step) {
- strcpy(g->Message, MSG(OPT_CANCELLED));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(OPT_CANCELLED));
goto err;
} else
dup->ProgCur = GetProgCur();
@@ -913,7 +916,8 @@ bool TDBDOS::SaveBlockValues(PGLOBAL g)
if (!(opfile = fopen(filename, "wb"))) {
snprintf(g->Message, sizeof(g->Message), MSG(OPEN_MODE_ERROR),
"wb", (int)errno, filename);
- strcat(strcat(g->Message, ": "), strerror(errno));
+ safe_strcat(g->Message, sizeof(g->Message), ": ");
+ safe_strcat(g->Message, sizeof(g->Message), strerror(errno));
if (trace(1))
htrc("%s\n", g->Message);
@@ -1230,7 +1234,8 @@ bool TDBDOS::GetDistinctColumnValues(PGLOBAL g, int nrec)
/* Initialize progress information */
/*********************************************************************/
p = (char *)PlugSubAlloc(g, NULL, 48 + strlen(Name));
- dup->Step = strcat(strcpy(p, MSG(GET_DIST_VALS)), Name);
+ snprintf(p, 48 + strlen(Name), "%s%s", MSG(GET_DIST_VALS), Name);
+ dup->Step = p;
dup->ProgMax = GetProgMax(g);
dup->ProgCur = 0;
@@ -1242,12 +1247,12 @@ bool TDBDOS::GetDistinctColumnValues(PGLOBAL g, int nrec)
#if defined(SOCKET_MODE)
if (SendProgress(dup)) {
- strcpy(g->Message, MSG(OPT_CANCELLED));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(OPT_CANCELLED));
return true;
} else
#elif defined(THREAD)
if (!dup->Step) {
- strcpy(g->Message, MSG(OPT_CANCELLED));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(OPT_CANCELLED));
return true;
} else
#endif // THREAD
@@ -1528,7 +1533,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
} else if (n == 8 || n == 14) {
if (n == 8 && ctype != TYPE_LIST) {
// Should never happen
- strcpy(g->Message, "Block opt: bad constant");
+ safe_strcpy(g->Message, sizeof(g->Message), "Block opt: bad constant");
throw 99;
} // endif Conv
@@ -1686,7 +1691,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
// Are we are called from CreateTable or CreateIndex?
if (pxdf) {
if (!add && dfp->GetIndx()) {
- strcpy(g->Message, MSG(INDX_EXIST_YET));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(INDX_EXIST_YET));
return RC_FX;
} // endif To_Indx
@@ -1798,7 +1803,7 @@ int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
htrc("Exception %d: %s\n", n, g->Message);
rc = RC_FX;
} catch (const char *msg) {
- strcpy(g->Message, msg);
+ safe_strcpy(g->Message, sizeof(g->Message), msg);
rc = RC_FX;
} // end catch
@@ -1832,7 +1837,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
PKPDEF kdp;
if (!xdp && !(xdp = To_Xdp)) {
- strcpy(g->Message, "NULL dynamic index");
+ safe_strcpy(g->Message, sizeof(g->Message), "NULL dynamic index");
return true;
} else
dynamic = To_Filter && xdp->IsUnique() && xdp->IsDynamic();
@@ -1921,7 +1926,7 @@ bool TDBDOS::InitialyzeIndex(PGLOBAL g, volatile PIXDEF xdp, bool sorted)
htrc("Exception %d: %s\n", n, g->Message);
brc = true;
} catch (const char *msg) {
- strcpy(g->Message, msg);
+ safe_strcpy(g->Message, sizeof(g->Message), msg);
brc = true;
} // end catch
@@ -2682,38 +2687,38 @@ void DOSCOL::WriteColumn(PGLOBAL g)
if (Ldz || Nod || Dcm >= 0) {
switch (Buf_Type) {
case TYPE_SHORT:
- strcpy(fmt, (Ldz) ? "%0*hd" : "%*.hd");
+ safe_strcpy(fmt, sizeof(fmt), (Ldz) ? "%0*hd" : "%*.hd");
i = 0;
if (Nod)
for (; i < Dcm; i++)
- strcat(fmt, "0");
+ safe_strcat(fmt, sizeof(fmt), "0");
len = sprintf(Buf, fmt, field - i, Value->GetShortValue());
break;
case TYPE_INT:
- strcpy(fmt, (Ldz) ? "%0*d" : "%*.d");
+ safe_strcpy(fmt, sizeof(fmt), (Ldz) ? "%0*d" : "%*.d");
i = 0;
if (Nod)
for (; i < Dcm; i++)
- strcat(fmt, "0");
+ safe_strcat(fmt,sizeof(fmt), "0");
len = sprintf(Buf, fmt, field - i, Value->GetIntValue());
break;
case TYPE_TINY:
- strcpy(fmt, (Ldz) ? "%0*d" : "%*.d");
+ safe_strcpy(fmt, sizeof(fmt), (Ldz) ? "%0*d" : "%*.d");
i = 0;
if (Nod)
for (; i < Dcm; i++)
- strcat(fmt, "0");
+ safe_strcat(fmt, sizeof(fmt), "0");
len = sprintf(Buf, fmt, field - i, Value->GetTinyValue());
break;
case TYPE_DOUBLE:
case TYPE_DECIM:
- strcpy(fmt, (Ldz) ? "%0*.*lf" : "%*.*lf");
+ safe_strcpy(fmt, sizeof(fmt), (Ldz) ? "%0*.*lf" : "%*.*lf");
len = field + ((Nod && Dcm) ? 1 : 0);
snprintf(Buf, len + 1, fmt, len, Dcm, Value->GetFloatValue());
len = strlen(Buf);
diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp
index 6ece7115ea5..f558cb04f4d 100644
--- a/storage/connect/tabext.cpp
+++ b/storage/connect/tabext.cpp
@@ -65,7 +65,7 @@ int CONDFIL::Init(PGLOBAL g, PHC hc)
while (alt) {
if (!(p = strchr(alt, '='))) {
- strcpy(g->Message, "Invalid alias list");
+ safe_strcpy(g->Message, sizeof(g->Message), "Invalid alias list");
rc = RC_FX;
break;
} // endif !p
@@ -126,7 +126,7 @@ EXTDEF::EXTDEF(void)
bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
if (g->Createas) {
- strcpy(g->Message,
+ safe_strcpy(g->Message, sizeof(g->Message),
"Multiple-table UPDATE/DELETE commands are not supported");
return true;
} // endif multi
@@ -349,7 +349,7 @@ bool TDBEXT::MakeSrcdef(PGLOBAL g)
int n_placeholders = count_placeholders(Srcdef);
if (n_placeholders < 0)
{
- strcpy(g->Message, "MakeSQL: Wrong place holders specification");
+ safe_strcpy(g->Message, sizeof(g->Message), "MakeSQL: Wrong place holders specification");
return true;
}
@@ -372,7 +372,7 @@ bool TDBEXT::MakeSrcdef(PGLOBAL g)
Query = new(g)STRING(g, strlen(Srcdef) + strlen(fil1) + strlen(fil2));
Query->SetLength(sprintf(Query->GetStr(), Srcdef, fil2, fil1));
} else {
- strcpy(g->Message, "MakeSQL: Wrong place holders specification");
+ safe_strcpy(g->Message, sizeof(g->Message), "MakeSQL: Wrong place holders specification");
return true;
} // endif's ph
@@ -466,7 +466,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
if (Quote) {
// Tabname can have both database and table identifiers, we need to parse
- if ((res= strstr(buf, ".")))
+ if ((res= strstr(buf, ".")))
{
// Parse schema
my_len= res - buf + 1;
@@ -513,7 +513,7 @@ bool TDBEXT::MakeSQL(PGLOBAL g, bool cnt)
len += ((Mode == MODE_READX) ? 256 : 1);
if (Query->IsTruncated()) {
- strcpy(g->Message, "MakeSQL: Out of memory");
+ safe_strcpy(g->Message, sizeof(g->Message), "MakeSQL: Out of memory");
return true;
} else
Query->Resize(len);
@@ -574,6 +574,7 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
bool qtd = Quoted > 0;
char q = qtd ? *Quote : ' ';
int i = 0, k = 0;
+ size_t stmt_sz = 0;
// Make a lower case copy of the originale query and change
// back ticks to the data source identifier quoting character
@@ -585,26 +586,30 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
p[7] = 0; // Remove where clause
Qrystr[(p - qrystr) + 7] = 0;
body = To_CondFil->Body;
- stmt = (char*)PlugSubAlloc(g, NULL, strlen(qrystr)
- + strlen(body) + 64);
+ stmt_sz = strlen(qrystr) + strlen(body) + 64;
} else
- stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64);
+ stmt_sz = strlen(Qrystr) + 64;
+ stmt = (char*)PlugSubAlloc(g, NULL, stmt_sz);
// Check whether the table name is equal to a keyword
// If so, it must be quoted in the original query
- strlwr(strcat(strcat(strcpy(name, " "), Name), " "));
+ snprintf(name, sizeof(name), " %s ", Name);
+ strlwr(name);
if (strstr(" update delete low_priority ignore quick from ", name)) {
if (Quote) {
- strlwr(strcat(strcat(strcpy(name, Quote), Name), Quote));
+ snprintf(name, sizeof(name), "%s%s%s", Quote, Name, Quote);
+ strlwr(name);
k += 2;
} else {
- strcpy(g->Message, "Quoted must be specified");
+ safe_strcpy(g->Message, sizeof(g->Message), "Quoted must be specified");
return true;
} // endif Quote
- } else
- strlwr(strcpy(name, Name)); // Not a keyword
+ } else {
+ safe_strcpy(name, sizeof(name), Name); // Not a keyword
+ strlwr(name);
+ }
if ((p = strstr(qrystr, name))) {
for (i = 0; i < p - qrystr; i++)
@@ -618,21 +623,29 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
schmp = Schema;
if (qtd && *(p - 1) == ' ') {
- if (schmp)
- strcat(strcat(stmt, schmp), ".");
+ if (schmp) {
+ safe_strcat(stmt, stmt_sz, schmp);
+ safe_strcat(stmt, stmt_sz, ".");
+ }
- strcat(strcat(strcat(stmt, Quote), TableName), Quote);
+ safe_strcat(stmt, stmt_sz, Quote);
+ safe_strcat(stmt, stmt_sz, TableName);
+ safe_strcat(stmt, stmt_sz, Quote);
} else {
if (schmp) {
if (qtd && *(p - 1) != ' ') {
stmt[i - 1] = 0;
- strcat(strcat(strcat(stmt, schmp), "."), Quote);
- } else
- strcat(strcat(stmt, schmp), ".");
+ safe_strcat(stmt, stmt_sz, schmp);
+ safe_strcat(stmt, stmt_sz, ".");
+ safe_strcat(stmt, stmt_sz, Quote);
+ } else {
+ safe_strcat(stmt, stmt_sz, schmp);
+ safe_strcat(stmt, stmt_sz, ".");
+ }
} // endif schmp
- strcat(stmt, TableName);
+ safe_strcat(stmt, stmt_sz, TableName);
} // endif's
i = (int)strlen(stmt);
@@ -644,7 +657,7 @@ bool TDBEXT::MakeCommand(PGLOBAL g)
RemoveConst(g, stmt);
if (body)
- strcat(stmt, body);
+ safe_strcat(stmt, stmt_sz, body);
} else {
snprintf(g->Message, sizeof(g->Message), "Cannot use this %s command",
diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp
index 7edffc638fa..037a465af13 100644
--- a/storage/connect/tabfmt.cpp
+++ b/storage/connect/tabfmt.cpp
@@ -62,6 +62,7 @@
#define NO_FUNC
#include "plgcnx.h" // For DB types
#include "resource.h"
+#include "m_string.h"
/***********************************************************************/
/* This should be an option. */
@@ -137,7 +138,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
? strchr(tdp->Entry, '*') || strchr(tdp->Entry, '?')
: GetBooleanTableOption(g, topt, "Mulentries", false);
#else // !ZIP_SUPPORT
- strcpy(g->Message, "ZIP not supported by this version");
+ safe_strcpy(g->Message, sizeof(g->Message), "ZIP not supported by this version");
return NULL;
#endif // !ZIP_SUPPORT
} // endif // Zipped
@@ -145,7 +146,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
fn = tdp->Fn = GetStringTableOption(g, topt, "Filename", NULL);
if (!tdp->Fn) {
- strcpy(g->Message, MSG(MISSING_FNAME));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(MISSING_FNAME));
return NULL;
} // endif Fn
@@ -472,7 +473,7 @@ bool CSVDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if (Catfunc == FNC_NO)
for (PCOLDEF cdp = To_Cols; cdp; cdp = cdp->GetNext())
if (cdp->GetOffset() < 1 && !cdp->IsSpecial()) {
- strcpy(g->Message, MSG(BAD_OFFSET_VAL));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(BAD_OFFSET_VAL));
return true;
} // endif Offset
@@ -528,11 +529,11 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
} else if (mode == MODE_INSERT) {
txfp = new(g) ZIPFAM(this);
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's mode
#else // !ZIP_SUPPORT
- strcpy(g->Message, "ZIP not supported");
+ safe_strcpy(g->Message, sizeof(g->Message), "ZIP not supported");
return NULL;
#endif // !ZIP_SUPPORT
} else if (map) {
@@ -546,7 +547,7 @@ PTDB CSVDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) ZLBFAM(this);
#else // !GZ_SUPPORT
- strcpy(g->Message, "Compress not supported");
+ safe_strcpy(g->Message, sizeof(g->Message), "Compress not supported");
return NULL;
#endif // !GZ_SUPPORT
} else
@@ -878,7 +879,7 @@ bool TDBCSV::SkipHeader(PGLOBAL g)
if (q)
To_Line[strlen(To_Line)] = Qot;
- strcat(To_Line, cdp->GetName());
+ safe_strcat(To_Line, Lrecl, cdp->GetName());
if (q)
To_Line[strlen(To_Line)] = Qot;
@@ -1048,14 +1049,16 @@ bool TDBCSV::PrepareWriting(PGLOBAL g)
for (i = 0; i < Fields; i++) {
if (i)
- strcat(To_Line, sep);
+ safe_strcat(To_Line, Lrecl, sep);
if (Field[i]) {
if (!strlen(Field[i])) {
// Generally null fields are not quoted
- if (Quoted > 2)
+ if (Quoted > 2) {
// Except if explicitly required
- strcat(strcat(To_Line, qot), qot);
+ safe_strcat(To_Line, Lrecl, qot);
+ safe_strcat(To_Line, Lrecl, qot);
+ }
} else if (Qot && (strchr(Field[i], Sep) || *Field[i] == Qot
|| Quoted > 1 || (Quoted == 1 && !Fldtyp[i]))) {
@@ -1074,12 +1077,15 @@ bool TDBCSV::PrepareWriting(PGLOBAL g)
To_Line[k++] = Qot;
To_Line[k] = '\0';
- } else
- strcat(strcat(strcat(To_Line, qot), Field[i]), qot);
+ } else {
+ safe_strcat(To_Line, Lrecl, qot);
+ safe_strcat(To_Line, Lrecl, Field[i]);
+ safe_strcat(To_Line, Lrecl, qot);
+ }
}
else
- strcat(To_Line, Field[i]);
+ safe_strcat(To_Line, Lrecl, Field[i]);
}
} // endfor i
@@ -1156,7 +1162,7 @@ int TDBCSV::CheckWrite(PGLOBAL g)
} // endif
}
if ((nlen += n) > maxlen) {
- strcpy(g->Message, MSG(LINE_TOO_LONG));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(LINE_TOO_LONG));
return -1;
} // endif nlen
@@ -1266,7 +1272,7 @@ bool TDBFMT::OpenDB(PGLOBAL g)
} // endif n
FldFormat[i] = (PSZ)PlugSubAlloc(g, NULL, n + 5);
- strcpy(FldFormat[i], pfm);
+ safe_strcpy(FldFormat[i], n + 5, pfm);
if (!strcmp(pfm + n, "%m")) {
// This is a field that can be missing. Flag it so it can
@@ -1276,7 +1282,7 @@ bool TDBFMT::OpenDB(PGLOBAL g)
} else if (i+1 < Fields && strcmp(pfm + n, "%n")) {
// There are trailing characters after the field contents
// add a marker for the next field start position.
- strcat(FldFormat[i], "%n");
+ safe_strcat(FldFormat[i], n + 5, "%n");
FmtTest[i] = 1;
} // endif's
diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp
index 46fb7695a51..0242832b02f 100644
--- a/storage/connect/tabjdbc.cpp
+++ b/storage/connect/tabjdbc.cpp
@@ -277,7 +277,7 @@ PTDB JDBCDEF::GetTable(PGLOBAL g, MODE m)
if (Multiple == 1)
tdbp = new(g)TDBMUL(tdbp);
else if (Multiple == 2)
- strcpy(g->Message, "NO_JDBC_MUL");
+ safe_strcpy(g->Message, sizeof(g->Message), "NO_JDBC_MUL");
} // endswitch Catfunc
@@ -386,7 +386,7 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
for (colp = Columns; colp; colp = colp->GetNext())
if (colp->IsSpecial()) {
- strcpy(g->Message, "No JDBC special columns");
+ safe_strcpy(g->Message, sizeof(g->Message), "No JDBC special columns");
return true;
} else {
// Column name can be encoded in UTF-8
@@ -460,7 +460,7 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
} // endfor colp
if ((Query->Append(") VALUES ("))) {
- strcpy(g->Message, "MakeInsert: Out of memory");
+ safe_strcpy(g->Message, sizeof(g->Message), "MakeInsert: Out of memory");
return true;
} else // in case prepared statement fails
pos = Query->GetLength();
@@ -470,7 +470,7 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
Query->Append("?,");
if (Query->IsTruncated()) {
- strcpy(g->Message, "MakeInsert: Out of memory");
+ safe_strcpy(g->Message, sizeof(g->Message), "MakeInsert: Out of memory");
return true;
} else
Query->RepLast(')');
@@ -532,12 +532,15 @@ int TDBJDBC::Cardinality(PGLOBAL g)
// Table name can be encoded in UTF-8
Decode(TableName, tbn, sizeof(tbn));
- strcpy(qry, "SELECT COUNT(*) FROM ");
+ safe_strcpy(qry, sizeof(qry), "SELECT COUNT(*) FROM ");
- if (Quote)
- strcat(strcat(strcat(qry, Quote), tbn), Quote);
+ if (Quote) {
+ safe_strcat(qry, sizeof(qry), Quote);
+ safe_strcat(qry, sizeof(qry), tbn);
+ safe_strcat(qry, sizeof(qry), Quote);
+ }
else
- strcat(qry, tbn);
+ safe_strcat(qry, sizeof(qry), tbn);
// Allocate a Count(*) column (must not use the default constructor)
Cnp = new(g)JDBCCOL;
@@ -656,7 +659,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
if ((Qrp = Jcp->AllocateResult(g, this)))
Memory = 2; // Must be filled
else {
- strcpy(g->Message, "Result set memory allocation failed");
+ safe_strcpy(g->Message, sizeof(g->Message), "Result set memory allocation failed");
return true;
} // endif n
@@ -683,7 +686,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
#if 0
if (!(rc = MakeInsert(g))) {
if (Nparm != Jcp->PrepareSQL(Query->GetStr())) {
- strcpy(g->Message, MSG(PARM_CNT_MISS));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(PARM_CNT_MISS));
rc = true;
} else
rc = BindParameters(g);
@@ -735,12 +738,12 @@ bool TDBJDBC::SetRecpos(PGLOBAL g, int recpos)
CurNum = recpos;
Fpos = recpos;
} else {
- strcpy(g->Message, "Scrolling out of row set NIY");
+ safe_strcpy(g->Message, sizeof(g->Message), "Scrolling out of row set NIY");
return true;
} // endif recpos
} else {
- strcpy(g->Message, "This action requires a scrollable cursor");
+ safe_strcpy(g->Message, sizeof(g->Message), "This action requires a scrollable cursor");
return true;
} // endif's
@@ -786,7 +789,7 @@ bool TDBJDBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
if (To_CondFil)
if (Query->Append(" AND ") || Query->Append(To_CondFil->Body)) {
- strcpy(g->Message, "Readkey: Out of memory");
+ safe_strcpy(g->Message, sizeof(g->Message), "Readkey: Out of memory");
return true;
} // endif Append
@@ -919,7 +922,7 @@ int TDBJDBC::WriteDB(PGLOBAL g)
} // endfor colp
if (unlikely(Query->IsTruncated())) {
- strcpy(g->Message, "WriteDB: Out of memory");
+ safe_strcpy(g->Message, sizeof(g->Message), "WriteDB: Out of memory");
return RC_FX;
} // endif Query
@@ -1112,13 +1115,13 @@ PCMD TDBXJDC::MakeCMD(PGLOBAL g)
(To_CondFil->Op == OP_EQ || To_CondFil->Op == OP_IN)) {
xcmd = To_CondFil->Cmds;
} else
- strcpy(g->Message, "Invalid command specification filter");
+ safe_strcpy(g->Message, sizeof(g->Message), "Invalid command specification filter");
} else
- strcpy(g->Message, "No command column in select list");
+ safe_strcpy(g->Message, sizeof(g->Message), "No command column in select list");
} else if (!Srcdef)
- strcpy(g->Message, "No Srcdef default command");
+ safe_strcpy(g->Message, sizeof(g->Message), "No Srcdef default command");
else
xcmd = new(g) CMD(g, Srcdef);
@@ -1149,7 +1152,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
this, Tdb_No, Use, Mode);
if (Use == USE_OPEN) {
- strcpy(g->Message, "Multiple execution is not allowed");
+ safe_strcpy(g->Message, sizeof(g->Message), "Multiple execution is not allowed");
return true;
} // endif use
@@ -1171,7 +1174,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
Use = USE_OPEN; // Do it now in case we are recursively called
if (Mode != MODE_READ && Mode != MODE_READX) {
- strcpy(g->Message, "No INSERT/DELETE/UPDATE of XJDBC tables");
+ safe_strcpy(g->Message, sizeof(g->Message), "No INSERT/DELETE/UPDATE of XJDBC tables");
return true;
} // endif Mode
@@ -1224,7 +1227,7 @@ int TDBXJDC::ReadDB(PGLOBAL g)
/***********************************************************************/
int TDBXJDC::WriteDB(PGLOBAL g)
{
- strcpy(g->Message, "Execsrc tables are read only");
+ safe_strcpy(g->Message, sizeof(g->Message), "Execsrc tables are read only");
return RC_FX;
} // end of DeleteDB
@@ -1233,7 +1236,7 @@ int TDBXJDC::WriteDB(PGLOBAL g)
/***********************************************************************/
int TDBXJDC::DeleteDB(PGLOBAL g, int irc)
{
- strcpy(g->Message, "NO_XJDBC_DELETE");
+ safe_strcpy(g->Message, sizeof(g->Message), "NO_XJDBC_DELETE");
return RC_FX;
} // end of DeleteDB
diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp
index 968253ec8d1..27bdfee5f35 100644
--- a/storage/connect/tabjson.cpp
+++ b/storage/connect/tabjson.cpp
@@ -85,7 +85,7 @@ PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info)
} // endif info
if (GetIntegerTableOption(g, topt, "Multiple", 0)) {
- strcpy(g->Message, "Cannot find column definition for multiple table");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot find column definition for multiple table");
return NULL;
} // endif Multiple
@@ -212,7 +212,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
tdp->Uri = (dsn && *dsn ? dsn : NULL);
if (!tdp->Fn && !tdp->Uri) {
- strcpy(g->Message, MSG(MISSING_FNAME));
+ safe_strcpy(g->Message, sizeof(g->Message), MSG(MISSING_FNAME));
return 0;
} else
topt->subtype = NULL;
@@ -320,7 +320,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
switch (tjnp->ReadDB(g)) {
case RC_EF:
- strcpy(g->Message, "Void json table");
+ safe_strcpy(g->Message, sizeof(g->Message), "Void json table");
case RC_FX:
goto err;
default:
@@ -333,7 +333,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
} // endif pretty
if (!(row = (jsp) ? jsp->GetObject() : NULL)) {
- strcpy(g->Message, "Can only retrieve columns from object rows");
+ safe_strcpy(g->Message, sizeof(g->Message), "Can only retrieve columns from object rows");
goto err;
} // endif row
@@ -417,7 +417,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
if (jvp && jvp->DataType != TYPE_JSON) {
if (JsonAllPath() && !fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
jcol.Type = jvp->DataType;
@@ -450,7 +450,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
jcol.Cbn = true;
} else if (j < lvl && !Stringified(strfy, colname)) {
if (!fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
p = fmt + strlen(fmt);
jsp = jvp->GetJson();
@@ -520,11 +520,11 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
} else if (lvl >= 0) {
if (Stringified(strfy, colname)) {
if (!fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
- strcat(fmt, ".*");
+ safe_strcat(fmt, sizeof(fmt), ".*");
} else if (JsonAllPath() && !fmt[bf])
- strcat(fmt, colname);
+ safe_strcat(fmt, sizeof(fmt), colname);
jcol.Type = TYPE_STRG;
jcol.Len = sz;
@@ -735,7 +735,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
} else if (m == MODE_INSERT) {
txfp = new(g) ZIPFAM(this);
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's m
#else // !ZIP_SUPPORT
@@ -775,7 +775,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
#endif // 0
((TDBJSN*)tdbp)->G = PlugInit(NULL, (size_t)Lrecl * (Pretty >= 0 ? 12 : 4));
} else {
- strcpy(g->Message, "LRECL is not defined");
+ safe_strcpy(g->Message, sizeof(g->Message), "LRECL is not defined");
return NULL;
} // endif Lrecl
@@ -785,10 +785,10 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m)
if (m == MODE_READ || m == MODE_ANY || m == MODE_ALTER) {
txfp = new(g) UNZFAM(this);
} else if (m == MODE_INSERT) {
- strcpy(g->Message, "INSERT supported only for zipped JSON when pretty=0");
+ safe_strcpy(g->Message, sizeof(g->Message), "INSERT supported only for zipped JSON when pretty=0");
return NULL;
} else {
- strcpy(g->Message, "UPDATE/DELETE not supported for ZIP");
+ safe_strcpy(g->Message, sizeof(g->Message), "UPDATE/DELETE not supported for ZIP");
return NULL;
} // endif's m
#else // !ZIP_SUPPORT
@@ -1144,7 +1144,7 @@ int TDBJSN::ReadDB(PGLOBAL g) {
M = 1;
rc = RC_OK;
} else if (Pretty != 1 || strcmp(To_Line, "]")) {
- strcpy(g->Message, G->Message);
+ safe_strcpy(g->Message, sizeof(g->Message), G->Message);
rc = RC_FX;
} else
rc = RC_EF;
@@ -1257,7 +1257,7 @@ bool TDBJSN::PrepareWriting(PGLOBAL g)
strcat(s, ",");
if ((signed)strlen(s) > Lrecl) {
- strncpy(To_Line, s, Lrecl);
+ safe_strcpy(To_Line, Lrecl, s);
snprintf(g->Message, sizeof(g->Message), "Line truncated (lrecl=%d)", Lrecl);
return PushWarning(g, this);
} else
@@ -1359,7 +1359,7 @@ bool JSONCOL::CheckExpand(PGLOBAL g, int i, PSZ nm, bool b)
Xpd = true; // Expandable object
Nodes[i].Op = OP_EXP;
} else if (b) {
- strcpy(g->Message, "Cannot expand more than one branch");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot expand more than one branch");
return true;
} // endif Xcol
@@ -1570,7 +1570,7 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
if (SetArrayOptions(g, p, i, Nodes[i - 1].Key))
return true;
else if (Xpd && Tjp->Mode == MODE_DELETE) {
- strcpy(g->Message, "Cannot delete expanded columns");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot delete expanded columns");
return true;
} // endif Xpd
@@ -1674,7 +1674,7 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj)
PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp, int n)
{
if (Value->IsTypeNum()) {
- strcpy(g->Message, "Cannot make Json for a numeric column");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot make Json for a numeric column");
if (!Warned) {
PushWarning(g, Tjp);
@@ -1689,10 +1689,10 @@ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp, int n)
ulong len = Tjp->Lrecl ? Tjp->Lrecl : 500;
PBSON bsp = JbinAlloc(g, NULL, len, jsp);
- strcat(bsp->Msg, " column");
+ safe_strcat(bsp->Msg, sizeof(bsp->Msg), " column");
((BINVAL*)Value)->SetBinValue(bsp, sizeof(BSON));
} else {
- strcpy(g->Message, "Column size too small");
+ safe_strcpy(g->Message, sizeof(g->Message), "Column size too small");
Value->SetValue_char(NULL, 0);
} // endif Clen
#endif // 0
@@ -1934,7 +1934,7 @@ PVAL JSONCOL::ExpandArray(PGLOBAL g, PJAR arp, int n)
} // endif ars
if (!(jvp = arp->GetArrayValue((Nodes[n].Rx = Nodes[n].Nx)))) {
- strcpy(g->Message, "Logical error expanding array");
+ safe_strcpy(g->Message, sizeof(g->Message), "Logical error expanding array");
throw 666;
} // endif jvp
@@ -2122,7 +2122,7 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
((PJAR)row)->AddArrayValue(G, new(G) JVALUE(nwr));
((PJAR)row)->InitArray(G);
} else {
- strcpy(g->Message, "Wrong type when writing new row");
+ safe_strcpy(g->Message, sizeof(g->Message), "Wrong type when writing new row");
nwr = NULL;
} // endif's
@@ -2143,7 +2143,7 @@ PJSON JSONCOL::GetRow(PGLOBAL g)
void JSONCOL::WriteColumn(PGLOBAL g)
{
if (Xpd && Tjp->Pretty < 2) {
- strcpy(g->Message, "Cannot write expanded column when Pretty is not 2");
+ safe_strcpy(g->Message, sizeof(g->Message), "Cannot write expanded column when Pretty is not 2");
throw 666;
} // endif Xpd
@@ -2179,7 +2179,7 @@ void JSONCOL::WriteColumn(PGLOBAL g)
if (s && *s) {
if (!(jsp = ParseJson(G, s, strlen(s)))) {
- strcpy(g->Message, s);
+ safe_strcpy(g->Message, sizeof(g->Message), s);
throw 666;
} // endif jsp
@@ -2362,7 +2362,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
if (!a && *p && *p != '[' && !IsNum(p)) {
// obj is a key
if (jsp->GetType() != TYPE_JOB) {
- strcpy(g->Message, "Table path does not match the json file");
+ safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file");
return RC_FX;
} // endif Type
@@ -2388,7 +2388,7 @@ int TDBJSON::MakeDocument(PGLOBAL g)
} // endif p
if (jsp->GetType() != TYPE_JAR) {
- strcpy(g->Message, "Table path does not match the json file");
+ safe_strcpy(g->Message, sizeof(g->Message), "Table path does not match the json file");
return RC_FX;
} // endif Type
@@ -2483,7 +2483,7 @@ void TDBJSON::ResetSize(void)
int TDBJSON::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool)
{
if (pxdf) {
- strcpy(g->Message, "JSON not indexable when pretty = 2");
+ safe_strcpy(g->Message, sizeof(g->Message), "JSON not indexable when pretty = 2");
return RC_FX;
} else
return RC_OK;
diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp
index 498ec71a87f..7265b2ed0ca 100644
--- a/storage/connect/value.cpp
+++ b/storage/connect/value.cpp
@@ -163,9 +163,9 @@ PCSZ GetTypeName(int type)
/***********************************************************************/
/* GetTypeSize: returns the PlugDB internal type size. */
/***********************************************************************/
-int GetTypeSize(int type, int len)
- {
- switch (type) {
+unsigned GetTypeSize(int type, unsigned len)
+{
+ switch (type) {
case TYPE_DECIM:
case TYPE_BIN:
case TYPE_STRING: len = len * sizeof(char); break;
@@ -176,7 +176,7 @@ int GetTypeSize(int type, int len)
case TYPE_DOUBLE: len = sizeof(double); break;
case TYPE_TINY: len = sizeof(char); break;
case TYPE_PCHAR: len = sizeof(char*); break;
- default: len = -1;
+ default: len = 0;
} // endswitch type
return len;
diff --git a/storage/connect/value.h b/storage/connect/value.h
index a0d947347c3..7eb0dec29f2 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -41,7 +41,7 @@ typedef struct _datpar *PDTP; // For DTVAL
/***********************************************************************/
// Exported functions
DllExport PCSZ GetTypeName(int);
-DllExport int GetTypeSize(int, int);
+DllExport unsigned GetTypeSize(int, unsigned);
#ifdef ODBC_SUPPORT
/* This function is exported for use in OEM table type DLLs */
DllExport int TranslateSQLType(int stp, int prec,
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index 491e987cac6..06b785b8b39 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -4463,7 +4463,7 @@ n_field_mismatch:
len -= BTR_EXTERN_FIELD_REF_SIZE;
ulint extern_len = mach_read_from_4(
data + len + BTR_EXTERN_LEN + 4);
- if (fixed_size == extern_len) {
+ if (fixed_size == extern_len + len) {
goto next_field;
}
}
diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc
index 7ecbe165a1e..f72915bce88 100644
--- a/storage/innobase/btr/btr0cur.cc
+++ b/storage/innobase/btr/btr0cur.cc
@@ -1017,7 +1017,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
if (lock_intention == BTR_INTENTION_DELETE)
{
compress_limit= BTR_CUR_PAGE_COMPRESS_LIMIT(index());
- if (buf_pool.n_pend_reads &&
+ if (os_aio_pending_reads_approx() &&
trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
{
/* Most delete-intended operations are due to the purge of history.
@@ -1723,7 +1723,7 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
{
compress_limit= BTR_CUR_PAGE_COMPRESS_LIMIT(index);
- if (buf_pool.n_pend_reads &&
+ if (os_aio_pending_reads_approx() &&
trx_sys.history_size_approx() > BTR_CUR_FINE_HISTORY_LENGTH)
{
mtr_x_lock_index(index, mtr);
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 4de8b4fd175..6a5221cb2c6 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -1311,11 +1311,11 @@ buf_tmp_buffer_t *buf_pool_t::io_buf_t::reserve()
for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
if (s->acquire())
return s;
- os_aio_wait_until_no_pending_writes();
+ os_aio_wait_until_no_pending_writes(true);
for (buf_tmp_buffer_t *s= slots, *e= slots + n_slots; s != e; s++)
if (s->acquire())
return s;
- os_aio_wait_until_no_pending_reads();
+ os_aio_wait_until_no_pending_reads(true);
}
}
@@ -3185,9 +3185,6 @@ dberr_t buf_page_t::read_complete(const fil_node_t &node)
ut_ad(zip_size() == node.space->zip_size());
ut_ad(!!zip.ssize == !!zip.data);
- ut_d(auto n=) buf_pool.n_pend_reads--;
- ut_ad(n > 0);
-
const byte *read_frame= zip.data ? zip.data : frame;
ut_ad(read_frame);
@@ -3476,9 +3473,8 @@ void buf_pool_t::print()
<< ", modified database pages="
<< UT_LIST_GET_LEN(flush_list)
<< ", n pending decompressions=" << n_pend_unzip
- << ", n pending reads=" << n_pend_reads
<< ", n pending flush LRU=" << n_flush()
- << " list=" << buf_dblwr.pending_writes()
+ << " list=" << os_aio_pending_writes()
<< ", pages made young=" << stat.n_pages_made_young
<< ", not young=" << stat.n_pages_not_made_young
<< ", pages read=" << stat.n_pages_read
@@ -3591,11 +3587,11 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info)
pool_info->n_pend_unzip = UT_LIST_GET_LEN(buf_pool.unzip_LRU);
- pool_info->n_pend_reads = buf_pool.n_pend_reads;
+ pool_info->n_pend_reads = os_aio_pending_reads_approx();
pool_info->n_pending_flush_lru = buf_pool.n_flush();
- pool_info->n_pending_flush_list = buf_dblwr.pending_writes();
+ pool_info->n_pending_flush_list = os_aio_pending_writes();
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
current_time = time(NULL);
diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc
index 8d8b92ae560..1260145ed1c 100644
--- a/storage/innobase/buf/buf0dblwr.cc
+++ b/storage/innobase/buf/buf0dblwr.cc
@@ -53,7 +53,6 @@ void buf_dblwr_t::init()
active_slot= &slots[0];
mysql_mutex_init(buf_dblwr_mutex_key, &mutex, nullptr);
pthread_cond_init(&cond, nullptr);
- pthread_cond_init(&write_cond, nullptr);
}
}
@@ -467,7 +466,6 @@ void buf_dblwr_t::close()
ut_ad(!batch_running);
pthread_cond_destroy(&cond);
- pthread_cond_destroy(&write_cond);
for (int i= 0; i < 2; i++)
{
aligned_free(slots[i].write_buf);
@@ -479,38 +477,31 @@ void buf_dblwr_t::close()
}
/** Update the doublewrite buffer on write completion. */
-void buf_dblwr_t::write_completed(bool with_doublewrite)
+void buf_dblwr_t::write_completed()
{
ut_ad(this == &buf_dblwr);
ut_ad(!srv_read_only_mode);
mysql_mutex_lock(&mutex);
- ut_ad(writes_pending);
- if (!--writes_pending)
- pthread_cond_broadcast(&write_cond);
+ ut_ad(is_created());
+ ut_ad(srv_use_doublewrite_buf);
+ ut_ad(batch_running);
+ slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
+ ut_ad(flush_slot->reserved);
+ ut_ad(flush_slot->reserved <= flush_slot->first_free);
- if (with_doublewrite)
+ if (!--flush_slot->reserved)
{
- ut_ad(is_created());
- ut_ad(srv_use_doublewrite_buf);
- ut_ad(batch_running);
- slot *flush_slot= active_slot == &slots[0] ? &slots[1] : &slots[0];
- ut_ad(flush_slot->reserved);
- ut_ad(flush_slot->reserved <= flush_slot->first_free);
-
- if (!--flush_slot->reserved)
- {
- mysql_mutex_unlock(&mutex);
- /* This will finish the batch. Sync data files to the disk. */
- fil_flush_file_spaces();
- mysql_mutex_lock(&mutex);
+ mysql_mutex_unlock(&mutex);
+ /* This will finish the batch. Sync data files to the disk. */
+ fil_flush_file_spaces();
+ mysql_mutex_lock(&mutex);
- /* We can now reuse the doublewrite memory buffer: */
- flush_slot->first_free= 0;
- batch_running= false;
- pthread_cond_broadcast(&cond);
- }
+ /* We can now reuse the doublewrite memory buffer: */
+ flush_slot->first_free= 0;
+ batch_running= false;
+ pthread_cond_broadcast(&cond);
}
mysql_mutex_unlock(&mutex);
@@ -605,7 +596,6 @@ bool buf_dblwr_t::flush_buffered_writes(const ulint size)
const bool multi_batch= block1 + static_cast<uint32_t>(size) != block2 &&
old_first_free > size;
flushing_buffered_writes= 1 + multi_batch;
- pages_submitted+= old_first_free;
/* Now safe to release the mutex. */
mysql_mutex_unlock(&mutex);
#ifdef UNIV_DEBUG
@@ -754,7 +744,6 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size)
const ulint buf_size= 2 * block_size();
mysql_mutex_lock(&mutex);
- writes_pending++;
for (;;)
{
diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc
index 63a28aa1a37..bb705ec5651 100644
--- a/storage/innobase/buf/buf0dump.cc
+++ b/storage/innobase/buf/buf0dump.cc
@@ -651,7 +651,7 @@ buf_load()
ut_free(dump);
if (i == dump_n) {
- os_aio_wait_until_no_pending_reads();
+ os_aio_wait_until_no_pending_reads(true);
}
ut_sprintf_timestamp(now);
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 0072d0c22b8..57245cbb95e 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -113,7 +113,12 @@ void buf_pool_t::page_cleaner_wakeup(bool for_LRU)
{
ut_d(buf_flush_validate_skip());
if (!page_cleaner_idle())
+ {
+ if (for_LRU)
+ /* Ensure that the page cleaner is not in a timed wait. */
+ pthread_cond_signal(&do_flush_list);
return;
+ }
double dirty_pct= double(UT_LIST_GET_LEN(buf_pool.flush_list)) * 100.0 /
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
double pct_lwm= srv_max_dirty_pages_pct_lwm;
@@ -209,7 +214,7 @@ void buf_flush_remove_pages(uint32_t id)
if (!deferred)
break;
- buf_dblwr.wait_for_page_writes();
+ os_aio_wait_until_no_pending_writes(true);
}
}
@@ -339,9 +344,9 @@ void buf_page_write_complete(const IORequest &request)
if (request.is_LRU())
{
const bool temp= bpage->oldest_modification() == 2;
- if (!temp)
- buf_dblwr.write_completed(state < buf_page_t::WRITE_FIX_REINIT &&
- request.node->space->use_doublewrite());
+ if (!temp && state < buf_page_t::WRITE_FIX_REINIT &&
+ request.node->space->use_doublewrite())
+ buf_dblwr.write_completed();
/* We must hold buf_pool.mutex while releasing the block, so that
no other thread can access it before we have freed it. */
mysql_mutex_lock(&buf_pool.mutex);
@@ -353,8 +358,9 @@ void buf_page_write_complete(const IORequest &request)
}
else
{
- buf_dblwr.write_completed(state < buf_page_t::WRITE_FIX_REINIT &&
- request.node->space->use_doublewrite());
+ if (state < buf_page_t::WRITE_FIX_REINIT &&
+ request.node->space->use_doublewrite())
+ buf_dblwr.write_completed();
bpage->write_complete(false);
}
}
@@ -847,8 +853,6 @@ bool buf_page_t::flush(bool evict, fil_space_t *space)
ut_ad(lsn >= oldest_modification());
log_write_up_to(lsn, true);
}
- if (UNIV_LIKELY(space->purpose != FIL_TYPE_TEMPORARY))
- buf_dblwr.add_unbuffered();
space->io(IORequest{type, this, slot}, physical_offset(), size,
write_frame, this);
}
@@ -1082,13 +1086,11 @@ static ulint buf_flush_try_neighbors(fil_space_t *space,
mysql_mutex_unlock(&buf_pool.mutex);
}
- ut_ad(!bpage);
-
- if (auto n= count - 1)
+ if (count > 1)
{
MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE,
MONITOR_FLUSH_NEIGHBOR_COUNT,
- MONITOR_FLUSH_NEIGHBOR_PAGES, n);
+ MONITOR_FLUSH_NEIGHBOR_PAGES, count - 1);
}
return count;
@@ -1218,6 +1220,11 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict,
++n->evicted;
/* fall through */
case 1:
+ if (UNIV_LIKELY(scanned & 31))
+ continue;
+ mysql_mutex_unlock(&buf_pool.mutex);
+ reacquire_mutex:
+ mysql_mutex_lock(&buf_pool.mutex);
continue;
}
@@ -1253,32 +1260,37 @@ static void buf_flush_LRU_list_batch(ulint max, bool evict,
auto p= buf_flush_space(space_id);
space= p.first;
last_space_id= space_id;
+ if (!space)
+ {
+ mysql_mutex_lock(&buf_pool.mutex);
+ goto no_space;
+ }
mysql_mutex_lock(&buf_pool.mutex);
- if (p.second)
- buf_pool.stat.n_pages_written+= p.second;
+ buf_pool.stat.n_pages_written+= p.second;
}
else
+ {
ut_ad(!space);
+ goto no_space;
+ }
}
else if (space->is_stopping())
{
space->release();
space= nullptr;
- }
-
- if (!space)
- {
+ no_space:
mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_discard_page(bpage);
+ continue;
}
- else if (neighbors && space->is_rotational())
+
+ if (neighbors && space->is_rotational())
{
mysql_mutex_unlock(&buf_pool.mutex);
n->flushed+= buf_flush_try_neighbors(space, page_id, bpage,
neighbors == 1,
do_evict, n->flushed, max);
-reacquire_mutex:
- mysql_mutex_lock(&buf_pool.mutex);
+ goto reacquire_mutex;
}
else if (n->flushed >= max && !recv_recovery_is_on())
{
@@ -1645,7 +1657,7 @@ done:
space->release();
if (space->purpose == FIL_TYPE_IMPORT)
- os_aio_wait_until_no_pending_writes();
+ os_aio_wait_until_no_pending_writes(true);
else
buf_dblwr.flush_buffered_writes();
@@ -1957,7 +1969,7 @@ static void buf_flush_wait(lsn_t lsn)
break;
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- buf_dblwr.wait_for_page_writes();
+ os_aio_wait_until_no_pending_writes(false);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
}
}
@@ -1978,8 +1990,6 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
if (buf_pool.get_oldest_modification(sync_lsn) < sync_lsn)
{
MONITOR_INC(MONITOR_FLUSH_SYNC_WAITS);
- thd_wait_begin(nullptr, THD_WAIT_DISKIO);
- tpool::tpool_wait_begin();
#if 1 /* FIXME: remove this, and guarantee that the page cleaner serves us */
if (UNIV_UNLIKELY(!buf_page_cleaner_is_active))
@@ -1994,17 +2004,20 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn)
MONITOR_FLUSH_SYNC_COUNT,
MONITOR_FLUSH_SYNC_PAGES, n_pages);
}
- buf_dblwr.wait_for_page_writes();
+ os_aio_wait_until_no_pending_writes(false);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
}
while (buf_pool.get_oldest_modification(sync_lsn) < sync_lsn);
}
else
#endif
+ {
+ thd_wait_begin(nullptr, THD_WAIT_DISKIO);
+ tpool::tpool_wait_begin();
buf_flush_wait(sync_lsn);
-
- tpool::tpool_wait_end();
- thd_wait_end(nullptr);
+ tpool::tpool_wait_end();
+ thd_wait_end(nullptr);
+ }
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
@@ -2157,10 +2170,12 @@ Based on various factors it decides if there is a need to do flushing.
@return number of pages recommended to be flushed
@param last_pages_in number of pages flushed in previous batch
@param oldest_lsn buf_pool.get_oldest_modification(0)
+@param pct_lwm innodb_max_dirty_pages_pct_lwm, or 0 to ignore it
@param dirty_blocks UT_LIST_GET_LEN(buf_pool.flush_list)
@param dirty_pct 100*flush_list.count / (LRU.count + free.count) */
static ulint page_cleaner_flush_pages_recommendation(ulint last_pages_in,
lsn_t oldest_lsn,
+ double pct_lwm,
ulint dirty_blocks,
double dirty_pct)
{
@@ -2230,11 +2245,17 @@ func_exit:
sum_pages = 0;
}
- const ulint pct_for_dirty = srv_max_dirty_pages_pct_lwm == 0
- ? (dirty_pct >= max_pct ? 100 : 0)
- : static_cast<ulint>
- (max_pct > 0.0 ? dirty_pct / max_pct : dirty_pct);
- ulint pct_total = std::max(pct_for_dirty, pct_for_lsn);
+ MONITOR_SET(MONITOR_FLUSH_PCT_FOR_LSN, pct_for_lsn);
+
+ double total_ratio;
+ if (pct_lwm == 0.0 || max_pct == 0.0) {
+ total_ratio = 1;
+ } else {
+ total_ratio = std::max(double(pct_for_lsn) / 100,
+ (dirty_pct / max_pct));
+ }
+
+ MONITOR_SET(MONITOR_FLUSH_PCT_FOR_DIRTY, ulint(total_ratio * 100));
/* Estimate pages to be flushed for the lsn progress */
lsn_t target_lsn = oldest_lsn
@@ -2260,7 +2281,7 @@ func_exit:
pages_for_lsn = 1;
}
- n_pages = (ulint(double(srv_io_capacity) * double(pct_total) / 100.0)
+ n_pages = (ulint(double(srv_io_capacity) * total_ratio)
+ avg_page_rate + pages_for_lsn) / 3;
if (n_pages > srv_max_io_capacity) {
@@ -2273,8 +2294,6 @@ func_exit:
MONITOR_SET(MONITOR_FLUSH_AVG_PAGE_RATE, avg_page_rate);
MONITOR_SET(MONITOR_FLUSH_LSN_AVG_RATE, lsn_avg_rate);
- MONITOR_SET(MONITOR_FLUSH_PCT_FOR_DIRTY, pct_for_dirty);
- MONITOR_SET(MONITOR_FLUSH_PCT_FOR_LSN, pct_for_lsn);
goto func_exit;
}
@@ -2362,7 +2381,7 @@ static void buf_flush_page_cleaner()
if (!recv_recovery_is_on() &&
!srv_startup_is_before_trx_rollback_phase &&
- srv_operation == SRV_OPERATION_NORMAL)
+ srv_operation <= SRV_OPERATION_EXPORT_RESTORED)
log_checkpoint();
}
while (false);
@@ -2387,7 +2406,7 @@ static void buf_flush_page_cleaner()
soft_lsn_limit= lsn_limit;
}
- bool idle_flush= false;
+ double pct_lwm= 0.0;
ulint n_flushed= 0, n;
if (UNIV_UNLIKELY(soft_lsn_limit != 0))
@@ -2406,7 +2425,7 @@ static void buf_flush_page_cleaner()
mysql_mutex_unlock(&buf_pool.mutex);
last_pages+= n;
- if (!idle_flush)
+ if (pct_lwm == 0.0)
goto end_of_batch;
/* when idle flushing kicks in page_cleaner is marked active.
@@ -2424,7 +2443,8 @@ static void buf_flush_page_cleaner()
guaranteed to be nonempty, and it is a subset of buf_pool.LRU. */
const double dirty_pct= double(dirty_blocks) * 100.0 /
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
- if (srv_max_dirty_pages_pct_lwm != 0.0)
+ pct_lwm= srv_max_dirty_pages_pct_lwm;
+ if (pct_lwm != 0.0)
{
const ulint activity_count= srv_get_activity_count();
if (activity_count != last_activity_count)
@@ -2432,7 +2452,7 @@ static void buf_flush_page_cleaner()
last_activity_count= activity_count;
goto maybe_unemployed;
}
- else if (buf_pool.page_cleaner_idle() && buf_pool.n_pend_reads == 0)
+ else if (buf_pool.page_cleaner_idle() && !os_aio_pending_reads())
{
/* reaching here means 3 things:
- last_activity_count == activity_count: suggesting server is idle
@@ -2441,13 +2461,16 @@ static void buf_flush_page_cleaner()
- there are no pending reads but there are dirty pages to flush */
buf_pool.update_last_activity_count(activity_count);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- idle_flush= true;
goto idle_flush;
}
else
+ {
maybe_unemployed:
- if (dirty_pct < srv_max_dirty_pages_pct_lwm)
+ const bool below{dirty_pct < pct_lwm};
+ pct_lwm= 0.0;
+ if (below)
goto possibly_unemployed;
+ }
}
else if (dirty_pct < srv_max_buf_pool_modified_pct)
possibly_unemployed:
@@ -2478,6 +2501,7 @@ static void buf_flush_page_cleaner()
}
else if ((n= page_cleaner_flush_pages_recommendation(last_pages,
oldest_lsn,
+ pct_lwm,
dirty_blocks,
dirty_pct)) != 0)
{
@@ -2508,7 +2532,7 @@ static void buf_flush_page_cleaner()
mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_wait_LRU_batch_end();
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- buf_dblwr.wait_for_page_writes();
+ os_aio_wait_until_no_pending_writes(false);
}
mysql_mutex_lock(&buf_pool.flush_list_mutex);
@@ -2534,7 +2558,7 @@ static void buf_flush_page_cleaner()
ATTRIBUTE_COLD void buf_flush_page_cleaner_init()
{
ut_ad(!buf_page_cleaner_is_active);
- ut_ad(srv_operation == SRV_OPERATION_NORMAL ||
+ ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED ||
srv_operation == SRV_OPERATION_RESTORE ||
srv_operation == SRV_OPERATION_RESTORE_EXPORT);
buf_flush_async_lsn= 0;
@@ -2558,15 +2582,7 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool()
{
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
buf_flush_list(srv_max_io_capacity);
- if (const size_t pending= buf_dblwr.pending_writes())
- {
- timespec abstime;
- service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
- "Waiting to write %zu pages", pending);
- set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2);
- buf_dblwr.wait_for_page_writes(abstime);
- }
-
+ os_aio_wait_until_no_pending_writes(false);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
"Waiting to flush " ULINTPF " pages",
@@ -2574,20 +2590,17 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool()
}
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- ut_ad(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
}
/** Synchronously flush dirty blocks during recv_sys_t::apply().
NOTE: The calling thread is not allowed to hold any buffer page latches! */
void buf_flush_sync_batch(lsn_t lsn)
{
- thd_wait_begin(nullptr, THD_WAIT_DISKIO);
- tpool::tpool_wait_begin();
+ lsn= std::max(lsn, log_sys.get_lsn());
mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_wait(lsn);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- tpool::tpool_wait_end();
- thd_wait_end(nullptr);
}
/** Synchronously flush dirty blocks.
diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc
index e4e20e8335f..4c42d3eab54 100644
--- a/storage/innobase/buf/buf0lru.cc
+++ b/storage/innobase/buf/buf0lru.cc
@@ -455,15 +455,15 @@ got_block:
mysql_mutex_unlock(&buf_pool.mutex);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
const auto n_flush = buf_pool.n_flush();
+ if (!buf_pool.try_LRU_scan) {
+ buf_pool.page_cleaner_wakeup(true);
+ }
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
mysql_mutex_lock(&buf_pool.mutex);
if (!n_flush) {
goto not_found;
}
if (!buf_pool.try_LRU_scan) {
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- buf_pool.page_cleaner_wakeup(true);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
my_cond_wait(&buf_pool.done_free,
&buf_pool.mutex.m_mutex);
}
@@ -1112,17 +1112,8 @@ static bool buf_LRU_block_remove_hashed(buf_page_t *bpage, const page_id_t id,
break;
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_TYPE_ZBLOB2:
- break;
case FIL_PAGE_INDEX:
case FIL_PAGE_RTREE:
-#if defined UNIV_ZIP_DEBUG && defined BTR_CUR_HASH_ADAPT
- /* During recovery, we only update the
- compressed page, not the uncompressed one. */
- ut_a(recv_recovery_is_on()
- || page_zip_validate(
- &bpage->zip, page,
- ((buf_block_t*) bpage)->index));
-#endif /* UNIV_ZIP_DEBUG && BTR_CUR_HASH_ADAPT */
break;
default:
ib::error() << "The compressed page to be"
diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc
index 7dab411dabb..1f7f9bfba0a 100644
--- a/storage/innobase/buf/buf0rea.cc
+++ b/storage/innobase/buf/buf0rea.cc
@@ -187,9 +187,6 @@ page_exists:
}
buf_pool.stat.n_pages_read++;
- mysql_mutex_unlock(&buf_pool.mutex);
- buf_pool.n_pend_reads++;
- return bpage;
func_exit:
mysql_mutex_unlock(&buf_pool.mutex);
ut_ad(!bpage || bpage->in_file());
@@ -252,8 +249,6 @@ buf_read_page_low(
page_id.page_no() * len, len, dst, bpage);
if (UNIV_UNLIKELY(fio.err != DB_SUCCESS)) {
- ut_d(auto n=) buf_pool.n_pend_reads--;
- ut_ad(n > 0);
buf_pool.corrupted_evict(bpage, buf_page_t::READ_FIX);
} else if (sync) {
thd_wait_end(NULL);
@@ -305,7 +300,8 @@ ulint buf_read_ahead_random(const page_id_t page_id, ulint zip_size)
/* No read-ahead to avoid thread deadlocks */
return 0;
- if (buf_pool.n_pend_reads > buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT)
+ if (os_aio_pending_reads_approx() >
+ buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT)
return 0;
fil_space_t* space= fil_space_t::get(page_id.space());
@@ -511,7 +507,8 @@ ulint buf_read_ahead_linear(const page_id_t page_id, ulint zip_size)
/* No read-ahead to avoid thread deadlocks */
return 0;
- if (buf_pool.n_pend_reads > buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT)
+ if (os_aio_pending_reads_approx() >
+ buf_pool.curr_size / BUF_READ_AHEAD_PEND_LIMIT)
return 0;
const uint32_t buf_read_ahead_area= buf_pool.read_ahead_area;
@@ -693,18 +690,8 @@ void buf_read_recv_pages(uint32_t space_id, st_::span<uint32_t> page_nos)
limit += buf_pool.chunks[j].size / 2;
}
- for (ulint count = 0; buf_pool.n_pend_reads >= limit; ) {
- std::this_thread::sleep_for(
- std::chrono::milliseconds(10));
-
- if (!(++count % 1000)) {
-
- ib::error()
- << "Waited for " << count / 100
- << " seconds for "
- << buf_pool.n_pend_reads
- << " pending reads";
- }
+ if (os_aio_pending_reads() >= limit) {
+ os_aio_wait_until_no_pending_reads(false);
}
buf_pool_t::hash_chain& chain =
diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc
index 4ea4f98640a..d92c2e12409 100644
--- a/storage/innobase/dict/drop.cc
+++ b/storage/innobase/dict/drop.cc
@@ -66,6 +66,7 @@ before transaction commit and must be rolled back explicitly are as follows:
#include "dict0stats.h"
#include "dict0stats_bg.h"
+#include "ibuf0ibuf.h"
#include "lock0lock.h"
#include "que0que.h"
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index c1fd916be55..53ea91529ec 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -96,7 +96,13 @@ bool fil_space_t::try_to_close(bool print_info)
if (!node->is_open())
continue;
- if (const auto n= space.set_closing())
+ /* Other thread is trying to do fil_delete_tablespace()
+ concurrently for the same tablespace. So ignore this
+ tablespace and try to close the other one */
+ const auto n= space.set_closing();
+ if (n & STOPPING)
+ continue;
+ if (n & (PENDING | NEEDS_FSYNC))
{
if (!print_info)
continue;
@@ -288,6 +294,8 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
uint32_t size, bool is_raw, bool atomic_write,
uint32_t max_pages)
{
+ mysql_mutex_assert_owner(&fil_system.mutex);
+
fil_node_t* node;
ut_ad(name != NULL);
@@ -312,7 +320,6 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
node->atomic_write = atomic_write;
- mysql_mutex_lock(&fil_system.mutex);
this->size += size;
UT_LIST_ADD_LAST(chain, node);
if (node->is_open()) {
@@ -323,7 +330,6 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle,
release();
}
}
- mysql_mutex_unlock(&fil_system.mutex);
return node;
}
@@ -799,8 +805,17 @@ pfs_os_file_t fil_system_t::detach(fil_space_t *space, bool detach_handle)
space_list_t::iterator s= space_list_t::iterator(space);
if (space_list_last_opened == space)
{
- space_list_t::iterator prev= s;
- space_list_last_opened= &*--prev;
+ if (s == space_list.begin())
+ {
+ ut_ad(srv_operation > SRV_OPERATION_EXPORT_RESTORED ||
+ srv_shutdown_state > SRV_SHUTDOWN_NONE);
+ space_list_last_opened= nullptr;
+ }
+ else
+ {
+ space_list_t::iterator prev= s;
+ space_list_last_opened= &*--prev;
+ }
}
space_list.erase(s);
}
@@ -934,6 +949,7 @@ fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
{
fil_space_t* space;
+ mysql_mutex_assert_owner(&fil_system.mutex);
ut_ad(fil_system.is_initialised());
ut_ad(fil_space_t::is_valid_flags(flags & ~FSP_FLAGS_MEM_MASK, id));
ut_ad(srv_page_size == UNIV_PAGE_SIZE_ORIG || flags != 0);
@@ -966,8 +982,6 @@ fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
space->latch.SRW_LOCK_INIT(fil_space_latch_key);
- mysql_mutex_lock(&fil_system.mutex);
-
if (const fil_space_t *old_space = fil_space_get_by_id(id)) {
ib::error() << "Trying to add tablespace with id " << id
<< " to the cache, but tablespace '"
@@ -975,7 +989,6 @@ fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
? old_space->chain.start->name
: "")
<< "' already exists in the cache!";
- mysql_mutex_unlock(&fil_system.mutex);
space->~fil_space_t();
ut_free(space);
return(NULL);
@@ -1022,12 +1035,12 @@ fil_space_t *fil_space_t::create(uint32_t id, uint32_t flags,
if (rotate) {
fil_system.default_encrypt_tables.push_back(*space);
space->is_in_default_encrypt = true;
- }
-
- mysql_mutex_unlock(&fil_system.mutex);
- if (rotate && srv_n_fil_crypt_threads_started) {
- fil_crypt_threads_signal();
+ if (srv_n_fil_crypt_threads_started) {
+ mysql_mutex_unlock(&fil_system.mutex);
+ fil_crypt_threads_signal();
+ mysql_mutex_lock(&fil_system.mutex);
+ }
}
return(space);
@@ -1310,9 +1323,9 @@ void fil_system_t::close()
void fil_system_t::add_opened_last_to_space_list(fil_space_t *space)
{
if (UNIV_LIKELY(space_list_last_opened != nullptr))
- space_list.insert(space_list_t::iterator(space_list_last_opened), *space);
+ space_list.insert(++space_list_t::iterator(space_list_last_opened), *space);
else
- space_list.push_back(*space);
+ space_list.push_front(*space);
space_list_last_opened= space;
}
@@ -1482,7 +1495,10 @@ void fil_space_t::close_all()
for (ulint count= 10000; count--;)
{
- if (!space.set_closing())
+ const auto n= space.set_closing();
+ if (n & STOPPING)
+ goto next;
+ if (!(n & (PENDING | NEEDS_FSYNC)))
{
node->close();
goto next;
@@ -1732,9 +1748,7 @@ pfs_os_file_t fil_delete_tablespace(uint32_t id)
mtr_t mtr;
mtr.start();
mtr.log_file_op(FILE_DELETE, id, space->chain.start->name);
- handle= space->chain.start->handle;
- mtr.commit_file(*space, nullptr);
-
+ mtr.commit_file(*space, nullptr, &handle);
fil_space_free_low(space);
}
@@ -2047,16 +2061,20 @@ err_exit:
DBUG_EXECUTE_IF("checkpoint_after_file_create",
log_make_checkpoint(););
+ mysql_mutex_lock(&fil_system.mutex);
if (fil_space_t* space = fil_space_t::create(space_id, flags,
FIL_TYPE_TABLESPACE,
crypt_data, mode, true)) {
fil_node_t* node = space->add(path, file, size, false, true);
+ mysql_mutex_unlock(&fil_system.mutex);
IF_WIN(node->find_metadata(), node->find_metadata(file, true));
mtr.start();
mtr.set_named_space(space);
ut_a(fsp_header_init(space, size, &mtr) == DB_SUCCESS);
mtr.commit();
return space;
+ } else {
+ mysql_mutex_unlock(&fil_system.mutex);
}
if (space_name.data()) {
@@ -2171,6 +2189,10 @@ func_exit:
must_validate = true;
}
+ const bool operation_not_for_export =
+ srv_operation != SRV_OPERATION_RESTORE_EXPORT
+ && srv_operation != SRV_OPERATION_EXPORT_RESTORED;
+
/* Always look for a file at the default location. But don't log
an error if the tablespace is already open in remote or dict. */
ut_a(df_default.filepath());
@@ -2181,6 +2203,7 @@ func_exit:
drop_garbage_tables_after_restore() a little later. */
const bool strict = validate && !tablespaces_found
+ && operation_not_for_export
&& !(srv_operation == SRV_OPERATION_NORMAL
&& srv_start_after_restore
&& srv_force_recovery < SRV_FORCE_NO_BACKGROUND
@@ -2229,7 +2252,11 @@ func_exit:
goto corrupted;
}
- os_file_get_last_error(true);
+ os_file_get_last_error(operation_not_for_export,
+ !operation_not_for_export);
+ if (!operation_not_for_export) {
+ goto corrupted;
+ }
sql_print_error("InnoDB: Could not find a valid tablespace"
" file for %.*s. %s",
static_cast<int>(name.size()), name.data(),
@@ -2307,8 +2334,10 @@ skip_validate:
first_page)
: NULL;
+ mysql_mutex_lock(&fil_system.mutex);
space = fil_space_t::create(id, flags, purpose, crypt_data);
if (!space) {
+ mysql_mutex_unlock(&fil_system.mutex);
goto error;
}
@@ -2318,6 +2347,7 @@ skip_validate:
space->add(
df_remote.is_open() ? df_remote.filepath() :
df_default.filepath(), OS_FILE_CLOSED, 0, false, true);
+ mysql_mutex_unlock(&fil_system.mutex);
if (must_validate && !srv_read_only_mode) {
df_remote.close();
@@ -2396,6 +2426,7 @@ fil_ibd_discover(
case SRV_OPERATION_RESTORE:
break;
case SRV_OPERATION_NORMAL:
+ case SRV_OPERATION_EXPORT_RESTORED:
size_t len= strlen(db);
if (len <= 4 || strcmp(db + len - 4, dot_ext[IBD])) {
break;
@@ -2602,10 +2633,13 @@ tablespace_check:
return FIL_LOAD_INVALID;
}
+ mysql_mutex_lock(&fil_system.mutex);
+
space = fil_space_t::create(
space_id, flags, FIL_TYPE_TABLESPACE, crypt_data);
if (space == NULL) {
+ mysql_mutex_unlock(&fil_system.mutex);
return(FIL_LOAD_INVALID);
}
@@ -2617,6 +2651,7 @@ tablespace_check:
let fil_node_open() do that task. */
space->add(file.filepath(), OS_FILE_CLOSED, 0, false, false);
+ mysql_mutex_unlock(&fil_system.mutex);
return(FIL_LOAD_OK);
}
diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc
index 0a4119587f8..e93ca4bc177 100644
--- a/storage/innobase/fsp/fsp0file.cc
+++ b/storage/innobase/fsp/fsp0file.cc
@@ -756,7 +756,7 @@ the double write buffer.
bool
Datafile::restore_from_doublewrite()
{
- if (srv_operation != SRV_OPERATION_NORMAL) {
+ if (srv_operation > SRV_OPERATION_EXPORT_RESTORED) {
return true;
}
diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc
index 6bdf9fcc4d8..c2152b08590 100644
--- a/storage/innobase/fsp/fsp0space.cc
+++ b/storage/innobase/fsp/fsp0space.cc
@@ -88,25 +88,25 @@ Tablespace::open_or_create(bool is_temp)
ut_ad(!m_files.empty());
for (iterator it = begin(); it != end(); ++it) {
-
if (it->m_exists) {
err = it->open_or_create(
m_ignore_read_only
? false : srv_read_only_mode);
+ if (err != DB_SUCCESS) {
+ return err;
+ }
} else {
err = it->open_or_create(
m_ignore_read_only
? false : srv_read_only_mode);
- /* Set the correct open flags now that we have
- successfully created the file. */
- if (err == DB_SUCCESS) {
- file_found(*it);
+ if (err != DB_SUCCESS) {
+ return err;
}
- }
- if (err != DB_SUCCESS) {
- break;
+ /* Set the correct open flags now that we have
+ successfully created the file. */
+ file_found(*it);
}
/* We can close the handle now and open the tablespace
@@ -130,20 +130,22 @@ Tablespace::open_or_create(bool is_temp)
fsp_flags = FSP_FLAGS_PAGE_SSIZE();
}
+ mysql_mutex_lock(&fil_system.mutex);
space = fil_space_t::create(
m_space_id, fsp_flags,
is_temp
? FIL_TYPE_TEMPORARY : FIL_TYPE_TABLESPACE,
NULL);
if (!space) {
+ mysql_mutex_unlock(&fil_system.mutex);
return DB_ERROR;
}
+ } else {
+ mysql_mutex_lock(&fil_system.mutex);
}
-
- ut_a(fil_validate());
-
space->add(it->m_filepath, OS_FILE_CLOSED, it->m_size,
false, true);
+ mysql_mutex_unlock(&fil_system.mutex);
}
return(err);
diff --git a/storage/innobase/fsp/fsp0sysspace.cc b/storage/innobase/fsp/fsp0sysspace.cc
index ef650436907..9aef6f389ef 100644
--- a/storage/innobase/fsp/fsp0sysspace.cc
+++ b/storage/innobase/fsp/fsp0sysspace.cc
@@ -576,7 +576,7 @@ inline dberr_t SysTablespace::read_lsn_and_check_flags()
ut_a(it->order() == 0);
- if (srv_operation == SRV_OPERATION_NORMAL) {
+ if (srv_operation <= SRV_OPERATION_EXPORT_RESTORED) {
buf_dblwr.init_or_load_pages(it->handle(), it->filepath());
}
@@ -920,6 +920,7 @@ SysTablespace::open_or_create(
/* Close the curent handles, add space and file info to the
fil_system cache and the Data Dictionary, and re-open them
in file_system cache so that they stay open until shutdown. */
+ mysql_mutex_lock(&fil_system.mutex);
ulint node_counter = 0;
for (files_t::iterator it = begin; it != end; ++it) {
it->close();
@@ -933,7 +934,8 @@ SysTablespace::open_or_create(
FIL_TYPE_TEMPORARY, NULL);
ut_ad(space == fil_system.temp_space);
if (!space) {
- return DB_ERROR;
+ err = DB_ERROR;
+ break;
}
ut_ad(!space->is_compressed());
ut_ad(space->full_crc32());
@@ -944,12 +946,11 @@ SysTablespace::open_or_create(
FIL_TYPE_TABLESPACE, NULL);
ut_ad(space == fil_system.sys_space);
if (!space) {
- return DB_ERROR;
+ err = DB_ERROR;
+ break;
}
}
- ut_a(fil_validate());
-
uint32_t max_size = (++node_counter == m_files.size()
? (m_last_file_size_max == 0
? UINT32_MAX
@@ -960,6 +961,7 @@ SysTablespace::open_or_create(
it->m_type != SRV_NOT_RAW, true, max_size);
}
+ mysql_mutex_unlock(&fil_system.mutex);
return(err);
}
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 8623e653991..d2b90542ec6 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -38,22 +38,6 @@ Full Text Search interface
#include "dict0stats.h"
#include "btr0pcur.h"
-/** The SYNC state of the cache. There is one instance of this struct
-associated with each ADD thread. */
-struct fts_sync_t {
- /** Transaction used for SYNCing the cache to disk */
- trx_t *trx;
- /** Table with FTS index(es) */
- dict_table_t *table;
- /** Max size in bytes of the cache */
- ulint max_cache_size;
- /** The doc id at which the cache was noted as being
- full, we use this to set the upper_limit field */
- doc_id_t max_doc_id;
- /** SYNC start time; only used if fts_enable_diag_print */
- time_t start_time;
-};
-
static const ulint FTS_MAX_ID_LEN = 32;
/** Column name from the FTS config table */
@@ -201,8 +185,15 @@ struct fts_tokenize_param_t {
/** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state
+@param[in] unlock_cache whether unlock cache lock when write node
+@param[in] wait whether wait when a sync is in progress
@return DB_SUCCESS if all OK */
-static dberr_t fts_sync(fts_sync_t *sync);
+static
+dberr_t
+fts_sync(
+ fts_sync_t* sync,
+ bool unlock_cache,
+ bool wait);
/****************************************************************//**
Release all resources help by the words rb tree e.g., the node ilist. */
@@ -275,6 +266,7 @@ fts_cache_destroy(fts_cache_t* cache)
mysql_mutex_destroy(&cache->init_lock);
mysql_mutex_destroy(&cache->deleted_lock);
mysql_mutex_destroy(&cache->doc_id_lock);
+ pthread_cond_destroy(&cache->sync->cond);
if (cache->stopword_info.cached_stopword) {
rbt_free(cache->stopword_info.cached_stopword);
@@ -574,6 +566,7 @@ fts_index_cache_init(
for (i = 0; i < FTS_NUM_AUX_INDEX; ++i) {
ut_a(index_cache->ins_graph[i] == NULL);
+ ut_a(index_cache->sel_graph[i] == NULL);
}
}
@@ -643,6 +636,7 @@ fts_cache_create(
mem_heap_zalloc(heap, sizeof(fts_sync_t)));
cache->sync->table = table;
+ pthread_cond_init(&cache->sync->cond, nullptr);
/* Create the index cache vector that will hold the inverted indexes. */
cache->indexes = ib_vector_create(
@@ -968,6 +962,10 @@ fts_cache_index_cache_create(
mem_heap_zalloc(static_cast<mem_heap_t*>(
cache->self_heap->arg), n_bytes));
+ index_cache->sel_graph = static_cast<que_t**>(
+ mem_heap_zalloc(static_cast<mem_heap_t*>(
+ cache->self_heap->arg), n_bytes));
+
fts_index_cache_init(cache->sync_heap, index_cache);
if (cache->get_docs) {
@@ -1041,6 +1039,13 @@ fts_cache_clear(
index_cache->ins_graph[j] = NULL;
}
+
+ if (index_cache->sel_graph[j] != NULL) {
+
+ que_graph_free(index_cache->sel_graph[j]);
+
+ index_cache->sel_graph[j] = NULL;
+ }
}
index_cache->doc_stats = NULL;
@@ -1333,7 +1338,8 @@ fts_cache_add_doc(
ib_vector_last(word->nodes));
}
- if (!fts_node || fts_node->ilist_size > FTS_ILIST_MAX_SIZE
+ if (fts_node == NULL || fts_node->synced
+ || fts_node->ilist_size > FTS_ILIST_MAX_SIZE
|| doc_id < fts_node->last_doc_id) {
fts_node = static_cast<fts_node_t*>(
@@ -3320,7 +3326,7 @@ fts_add_doc_from_tuple(
if (cache->total_size > fts_max_cache_size / 5
|| fts_need_sync) {
- fts_sync(cache->sync);
+ fts_sync(cache->sync, true, false);
}
mtr_start(&mtr);
@@ -3356,7 +3362,7 @@ fts_add_doc_by_id(
dict_index_t* fts_id_index;
ibool is_id_cluster;
fts_cache_t* cache = ftt->table->fts->cache;
- bool need_sync= false;
+
ut_ad(cache->get_docs);
/* If Doc ID has been supplied by the user, then the table
@@ -3496,32 +3502,44 @@ fts_add_doc_by_id(
get_doc->index_cache,
doc_id, doc.tokens);
- /** FTS cache sync should happen
- frequently. Because user thread
- shouldn't hold the cache lock for
- longer time. So cache should sync
- whenever cache size exceeds 512 KB */
- need_sync =
- cache->total_size > 512*1024;
+ bool need_sync = !cache->sync->in_progress
+ && (fts_need_sync
+ || (cache->total_size
+ - cache->total_size_at_sync)
+ > fts_max_cache_size / 10);
+ if (need_sync) {
+ cache->total_size_at_sync =
+ cache->total_size;
+ }
mysql_mutex_unlock(&table->fts->cache->lock);
DBUG_EXECUTE_IF(
"fts_instrument_sync",
- fts_sync_table(table);
+ fts_optimize_request_sync_table(table);
+ mysql_mutex_lock(&cache->lock);
+ if (cache->sync->in_progress)
+ my_cond_wait(
+ &cache->sync->cond,
+ &cache->lock.m_mutex);
+ mysql_mutex_unlock(&cache->lock);
);
DBUG_EXECUTE_IF(
"fts_instrument_sync_debug",
- fts_sync(cache->sync);
+ fts_sync(cache->sync, true, true);
);
DEBUG_SYNC_C("fts_instrument_sync_request");
DBUG_EXECUTE_IF(
"fts_instrument_sync_request",
- need_sync= true;
+ fts_optimize_request_sync_table(table);
);
+ if (need_sync) {
+ fts_optimize_request_sync_table(table);
+ }
+
mtr_start(&mtr);
if (i < num_idx - 1) {
@@ -3547,10 +3565,6 @@ func_exit:
ut_free(pcur.old_rec_buf);
mem_heap_free(heap);
-
- if (need_sync) {
- fts_sync_table(table);
- }
}
@@ -3910,13 +3924,15 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result))
dberr_t
fts_sync_write_words(
trx_t* trx,
- fts_index_cache_t* index_cache)
+ fts_index_cache_t* index_cache,
+ bool unlock_cache)
{
fts_table_t fts_table;
ulint n_nodes = 0;
ulint n_words = 0;
const ib_rbt_node_t* rbt_node;
dberr_t error = DB_SUCCESS;
+ ibool print_error = FALSE;
dict_table_t* table = index_cache->index->table;
FTS_INIT_INDEX_TABLE(
@@ -3947,36 +3963,53 @@ fts_sync_write_words(
fts_table.suffix = fts_get_suffix(selected);
+ /* We iterate over all the nodes even if there was an error */
for (i = 0; i < ib_vector_size(word->nodes); ++i) {
fts_node_t* fts_node = static_cast<fts_node_t*>(
ib_vector_get(word->nodes, i));
- error = fts_write_node(
- trx, &index_cache->ins_graph[selected],
- &fts_table, &word->text, fts_node);
+ if (fts_node->synced) {
+ continue;
+ } else {
+ fts_node->synced = true;
+ }
+
+ /*FIXME: we need to handle the error properly. */
+ if (error == DB_SUCCESS) {
+ if (unlock_cache) {
+ mysql_mutex_unlock(
+ &table->fts->cache->lock);
+ }
+
+ error = fts_write_node(
+ trx,
+ &index_cache->ins_graph[selected],
+ &fts_table, &word->text, fts_node);
- DEBUG_SYNC_C("fts_write_node");
- DBUG_EXECUTE_IF("fts_write_node_crash",
+ DEBUG_SYNC_C("fts_write_node");
+ DBUG_EXECUTE_IF("fts_write_node_crash",
DBUG_SUICIDE(););
- DBUG_EXECUTE_IF("fts_instrument_sync_sleep",
+ DBUG_EXECUTE_IF(
+ "fts_instrument_sync_sleep",
std::this_thread::sleep_for(
std::chrono::seconds(1)););
- if (error != DB_SUCCESS) {
- goto err_exit;
+ if (unlock_cache) {
+ mysql_mutex_lock(
+ &table->fts->cache->lock);
+ }
}
}
n_nodes += ib_vector_size(word->nodes);
- if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
-err_exit:
+ if (UNIV_UNLIKELY(error != DB_SUCCESS) && !print_error) {
ib::error() << "(" << error << ") writing"
" word node to FTS auxiliary index table "
<< table->name;
- break;
+ print_error = TRUE;
}
}
@@ -4035,44 +4068,58 @@ fts_sync_index(
ut_ad(rbt_validate(index_cache->words));
- return(fts_sync_write_words(trx, index_cache));
+ return(fts_sync_write_words(trx, index_cache, sync->unlock_cache));
}
-/** Rollback a sync operation
-@param[in,out] sync sync state */
+/** Check if index cache has been synced completely
+@param[in,out] index_cache index cache
+@return true if index is synced, otherwise false. */
static
-void
-fts_sync_rollback(
- fts_sync_t* sync)
+bool
+fts_sync_index_check(
+ fts_index_cache_t* index_cache)
{
- trx_t* trx = sync->trx;
- fts_cache_t* cache = sync->table->fts->cache;
-
- for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) {
- ulint j;
- fts_index_cache_t* index_cache;
-
- index_cache = static_cast<fts_index_cache_t*>(
- ib_vector_get(cache->indexes, i));
+ const ib_rbt_node_t* rbt_node;
- for (j = 0; fts_index_selector[j].value; ++j) {
+ for (rbt_node = rbt_first(index_cache->words);
+ rbt_node != NULL;
+ rbt_node = rbt_next(index_cache->words, rbt_node)) {
- if (index_cache->ins_graph[j] != NULL) {
+ fts_tokenizer_word_t* word;
+ word = rbt_value(fts_tokenizer_word_t, rbt_node);
- que_graph_free(index_cache->ins_graph[j]);
+ fts_node_t* fts_node;
+ fts_node = static_cast<fts_node_t*>(ib_vector_last(word->nodes));
- index_cache->ins_graph[j] = NULL;
- }
+ if (!fts_node->synced) {
+ return(false);
}
}
- mysql_mutex_unlock(&cache->lock);
+ return(true);
+}
- fts_sql_rollback(trx);
+/** Reset synced flag in index cache when rollback
+@param[in,out] index_cache index cache */
+static
+void
+fts_sync_index_reset(
+ fts_index_cache_t* index_cache)
+{
+ const ib_rbt_node_t* rbt_node;
- /* Avoid assertion in trx_t::free(). */
- trx->dict_operation_lock_mode = false;
- trx->free();
+ for (rbt_node = rbt_first(index_cache->words);
+ rbt_node != NULL;
+ rbt_node = rbt_next(index_cache->words, rbt_node)) {
+
+ fts_tokenizer_word_t* word;
+ word = rbt_value(fts_tokenizer_word_t, rbt_node);
+
+ fts_node_t* fts_node;
+ fts_node = static_cast<fts_node_t*>(ib_vector_last(word->nodes));
+
+ fts_node->synced = false;
+ }
}
/** Commit the SYNC, change state of processed doc ids etc.
@@ -4105,20 +4152,19 @@ fts_sync_commit(
sync, cache->deleted_doc_ids);
}
+ /* We need to do this within the deleted lock since fts_delete() can
+ attempt to add a deleted doc id to the cache deleted id array. */
+ fts_cache_clear(cache);
+ DEBUG_SYNC_C("fts_deleted_doc_ids_clear");
+ fts_cache_init(cache);
+ mysql_mutex_unlock(&cache->lock);
+
if (UNIV_LIKELY(error == DB_SUCCESS)) {
- /* We need to do this within the deleted lock
- since fts_delete() can attempt to add a deleted
- doc id to the cache deleted id array. */
- fts_cache_clear(cache);
- DEBUG_SYNC_C("fts_deleted_doc_ids_clear");
- fts_cache_init(cache);
- mysql_mutex_unlock(&cache->lock);
fts_sql_commit(trx);
} else {
+ fts_sql_rollback(trx);
ib::error() << "(" << error << ") during SYNC of "
"table " << sync->table->name;
- fts_sync_rollback(sync);
- return error;
}
if (UNIV_UNLIKELY(fts_enable_diag_print) && elapsed_time) {
@@ -4138,13 +4184,66 @@ fts_sync_commit(
return(error);
}
+/** Rollback a sync operation
+@param[in,out] sync sync state */
+static
+void
+fts_sync_rollback(
+ fts_sync_t* sync)
+{
+ trx_t* trx = sync->trx;
+ fts_cache_t* cache = sync->table->fts->cache;
+
+ for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) {
+ ulint j;
+ fts_index_cache_t* index_cache;
+
+ index_cache = static_cast<fts_index_cache_t*>(
+ ib_vector_get(cache->indexes, i));
+
+ /* Reset synced flag so nodes will not be skipped
+ in the next sync, see fts_sync_write_words(). */
+ fts_sync_index_reset(index_cache);
+
+ for (j = 0; fts_index_selector[j].value; ++j) {
+
+ if (index_cache->ins_graph[j] != NULL) {
+
+ que_graph_free(index_cache->ins_graph[j]);
+
+ index_cache->ins_graph[j] = NULL;
+ }
+
+ if (index_cache->sel_graph[j] != NULL) {
+
+ que_graph_free(index_cache->sel_graph[j]);
+
+ index_cache->sel_graph[j] = NULL;
+ }
+ }
+ }
+
+ mysql_mutex_unlock(&cache->lock);
+
+ fts_sql_rollback(trx);
+
+ /* Avoid assertion in trx_t::free(). */
+ trx->dict_operation_lock_mode = false;
+ trx->free();
+}
+
/** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] sync sync state
@param[in] unlock_cache whether unlock cache lock when write node
@param[in] wait whether wait when a sync is in progress
@return DB_SUCCESS if all OK */
-static dberr_t fts_sync(fts_sync_t *sync)
+static
+dberr_t
+fts_sync(
+ fts_sync_t* sync,
+ bool unlock_cache,
+ bool wait)
{
if (srv_read_only_mode) {
return DB_READ_ONLY;
@@ -4155,13 +4254,33 @@ static dberr_t fts_sync(fts_sync_t *sync)
fts_cache_t* cache = sync->table->fts->cache;
mysql_mutex_lock(&cache->lock);
+
+ /* Check if cache is being synced.
+ Note: we release cache lock in fts_sync_write_words() to
+ avoid long wait for the lock by other threads. */
+ if (sync->in_progress) {
+ if (!wait) {
+ mysql_mutex_unlock(&cache->lock);
+ return(DB_SUCCESS);
+ }
+ do {
+ my_cond_wait(&sync->cond, &cache->lock.m_mutex);
+ } while (sync->in_progress);
+ }
+
+ sync->unlock_cache = unlock_cache;
+ sync->in_progress = true;
+
DEBUG_SYNC_C("fts_sync_begin");
fts_sync_begin(sync);
+begin_sync:
const size_t fts_cache_size= fts_max_cache_size;
if (cache->total_size > fts_cache_size) {
/* Avoid the case: sync never finish when
insert/update keeps comming. */
+ ut_ad(sync->unlock_cache);
+ sync->unlock_cache = false;
ib::warn() << "Total InnoDB FTS size "
<< cache->total_size << " for the table "
<< cache->sync->table->name
@@ -4185,23 +4304,52 @@ static dberr_t fts_sync(fts_sync_t *sync)
error = fts_sync_index(sync, index_cache);
if (error != DB_SUCCESS) {
- goto err_exit;
+ goto end_sync;
+ }
+
+ if (!sync->unlock_cache
+ && cache->total_size < fts_max_cache_size) {
+ /* Reset the unlock cache if the value
+ is less than innodb_ft_cache_size */
+ sync->unlock_cache = true;
}
}
DBUG_EXECUTE_IF("fts_instrument_sync_interrupted",
+ sync->interrupted = true;
error = DB_INTERRUPTED;
- goto err_exit;
+ goto end_sync;
);
- if (error == DB_SUCCESS) {
+ /* Make sure all the caches are synced. */
+ for (i = 0; i < ib_vector_size(cache->indexes); ++i) {
+ fts_index_cache_t* index_cache;
+
+ index_cache = static_cast<fts_index_cache_t*>(
+ ib_vector_get(cache->indexes, i));
+
+ if (index_cache->index->to_be_dropped
+ || fts_sync_index_check(index_cache)) {
+ continue;
+ }
+
+ goto begin_sync;
+ }
+
+end_sync:
+ if (error == DB_SUCCESS && !sync->interrupted) {
error = fts_sync_commit(sync);
} else {
-err_exit:
fts_sync_rollback(sync);
- return error;
}
+ mysql_mutex_lock(&cache->lock);
+ ut_ad(sync->in_progress);
+ sync->interrupted = false;
+ sync->in_progress = false;
+ pthread_cond_broadcast(&sync->cond);
+ mysql_mutex_unlock(&cache->lock);
+
/* We need to check whether an optimize is required, for that
we make copies of the two variables that control the trigger. These
variables can change behind our back and we don't want to hold the
@@ -4213,7 +4361,6 @@ err_exit:
mysql_mutex_unlock(&cache->deleted_lock);
- DEBUG_SYNC_C("fts_sync_end");
return(error);
}
@@ -4222,12 +4369,12 @@ FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table
@param[in] wait whether wait for existing sync to finish
@return DB_SUCCESS on success, error code on failure. */
-dberr_t fts_sync_table(dict_table_t* table)
+dberr_t fts_sync_table(dict_table_t* table, bool wait)
{
ut_ad(table->fts);
return table->space && !table->corrupted && table->fts->cache
- ? fts_sync(table->fts->cache->sync)
+ ? fts_sync(table->fts->cache->sync, !wait, wait)
: DB_SUCCESS;
}
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 7c40a25e6e7..fe31767d901 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -83,8 +83,9 @@ enum fts_msg_type_t {
FTS_MSG_ADD_TABLE, /*!< Add table to the optimize thread's
work queue */
- FTS_MSG_DEL_TABLE /*!< Remove a table from the optimize
+ FTS_MSG_DEL_TABLE, /*!< Remove a table from the optimize
threads work queue */
+ FTS_MSG_SYNC_TABLE /*!< Sync fts cache of a table */
};
/** Compressed list of words that have been read from FTS INDEX
@@ -2624,6 +2625,36 @@ fts_optimize_remove_table(
mysql_mutex_unlock(&fts_optimize_wq->mutex);
}
+/** Send sync fts cache for the table.
+@param[in] table table to sync */
+void
+fts_optimize_request_sync_table(
+ dict_table_t* table)
+{
+ /* if the optimize system not yet initialized, return */
+ if (!fts_optimize_wq) {
+ return;
+ }
+
+ mysql_mutex_lock(&fts_optimize_wq->mutex);
+
+ /* FTS optimizer thread is already exited */
+ if (fts_opt_start_shutdown) {
+ ib::info() << "Try to sync table " << table->name
+ << " after FTS optimize thread exiting.";
+ } else if (table->fts->sync_message) {
+ /* If the table already has SYNC message in
+ fts_optimize_wq queue then ignore it */
+ } else {
+ add_msg(fts_optimize_create_msg(FTS_MSG_SYNC_TABLE, table));
+ table->fts->sync_message = true;
+ DBUG_EXECUTE_IF("fts_optimize_wq_count_check",
+ DBUG_ASSERT(fts_optimize_wq->length <= 1000););
+ }
+
+ mysql_mutex_unlock(&fts_optimize_wq->mutex);
+}
+
/** Add a table to fts_slots if it doesn't already exist. */
static bool fts_optimize_new_table(dict_table_t* table)
{
@@ -2765,8 +2796,7 @@ static void fts_optimize_sync_table(dict_table_t *table,
if (sync_table->fts && sync_table->fts->cache && sync_table->is_accessible())
{
- fts_sync_table(sync_table);
-
+ fts_sync_table(sync_table, false);
if (process_message)
{
mysql_mutex_lock(&fts_optimize_wq->mutex);
@@ -2866,6 +2896,24 @@ retry_later:
--n_tables;
}
break;
+
+ case FTS_MSG_SYNC_TABLE:
+ if (UNIV_UNLIKELY(wsrep_sst_disable_writes)) {
+ add_msg(msg);
+ goto retry_later;
+ }
+
+ DBUG_EXECUTE_IF(
+ "fts_instrument_msg_sync_sleep",
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(
+ 300)););
+
+ fts_optimize_sync_table(
+ static_cast<dict_table_t*>(msg->ptr),
+ true);
+ break;
+
default:
ut_error;
}
@@ -2998,7 +3046,7 @@ void fts_sync_during_ddl(dict_table_t* table)
if (!sync_message)
return;
- fts_sync_table(table);
+ fts_sync_table(table, false);
mysql_mutex_lock(&fts_optimize_wq->mutex);
table->fts->sync_message = false;
diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc
index 60218a132c9..f75eab07cf3 100644
--- a/storage/innobase/gis/gis0rtree.cc
+++ b/storage/innobase/gis/gis0rtree.cc
@@ -1468,7 +1468,8 @@ rtr_ins_enlarge_mbr(
/* Check path info is not empty. */
ut_ad(!btr_cur->rtr_info->parent_path->empty());
- ut_ad(btr_cur->rtr_info->thr || !btr_cur->index()->is_committed());
+ ut_ad(btr_cur->rtr_info->thr || !btr_cur->index()->is_committed()
+ || btr_cur->index()->table->name.is_temporary());
/* Create a memory heap. */
heap = mem_heap_create(1024);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 211126765f8..6345435af97 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -526,6 +526,7 @@ mysql_pfs_key_t trx_pool_manager_mutex_key;
mysql_pfs_key_t lock_wait_mutex_key;
mysql_pfs_key_t trx_sys_mutex_key;
mysql_pfs_key_t srv_threads_mutex_key;
+mysql_pfs_key_t tpool_cache_mutex_key;
/* all_innodb_mutexes array contains mutexes that are
performance schema instrumented if "UNIV_PFS_MUTEX"
@@ -557,6 +558,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(rtr_match_mutex),
PSI_KEY(rtr_path_mutex),
PSI_KEY(trx_sys_mutex),
+ PSI_KEY(tpool_cache_mutex),
};
# endif /* UNIV_PFS_MUTEX */
@@ -1527,6 +1529,7 @@ static void innodb_drop_database(handlerton*, char *path)
mtr.commit();
for (pfs_os_file_t detached : to_close)
os_file_close(detached);
+
/* Any changes must be persisted before we return. */
log_write_up_to(mtr.commit_lsn(), true);
}
@@ -2036,7 +2039,7 @@ static void innodb_ddl_recovery_done(handlerton*)
{
ut_ad(!ddl_recovery_done);
ut_d(ddl_recovery_done= true);
- if (!srv_read_only_mode && srv_operation == SRV_OPERATION_NORMAL &&
+ if (!srv_read_only_mode && srv_operation <= SRV_OPERATION_EXPORT_RESTORED &&
srv_force_recovery < SRV_FORCE_NO_BACKGROUND)
{
if (srv_start_after_restore && !high_level_read_only)
@@ -8439,6 +8442,37 @@ wsrep_calc_row_hash(
return(0);
}
+
+/** Append table-level exclusive key.
+@param thd MySQL thread handle
+@param table table
+@retval false on success
+@retval true on failure */
+ATTRIBUTE_COLD bool wsrep_append_table_key(MYSQL_THD thd, const dict_table_t &table)
+{
+ char db_buf[NAME_LEN + 1];
+ char tbl_buf[NAME_LEN + 1];
+ ulint db_buf_len, tbl_buf_len;
+
+ if (!table.parse_name(db_buf, tbl_buf, &db_buf_len, &tbl_buf_len))
+ {
+ WSREP_ERROR("Parse_name for table key append failed: %s",
+ wsrep_thd_query(thd));
+ return true;
+ }
+
+ /* Append table-level exclusive key */
+ const int rcode = wsrep_thd_append_table_key(thd, db_buf,
+ tbl_buf, WSREP_SERVICE_KEY_EXCLUSIVE);
+ if (rcode)
+ {
+ WSREP_ERROR("Appending table key failed: %s, %d",
+ wsrep_thd_query(thd), rcode);
+ return true;
+ }
+
+ return false;
+}
#endif /* WITH_WSREP */
/**
@@ -8609,11 +8643,16 @@ func_exit:
&& !wsrep_thd_ignore_table(m_user_thd)) {
DBUG_PRINT("wsrep", ("update row key"));
- if (wsrep_append_keys(m_user_thd,
- wsrep_protocol_version >= 4
- ? WSREP_SERVICE_KEY_UPDATE
- : WSREP_SERVICE_KEY_EXCLUSIVE,
- old_row, new_row)){
+ /* We use table-level exclusive key for SEQUENCES
+ and normal key append for others. */
+ if (table->s->table_type == TABLE_TYPE_SEQUENCE) {
+ if (wsrep_append_table_key(m_user_thd, *m_prebuilt->table))
+ DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
+ } else if (wsrep_append_keys(m_user_thd,
+ wsrep_protocol_version >= 4
+ ? WSREP_SERVICE_KEY_UPDATE
+ : WSREP_SERVICE_KEY_EXCLUSIVE,
+ old_row, new_row)) {
WSREP_DEBUG("WSREP: UPDATE_ROW_KEY FAILED");
DBUG_PRINT("wsrep", ("row key failed"));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
@@ -17821,44 +17860,6 @@ exit:
return;
}
-/** Validate SET GLOBAL innodb_buffer_pool_filename.
-On Windows, file names with colon (:) are not allowed.
-@param thd connection
-@param save &srv_buf_dump_filename
-@param value new value to be validated
-@return 0 for valid name */
-static int innodb_srv_buf_dump_filename_validate(THD *thd, st_mysql_sys_var*,
- void *save,
- st_mysql_value *value)
-{
- char buff[OS_FILE_MAX_PATH];
- int len= sizeof buff;
-
- if (const char *buf_name= value->val_str(value, buff, &len))
- {
-#ifdef _WIN32
- if (!is_filename_allowed(buf_name, len, FALSE))
- {
- push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
- ER_WRONG_ARGUMENTS,
- "InnoDB: innodb_buffer_pool_filename "
- "cannot have colon (:) in the file name.");
- return 1;
- }
-#endif /* _WIN32 */
- if (buf_name == buff)
- {
- ut_ad(static_cast<size_t>(len) < sizeof buff);
- buf_name= thd_strmake(thd, buf_name, len);
- }
-
- *static_cast<const char**>(save)= buf_name;
- return 0;
- }
-
- return 1;
-}
-
#ifdef UNIV_DEBUG
static char* srv_buffer_pool_evict;
@@ -18975,9 +18976,9 @@ static MYSQL_SYSVAR_SIZE_T(buffer_pool_chunk_size, srv_buf_pool_chunk_unit,
0, 0, SIZE_T_MAX, 1024 * 1024);
static MYSQL_SYSVAR_STR(buffer_pool_filename, srv_buf_dump_filename,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Filename to/from which to dump/load the InnoDB buffer pool",
- innodb_srv_buf_dump_filename_validate, NULL, SRV_BUF_DUMP_FILENAME_DEFAULT);
+ NULL, NULL, SRV_BUF_DUMP_FILENAME_DEFAULT);
static MYSQL_SYSVAR_BOOL(buffer_pool_dump_now, innodb_buffer_pool_dump_now,
PLUGIN_VAR_RQCMDARG,
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 5ce41a9857c..406baf3e662 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -11604,8 +11604,12 @@ foreign_fail:
ut_d(dict_table_check_for_dup_indexes(
ctx->new_table, CHECK_ABORTED_OK));
- ut_ad(!ctx->new_table->fts
- || fts_check_cached_index(ctx->new_table));
+#ifdef UNIV_DEBUG
+ if (!(ctx->new_table->fts != NULL
+ && ctx->new_table->fts->cache->sync->in_progress)) {
+ ut_a(fts_check_cached_index(ctx->new_table));
+ }
+#endif
}
unlock_and_close_files(deleted, trx);
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 589182b73ba..2786c26271d 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -4923,10 +4923,10 @@ static ST_FIELD_INFO innodb_sysindex_fields_info[]=
Column("N_FIELDS", SLong(), NOT_NULL),
#define SYS_INDEX_PAGE_NO 5
- Column("PAGE_NO", SLong(), NOT_NULL),
+ Column("PAGE_NO", SLong(), NULLABLE),
#define SYS_INDEX_SPACE 6
- Column("SPACE", SLong(), NOT_NULL),
+ Column("SPACE", SLong(), NULLABLE),
#define SYS_INDEX_MERGE_THRESHOLD 7
Column("MERGE_THRESHOLD", SLong(), NOT_NULL),
@@ -4978,12 +4978,14 @@ i_s_dict_fill_sys_indexes(
if (index->page == FIL_NULL) {
fields[SYS_INDEX_PAGE_NO]->set_null();
} else {
+ fields[SYS_INDEX_PAGE_NO]->set_notnull();
OK(fields[SYS_INDEX_PAGE_NO]->store(index->page, true));
}
- if (space_id == ULINT_UNDEFINED) {
+ if (space_id == FIL_NULL) {
fields[SYS_INDEX_SPACE]->set_null();
} else {
+ fields[SYS_INDEX_SPACE]->set_notnull();
OK(fields[SYS_INDEX_SPACE]->store(space_id, true));
}
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 420d4a388e8..9ff65ce7c9c 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1592,8 +1592,6 @@ public:
/** map of block->frame to buf_block_t blocks that belong
to buf_buddy_alloc(); protected by buf_pool.mutex */
hash_table_t zip_hash;
- /** number of pending read operations */
- Atomic_counter<ulint> n_pend_reads;
Atomic_counter<ulint>
n_pend_unzip; /*!< number of pending decompressions */
@@ -1620,7 +1618,7 @@ public:
/** flush_list size in bytes; protected by flush_list_mutex */
ulint flush_list_bytes;
/** possibly modified persistent pages (a subset of LRU);
- buf_dblwr.pending_writes() is approximately COUNT(is_write_fixed()) */
+ os_aio_pending_writes() is approximately COUNT(is_write_fixed()) */
UT_LIST_BASE_NODE_T(buf_page_t) flush_list;
/** number of blocks ever added to flush_list;
sometimes protected by flush_list_mutex */
@@ -1776,18 +1774,6 @@ public:
/** Reserve a buffer. */
buf_tmp_buffer_t *io_buf_reserve() { return io_buf.reserve(); }
- /** @return whether any I/O is pending */
- bool any_io_pending()
- {
- if (n_pend_reads)
- return true;
- mysql_mutex_lock(&flush_list_mutex);
- const bool any_pending= page_cleaner_status > PAGE_CLEANER_IDLE ||
- buf_dblwr.pending_writes();
- mysql_mutex_unlock(&flush_list_mutex);
- return any_pending;
- }
-
/** Remove a block from flush_list.
@param bpage buffer pool page */
void delete_from_flush_list(buf_page_t *bpage) noexcept;
diff --git a/storage/innobase/include/buf0dblwr.h b/storage/innobase/include/buf0dblwr.h
index d9c9239c0b4..9932b0e521f 100644
--- a/storage/innobase/include/buf0dblwr.h
+++ b/storage/innobase/include/buf0dblwr.h
@@ -66,16 +66,10 @@ class buf_dblwr_t
bool batch_running;
/** number of expected flush_buffered_writes_completed() calls */
unsigned flushing_buffered_writes;
- /** pages submitted to flush_buffered_writes() */
- ulint pages_submitted;
/** number of flush_buffered_writes_completed() calls */
ulint writes_completed;
/** number of pages written by flush_buffered_writes_completed() */
ulint pages_written;
- /** condition variable for !writes_pending */
- pthread_cond_t write_cond;
- /** number of pending page writes */
- size_t writes_pending;
slot slots[2];
slot *active_slot;
@@ -98,9 +92,6 @@ public:
/** Acquire the mutex */
void lock() { mysql_mutex_lock(&mutex); }
- /** @return the number of submitted page writes */
- ulint submitted() const
- { mysql_mutex_assert_owner(&mutex); return pages_submitted; }
/** @return the number of completed batches */
ulint batches() const
{ mysql_mutex_assert_owner(&mutex); return writes_completed; }
@@ -124,7 +115,7 @@ public:
void recover();
/** Update the doublewrite buffer on data page write completion. */
- void write_completed(bool with_doublewrite);
+ void write_completed();
/** Flush possible buffered writes to persistent storage.
It is very important to call this function after a batch of writes has been
posted, and also when we may have to wait for a page latch!
@@ -167,40 +158,6 @@ public:
my_cond_wait(&cond, &mutex.m_mutex);
mysql_mutex_unlock(&mutex);
}
-
- /** Register an unbuffered page write */
- void add_unbuffered()
- {
- mysql_mutex_lock(&mutex);
- writes_pending++;
- mysql_mutex_unlock(&mutex);
- }
-
- size_t pending_writes()
- {
- mysql_mutex_lock(&mutex);
- const size_t pending{writes_pending};
- mysql_mutex_unlock(&mutex);
- return pending;
- }
-
- /** Wait for writes_pending to reach 0 */
- void wait_for_page_writes()
- {
- mysql_mutex_lock(&mutex);
- while (writes_pending)
- my_cond_wait(&write_cond, &mutex.m_mutex);
- mysql_mutex_unlock(&mutex);
- }
-
- /** Wait for writes_pending to reach 0 */
- void wait_for_page_writes(const timespec &abstime)
- {
- mysql_mutex_lock(&mutex);
- while (writes_pending)
- my_cond_timedwait(&write_cond, &mutex.m_mutex, &abstime);
- mysql_mutex_unlock(&mutex);
- }
};
/** The doublewrite buffer */
diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h
index f53279ecb88..e4e0b2c9c74 100644
--- a/storage/innobase/include/fil0fil.h
+++ b/storage/innobase/include/fil0fil.h
@@ -597,8 +597,7 @@ private:
@return number of pending operations, possibly with NEEDS_FSYNC flag */
uint32_t set_closing()
{
- return n_pending.fetch_or(CLOSING, std::memory_order_acquire) &
- (PENDING | NEEDS_FSYNC);
+ return n_pending.fetch_or(CLOSING, std::memory_order_acquire);
}
public:
@@ -1470,6 +1469,7 @@ public:
if (space_list_last_opened == space)
{
+ ut_ad(s != space_list.begin());
space_list_t::iterator prev= s;
space_list_last_opened= &*--prev;
}
diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h
index 720fe7f25b9..c0151b44063 100644
--- a/storage/innobase/include/fts0fts.h
+++ b/storage/innobase/include/fts0fts.h
@@ -648,6 +648,12 @@ fts_optimize_remove_table(
void
fts_optimize_shutdown();
+/** Send sync fts cache for the table.
+@param[in] table table to sync */
+void
+fts_optimize_request_sync_table(
+ dict_table_t* table);
+
/**********************************************************************//**
Take a FTS savepoint. */
void
@@ -702,8 +708,9 @@ fts_savepoint_rollback_last_stmt(
/** Run SYNC on the table, i.e., write out data from the cache to the
FTS auxiliary INDEX table and clear the cache at the end.
@param[in,out] table fts table
+@param[in] wait whether to wait for existing sync to finish
@return DB_SUCCESS on success, error code on failure. */
-dberr_t fts_sync_table(dict_table_t* table);
+dberr_t fts_sync_table(dict_table_t* table, bool wait = true);
/****************************************************************//**
Create an FTS index cache. */
diff --git a/storage/innobase/include/fts0types.h b/storage/innobase/include/fts0types.h
index 04e99d595c5..fb278d543c4 100644
--- a/storage/innobase/include/fts0types.h
+++ b/storage/innobase/include/fts0types.h
@@ -75,6 +75,7 @@ struct fts_index_cache_t {
que_t** ins_graph; /*!< Insert query graphs */
+ que_t** sel_graph; /*!< Select query graphs */
CHARSET_INFO* charset; /*!< charset */
};
@@ -86,7 +87,35 @@ struct fts_stopword_t {
CHARSET_INFO* charset; /*!< charset for stopword */
};
-struct fts_sync_t;
+/** The SYNC state of the cache. There is one instance of this struct
+associated with each ADD thread. */
+struct fts_sync_t {
+ trx_t* trx; /*!< The transaction used for SYNCing
+ the cache to disk */
+ dict_table_t* table; /*!< Table with FTS index(es) */
+ ulint max_cache_size; /*!< Max size in bytes of the cache */
+ ibool cache_full; /*!< flag, when true it indicates that
+ we need to sync the cache to disk */
+ ulint lower_index; /*!< the start index of the doc id
+ vector from where to start adding
+ documents to the FTS cache */
+ ulint upper_index; /*!< max index of the doc id vector to
+ add to the FTS cache */
+ ibool interrupted; /*!< TRUE if SYNC was interrupted */
+ doc_id_t min_doc_id; /*!< The smallest doc id added to the
+ cache. It should equal to
+ doc_ids[lower_index] */
+ doc_id_t max_doc_id; /*!< The doc id at which the cache was
+ noted as being full, we use this to
+ set the upper_limit field */
+ time_t start_time; /*!< SYNC start time; only used if
+ fts_enable_diag_print */
+ bool in_progress; /*!< flag whether sync is in progress.*/
+ bool unlock_cache; /*!< flag whether unlock cache when
+ write fts node */
+ /** condition variable for in_progress; used with table->fts->cache->lock */
+ pthread_cond_t cond;
+};
/** The cache for the FTS system. It is a memory-based inverted index
that new entries are added to, until it grows over the configured maximum
@@ -175,6 +204,7 @@ struct fts_node_t {
ulint ilist_size_alloc;
/*!< Allocated size of ilist in
bytes */
+ bool synced; /*!< flag whether the node is synced */
};
/** A tokenizer word. Contains information about one word. */
diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h
index da9dec05827..d5239ec3f9a 100644
--- a/storage/innobase/include/ha_prototypes.h
+++ b/storage/innobase/include/ha_prototypes.h
@@ -462,5 +462,15 @@ void destroy_background_thd(MYSQL_THD thd);
void
innobase_reset_background_thd(MYSQL_THD);
+#ifdef WITH_WSREP
+/** Append table-level exclusive key.
+@param thd MySQL thread handle
+@param table table
+@retval false on success
+@retval true on failure */
+struct dict_table_t;
+bool wsrep_append_table_key(MYSQL_THD thd, const dict_table_t &table);
+#endif /* WITH_WSREP */
+
#endif /* !UNIV_INNOCHECKSUM */
#endif /* HA_INNODB_PROTOTYPES_H */
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index 8afa92abc93..cd596b4db46 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -382,7 +382,6 @@ public:
lsn_t get_lsn(std::memory_order order= std::memory_order_relaxed) const
{ return lsn.load(order); }
- void set_lsn(lsn_t lsn) { this->lsn.store(lsn, std::memory_order_release); }
lsn_t get_flushed_lsn(std::memory_order order= std::memory_order_acquire)
const noexcept
@@ -519,11 +518,10 @@ public:
/** Redo log system */
extern log_t log_sys;
-inline void log_free_check()
-{
- if (log_sys.check_flush_or_checkpoint())
- log_check_margins();
-}
+/** Wait for a log checkpoint if needed.
+NOTE that this function may only be called while not holding
+any synchronization objects except dict_sys.latch. */
+void log_free_check();
/** Release the latches that protect log resizing. */
void log_resize_release();
diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h
index 5576560dca8..81f1f2b0dc9 100644
--- a/storage/innobase/include/mtr0mtr.h
+++ b/storage/innobase/include/mtr0mtr.h
@@ -93,10 +93,16 @@ struct mtr_t {
ATTRIBUTE_COLD void commit_shrink(fil_space_t &space);
/** Commit a mini-transaction that is deleting or renaming a file.
- @param space tablespace that is being renamed or deleted
- @param name new file name (nullptr=the file will be deleted)
+ @param space tablespace that is being renamed or deleted
+ @param name new file name (nullptr=the file will be deleted)
+ @param detached_handle if detached_handle != nullptr and if space is detached
+ during the function execution the file handle if its
+ node will be set to OS_FILE_CLOSED, and the previous
+ value of the file handle will be assigned to the
+ address, pointed by detached_handle.
@return whether the operation succeeded */
- ATTRIBUTE_COLD bool commit_file(fil_space_t &space, const char *name);
+ ATTRIBUTE_COLD bool commit_file(fil_space_t &space, const char *name,
+ pfs_os_file_t *detached_handle= nullptr);
/** Commit a mini-transaction that did not modify any pages,
but generated some redo log on a higher level, such as
@@ -326,7 +332,7 @@ public:
{
mtr_memo_slot_t &slot= m_memo[savepoint];
ut_ad(slot.type <= MTR_MEMO_BUF_FIX);
- ut_ad(type <= MTR_MEMO_BUF_FIX);
+ ut_ad(type < MTR_MEMO_S_LOCK);
slot.type= type;
}
diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h
index c0e5f7683a9..13f9d3de3f8 100644
--- a/storage/innobase/include/os0file.h
+++ b/storage/innobase/include/os0file.h
@@ -933,13 +933,14 @@ os_file_flush_func(
/** Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
-the OS error number + 100 is returned.
-@param[in] report true if we want an error message printed
- for all errors
-@return error number, or OS error number + 100 */
-ulint
-os_file_get_last_error(
- bool report);
+the OS error number + OS_FILE_ERROR_MAX is returned.
+@param[in] report_all_errors true if we want an error message
+ printed of all errors
+@param[in] on_error_silent true then don't print any diagnostic
+ to the log
+@return error number, or OS error number + OS_FILE_ERROR_MAX */
+ulint os_file_get_last_error(bool report_all_errors,
+ bool on_error_silent= false);
/** NOTE! Use the corresponding macro os_file_read(), not directly this
function!
@@ -1048,11 +1049,20 @@ void os_aio_free();
@retval DB_IO_ERROR on I/O error */
dberr_t os_aio(const IORequest &type, void *buf, os_offset_t offset, size_t n);
-/** Wait until there are no pending asynchronous writes. */
-void os_aio_wait_until_no_pending_writes();
+/** @return number of pending reads */
+size_t os_aio_pending_reads();
+/** @return approximate number of pending reads */
+size_t os_aio_pending_reads_approx();
+/** @return number of pending writes */
+size_t os_aio_pending_writes();
-/** Wait until all pending asynchronous reads have completed. */
-void os_aio_wait_until_no_pending_reads();
+/** Wait until there are no pending asynchronous writes.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_writes(bool declare);
+
+/** Wait until all pending asynchronous reads have completed.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_reads(bool declare);
/** Prints info of the aio arrays.
@param[in/out] file file where to print */
diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h
index 0c6aa8a94bb..6f0acbde975 100644
--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -317,6 +317,9 @@ extern my_bool srv_immediate_scrub_data_uncompressed;
enum srv_operation_mode {
/** Normal mode (MariaDB Server) */
SRV_OPERATION_NORMAL,
+ /** Mariabackup is executing server to export already restored
+ tablespaces */
+ SRV_OPERATION_EXPORT_RESTORED,
/** Mariabackup taking a backup */
SRV_OPERATION_BACKUP,
/** Mariabackup restoring a backup for subsequent --copy-back */
diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h
index ac39d3ec45b..bf6f6eb8eff 100644
--- a/storage/innobase/include/trx0purge.h
+++ b/storage/innobase/include/trx0purge.h
@@ -41,10 +41,11 @@ void
trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr);
/**
Run a purge batch.
-@param n_tasks number of purge tasks to submit to the queue
-@param truncate whether to truncate the history at the end of the batch
+@param n_tasks number of purge tasks to submit to the queue
+@param history_size trx_sys.history_size()
+@param truncate whether to truncate the history at the end of the batch
@return number of undo log pages handled in the batch */
-ulint trx_purge(ulint n_tasks, bool truncate);
+ulint trx_purge(ulint n_tasks, ulint history_size, bool truncate);
/** Rollback segements from a given transaction with trx-no
scheduled for purge. */
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h
index 6e0eb547eb8..43e0c290d63 100644
--- a/storage/innobase/include/trx0rseg.h
+++ b/storage/innobase/include/trx0rseg.h
@@ -129,7 +129,8 @@ public:
#endif
}
/** @return whether the segment is marked for undo truncation */
- bool skip_allocation() const { return ref_load() & SKIP; }
+ bool skip_allocation() const
+ { return ref.load(std::memory_order_acquire) & SKIP; }
/** Increment the reference count */
void acquire()
{ ut_d(auto r=) ref.fetch_add(REF); ut_ad(!(r & SKIP)); }
diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h
index 4728e7ef2bf..8adff09a3df 100644
--- a/storage/innobase/include/trx0undo.h
+++ b/storage/innobase/include/trx0undo.h
@@ -203,16 +203,18 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr)
MY_ATTRIBUTE((nonnull));
/** Assign an undo log for a transaction.
A new undo log is created or a cached undo log reused.
+@tparam is_temp whether this is temporary undo log
@param[in,out] trx transaction
@param[in] rseg rollback segment
@param[out] undo the undo log
-@param[out] err error code
@param[in,out] mtr mini-transaction
+@param[out] err error code
@return the undo log block
-@retval NULL on error */
+@retval nullptr on error */
+template<bool is_temp>
buf_block_t*
-trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
- dberr_t* err, mtr_t* mtr)
+trx_undo_assign_low(trx_t *trx, trx_rseg_t *rseg, trx_undo_t **undo,
+ mtr_t *mtr, dberr_t *err)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/******************************************************************//**
Sets the state of the undo log segment at a transaction finish.
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index 209e1e60e2a..d763ef10734 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -1060,6 +1060,16 @@ ATTRIBUTE_COLD void log_check_margins()
while (log_sys.check_flush_or_checkpoint());
}
+/** Wait for a log checkpoint if needed.
+NOTE that this function may only be called while not holding
+any synchronization objects except dict_sys.latch. */
+void log_free_check()
+{
+ ut_ad(!lock_sys.is_writer());
+ if (log_sys.check_flush_or_checkpoint())
+ log_check_margins();
+}
+
extern void buf_resize_shutdown();
/** Make a checkpoint at the latest lsn on shutdown. */
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 3443369af6c..2d1c2a9419f 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -763,9 +763,10 @@ retry:
if (!os_file_status(name->c_str(), &exists, &ftype) || !exists)
goto processed;
}
- create(it, *name, static_cast<uint32_t>
- (1U << FSP_FLAGS_FCRC32_POS_MARKER |
- FSP_FLAGS_FCRC32_PAGE_SSIZE()), nullptr, 0);
+ if (create(it, *name, static_cast<uint32_t>
+ (1U << FSP_FLAGS_FCRC32_POS_MARKER |
+ FSP_FLAGS_FCRC32_PAGE_SSIZE()), nullptr, 0))
+ mysql_mutex_unlock(&fil_system.mutex);
}
}
else
@@ -794,7 +795,7 @@ processed:
@param flags FSP_SPACE_FLAGS
@param crypt_data encryption metadata
@param size tablespace size in pages
- @return tablespace
+ @return tablespace; the caller must release fil_system.mutex
@retval nullptr if crypt_data is invalid */
static fil_space_t *create(const recv_spaces_t::const_iterator &it,
const std::string &name, uint32_t flags,
@@ -806,6 +807,7 @@ processed:
ut_free(crypt_data);
return nullptr;
}
+ mysql_mutex_lock(&fil_system.mutex);
fil_space_t *space= fil_space_t::create(it->first, flags,
FIL_TYPE_TABLESPACE, crypt_data);
ut_ad(space);
@@ -866,12 +868,13 @@ processed:
space->free_limit= fsp_header_get_field(page, FSP_FREE_LIMIT);
space->free_len= flst_get_len(FSP_HEADER_OFFSET + FSP_FREE + page);
fil_node_t *node= UT_LIST_GET_FIRST(space->chain);
+ mysql_mutex_unlock(&fil_system.mutex);
if (!space->acquire())
- {
+ {
free_space:
fil_space_free(it->first, false);
goto next_item;
- }
+ }
if (os_file_write(IORequestWrite, node->name, node->handle,
page, 0, fil_space_t::physical_size(flags)) !=
DB_SUCCESS)
@@ -941,6 +944,7 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p,
space->free_len= flst_get_len(FSP_HEADER_OFFSET + FSP_FREE + page);
fil_node_t *node= UT_LIST_GET_FIRST(space->chain);
node->deferred= true;
+ mysql_mutex_unlock(&fil_system.mutex);
if (!space->acquire())
goto release_and_fail;
fil_names_dirty(space);
@@ -964,8 +968,10 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p,
uint32_t(file_size / fil_space_t::physical_size(flags));
if (n_pages > size)
{
+ mysql_mutex_lock(&fil_system.mutex);
space->size= node->size= n_pages;
space->set_committed_size();
+ mysql_mutex_unlock(&fil_system.mutex);
goto size_set;
}
}
@@ -1120,7 +1126,7 @@ static void fil_name_process(const char *name, ulint len, uint32_t space_id,
return;
}
- ut_ad(srv_operation == SRV_OPERATION_NORMAL
+ ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT);
@@ -1239,8 +1245,9 @@ same_space:
ut_ad(space == NULL);
if (srv_force_recovery == 0) {
sql_print_error("InnoDB: Recovery cannot access"
- " file %s (tablespace "
- UINT32PF ")", name, space_id);
+ " file %.*s (tablespace "
+ UINT32PF ")", int(len), name,
+ space_id);
sql_print_information("InnoDB: You may set "
"innodb_force_recovery=1"
" to ignore this and"
@@ -1251,9 +1258,10 @@ same_space:
}
sql_print_warning("InnoDB: Ignoring changes to"
- " file %s (tablespace " UINT32PF ")"
+ " file %.*s (tablespace "
+ UINT32PF ")"
" due to innodb_force_recovery",
- name, space_id);
+ int(len), name, space_id);
}
}
}
@@ -3324,7 +3332,7 @@ static void log_sort_flush_list()
@param last_batch whether it is possible to write more redo log */
void recv_sys_t::apply(bool last_batch)
{
- ut_ad(srv_operation == SRV_OPERATION_NORMAL ||
+ ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED ||
srv_operation == SRV_OPERATION_RESTORE ||
srv_operation == SRV_OPERATION_RESTORE_EXPORT);
@@ -3475,7 +3483,7 @@ next_free_block:
for (;;)
{
const bool empty= pages.empty();
- if (empty && !buf_pool.n_pend_reads)
+ if (empty && !os_aio_pending_reads())
break;
if (!is_corrupt_fs() && !is_corrupt_log())
@@ -3487,8 +3495,7 @@ next_free_block:
else
{
mysql_mutex_unlock(&mutex);
- os_aio_wait_until_no_pending_reads();
- ut_ad(!buf_pool.n_pend_reads);
+ os_aio_wait_until_no_pending_reads(false);
mysql_mutex_lock(&mutex);
ut_ad(pages.empty());
}
@@ -4040,7 +4047,7 @@ dberr_t recv_recovery_from_checkpoint_start()
{
bool rescan = false;
- ut_ad(srv_operation == SRV_OPERATION_NORMAL
+ ut_ad(srv_operation <= SRV_OPERATION_EXPORT_RESTORED
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT);
ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
@@ -4157,7 +4164,7 @@ read_only_recovery:
rescan = true;
}
- if (srv_operation == SRV_OPERATION_NORMAL) {
+ if (srv_operation <= SRV_OPERATION_EXPORT_RESTORED) {
deferred_spaces.deferred_dblwr();
buf_dblwr.recover();
}
@@ -4220,7 +4227,7 @@ err_exit:
}
log_sys.buf_free = recv_sys.offset;
if (recv_needed_recovery
- && srv_operation == SRV_OPERATION_NORMAL) {
+ && srv_operation <= SRV_OPERATION_EXPORT_RESTORED) {
/* Write a FILE_CHECKPOINT marker as the first thing,
before generating any other redo log. This ensures
that subsequent crash recovery will be possible even
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 6d31a55e8ed..fe90487ebec 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -594,8 +594,14 @@ void mtr_t::commit_shrink(fil_space_t &space)
/** Commit a mini-transaction that is deleting or renaming a file.
@param space tablespace that is being renamed or deleted
@param name new file name (nullptr=the file will be deleted)
+@param detached_handle if detached_handle != nullptr and if space is detached
+ during the function execution the file handle if its
+ node will be set to OS_FILE_CLOSED, and the previous
+ value of the file handle will be assigned to the
+ address, pointed by detached_handle.
@return whether the operation succeeded */
-bool mtr_t::commit_file(fil_space_t &space, const char *name)
+bool mtr_t::commit_file(fil_space_t &space, const char *name,
+ pfs_os_file_t *detached_handle)
{
ut_ad(is_active());
ut_ad(!high_level_read_only);
@@ -683,7 +689,9 @@ bool mtr_t::commit_file(fil_space_t &space, const char *name)
ut_ad(!space.referenced());
ut_ad(space.is_stopping());
- fil_system.detach(&space, true);
+ pfs_os_file_t handle = fil_system.detach(&space, true);
+ if (detached_handle)
+ *detached_handle = handle;
mysql_mutex_unlock(&fil_system.mutex);
success= true;
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 98bf4fdb8ca..08f525be314 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -106,9 +106,9 @@ public:
}
/* Wait for completions of all AIO operations */
- void wait(std::unique_lock<std::mutex> &lk)
+ void wait(mysql_mutex_t &m)
{
- m_cache.wait(lk);
+ m_cache.wait(m);
}
void wait()
@@ -131,14 +131,13 @@ public:
wait();
}
- std::mutex& mutex()
+ mysql_mutex_t& mutex()
{
return m_cache.mutex();
}
- void resize(int max_submitted_io, int max_callback_concurrency, std::unique_lock<std::mutex> &lk)
+ void resize(int max_submitted_io, int max_callback_concurrency)
{
- ut_a(lk.owns_lock());
m_cache.resize(max_submitted_io);
m_group.set_max_tasks(max_callback_concurrency);
m_max_aio = max_submitted_io;
@@ -751,22 +750,16 @@ os_file_punch_hole_posix(
return(DB_IO_NO_PUNCH_HOLE);
}
-
-
/** Retrieves the last error number if an error occurs in a file io function.
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
the OS error number + 100 is returned.
@param[in] report_all_errors true if we want an error message
- printed of all errors
+ printed of all errors
@param[in] on_error_silent true then don't print any diagnostic
to the log
@return error number, or OS error number + 100 */
-static
-ulint
-os_file_get_last_error_low(
- bool report_all_errors,
- bool on_error_silent)
+ulint os_file_get_last_error(bool report_all_errors, bool on_error_silent)
{
int err = errno;
@@ -1801,16 +1794,13 @@ bool os_file_flush_func(os_file_t file)
The number should be retrieved before any other OS calls (because they may
overwrite the error number). If the number is not known to this program,
then OS error number + OS_FILE_ERROR_MAX is returned.
-@param[in] report_all_errors true if we want an error message printed
- of all errors
+@param[in] report_all_errors true if we want an error message
+printed of all errors
@param[in] on_error_silent true then don't print any diagnostic
to the log
@return error number, or OS error number + OS_FILE_ERROR_MAX */
-static
-ulint
-os_file_get_last_error_low(
- bool report_all_errors,
- bool on_error_silent)
+ulint os_file_get_last_error(bool report_all_errors, bool on_error_silent)
+
{
ulint err = (ulint) GetLastError();
@@ -2928,20 +2918,6 @@ os_file_read_func(
return err ? err : DB_IO_ERROR;
}
-/** Retrieves the last error number if an error occurs in a file io function.
-The number should be retrieved before any other OS calls (because they may
-overwrite the error number). If the number is not known to this program,
-the OS error number + 100 is returned.
-@param[in] report_all_errors true if we want an error printed
- for all errors
-@return error number, or OS error number + 100 */
-ulint
-os_file_get_last_error(
- bool report_all_errors)
-{
- return(os_file_get_last_error_low(report_all_errors, false));
-}
-
/** Handle errors for file operations.
@param[in] name name of a file or NULL
@param[in] operation operation
@@ -2958,7 +2934,7 @@ os_file_handle_error_cond_exit(
{
ulint err;
- err = os_file_get_last_error_low(false, on_error_silent);
+ err = os_file_get_last_error(false, on_error_silent);
switch (err) {
case OS_FILE_DISK_FULL:
@@ -3447,9 +3423,8 @@ static void io_callback(tpool::aiocb *cb)
else
{
ut_ad(write_slots->contains(cb));
- const IORequest req{request};
+ fil_aio_callback(request);
write_slots->release(cb);
- fil_aio_callback(req);
}
}
@@ -3647,8 +3622,9 @@ more concurrent threads via thread_group setting.
int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads)
{
/* Lock the slots, and wait until all current IOs finish.*/
- std::unique_lock<std::mutex> lk_read(read_slots->mutex());
- std::unique_lock<std::mutex> lk_write(write_slots->mutex());
+ auto &lk_read= read_slots->mutex(), &lk_write= write_slots->mutex();
+ mysql_mutex_lock(&lk_read);
+ mysql_mutex_lock(&lk_write);
read_slots->wait(lk_read);
write_slots->wait(lk_write);
@@ -3661,20 +3637,25 @@ int os_aio_resize(ulint n_reader_threads, ulint n_writer_threads)
/** Do the Linux AIO dance (this will try to create a new
io context with changed max_events ,etc*/
- if (int ret= srv_thread_pool->reconfigure_aio(srv_use_native_aio, events))
+ int ret= srv_thread_pool->reconfigure_aio(srv_use_native_aio, events);
+
+ if (ret)
{
/** Do the best effort. We can't change the parallel io number,
but we still can adjust the number of concurrent completion handlers.*/
read_slots->task_group().set_max_tasks(static_cast<int>(n_reader_threads));
write_slots->task_group().set_max_tasks(static_cast<int>(n_writer_threads));
- return ret;
+ }
+ else
+ {
+ /* Allocation succeeded, resize the slots*/
+ read_slots->resize(max_read_events, static_cast<int>(n_reader_threads));
+ write_slots->resize(max_write_events, static_cast<int>(n_writer_threads));
}
- /* Allocation succeeded, resize the slots*/
- read_slots->resize(max_read_events, static_cast<int>(n_reader_threads), lk_read);
- write_slots->resize(max_write_events, static_cast<int>(n_writer_threads), lk_write);
-
- return 0;
+ mysql_mutex_unlock(&lk_read);
+ mysql_mutex_unlock(&lk_write);
+ return ret;
}
void os_aio_free()
@@ -3687,9 +3668,9 @@ void os_aio_free()
}
/** Wait until there are no pending asynchronous writes. */
-static void os_aio_wait_until_no_pending_writes_low()
+static void os_aio_wait_until_no_pending_writes_low(bool declare)
{
- bool notify_wait = write_slots->pending_io_count() > 0;
+ const bool notify_wait= declare && write_slots->pending_io_count();
if (notify_wait)
tpool::tpool_wait_begin();
@@ -3700,17 +3681,43 @@ static void os_aio_wait_until_no_pending_writes_low()
tpool::tpool_wait_end();
}
-/** Wait until there are no pending asynchronous writes. */
-void os_aio_wait_until_no_pending_writes()
+/** Wait until there are no pending asynchronous writes.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_writes(bool declare)
{
- os_aio_wait_until_no_pending_writes_low();
+ os_aio_wait_until_no_pending_writes_low(declare);
buf_dblwr.wait_flush_buffered_writes();
}
-/** Wait until all pending asynchronous reads have completed. */
-void os_aio_wait_until_no_pending_reads()
+/** @return number of pending reads */
+size_t os_aio_pending_reads()
+{
+ mysql_mutex_lock(&read_slots->mutex());
+ size_t pending= read_slots->pending_io_count();
+ mysql_mutex_unlock(&read_slots->mutex());
+ return pending;
+}
+
+/** @return approximate number of pending reads */
+size_t os_aio_pending_reads_approx()
+{
+ return read_slots->pending_io_count();
+}
+
+/** @return number of pending writes */
+size_t os_aio_pending_writes()
+{
+ mysql_mutex_lock(&write_slots->mutex());
+ size_t pending= write_slots->pending_io_count();
+ mysql_mutex_unlock(&write_slots->mutex());
+ return pending;
+}
+
+/** Wait until all pending asynchronous reads have completed.
+@param declare whether the wait will be declared in tpool */
+void os_aio_wait_until_no_pending_reads(bool declare)
{
- const auto notify_wait= read_slots->pending_io_count();
+ const bool notify_wait= declare && read_slots->pending_io_count();
if (notify_wait)
tpool::tpool_wait_begin();
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index c7ad8399304..830a4bef9d9 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -3367,7 +3367,7 @@ page_zip_validate_low(
differed. Let us ignore it. */
page_zip_fail(("page_zip_validate:"
" min_rec_flag"
- " (%s" ULINTPF "," ULINTPF
+ " (%s" UINT32PF "," UINT32PF
",0x%02x)\n",
sloppy ? "ignored, " : "",
page_get_space_id(page),
@@ -3412,7 +3412,8 @@ page_zip_validate_low(
page + PAGE_NEW_INFIMUM, TRUE);
trec = page_rec_get_next_low(
temp_page + PAGE_NEW_INFIMUM, TRUE);
- const ulint n_core = page_is_leaf(page) ? index->n_fields : 0;
+ const ulint n_core = (index && page_is_leaf(page))
+ ? index->n_fields : 0;
do {
if (page_offset(rec) != page_offset(trec)) {
diff --git a/storage/innobase/rem/rem0cmp.cc b/storage/innobase/rem/rem0cmp.cc
index e48cad01530..3620363ff2e 100644
--- a/storage/innobase/rem/rem0cmp.cc
+++ b/storage/innobase/rem/rem0cmp.cc
@@ -300,8 +300,9 @@ int cmp_data(ulint mtype, ulint prtype, bool descending,
DBUG_ASSERT(is_strnncoll_compatible(prtype & DATA_MYSQL_TYPE_MASK));
if (CHARSET_INFO *cs= all_charsets[dtype_get_charset_coll(prtype)])
{
- cmp= cs->coll->strnncollsp_nchars(cs, data1, len1, data2, len2,
- std::max(len1, len2));
+ cmp= cs->coll->
+ strnncollsp_nchars(cs, data1, len1, data2, len2, std::max(len1, len2),
+ MY_STRNNCOLLSP_NCHARS_EMULATE_TRIMMED_TRAILING_SPACES);
goto func_exit;
}
goto no_collation;
diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc
index f489669b408..3f8e48763ea 100644
--- a/storage/innobase/rem/rem0rec.cc
+++ b/storage/innobase/rem/rem0rec.cc
@@ -242,9 +242,9 @@ enum rec_leaf_format {
REC_LEAF_INSTANT
};
-#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 11
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ < 12
# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 to 10 need this */
+# pragma GCC diagnostic ignored "-Wconversion" /* GCC 5 to 11 need this */
#endif
/** Determine the offset to each field in a leaf-page record
in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED.
@@ -291,7 +291,9 @@ rec_init_offsets_comp_ordinary(
!= n_core)
? UT_BITS_IN_BYTES(unsigned(index->get_n_nullable(n_core)))
: (redundant_temp
- ? UT_BITS_IN_BYTES(index->n_nullable)
+ ? (index->is_instant()
+ ? UT_BITS_IN_BYTES(index->get_n_nullable(n_core))
+ : UT_BITS_IN_BYTES(index->n_nullable))
: index->n_core_null_bytes);
if (mblob) {
@@ -448,7 +450,7 @@ start:
continue;
}
- len = offs += len;
+ len = offs += static_cast<rec_offs>(len);
} else {
len = offs += field->fixed_len;
}
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index 5d7ea475d43..eaf987d115d 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -3853,6 +3853,7 @@ page_corrupted:
block->page.zip.data = src;
frame_changed = true;
} else if (!page_compressed
+ && type != FIL_PAGE_TYPE_XDES
&& !block->page.zip.data) {
block->page.frame = src;
frame_changed = true;
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 24fb6eb39ce..eca839fa7be 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -48,6 +48,7 @@ Created 4/20/1996 Heikki Tuuri
#ifdef WITH_WSREP
#include <wsrep.h>
#include <mysql/service_wsrep.h>
+#include "ha_prototypes.h"
#endif /* WITH_WSREP */
/*************************************************************************
@@ -2580,42 +2581,6 @@ but GCC 4.8.5 does not support pop_options. */
# pragma GCC optimize ("O0")
#endif
-#ifdef WITH_WSREP
-/** Start bulk insert operation for Galera by appending
-table-level exclusive key for bulk insert.
-@param trx transaction
-@param index index
-@retval false on success
-@retval true on failure */
-ATTRIBUTE_COLD static bool row_ins_wsrep_start_bulk(trx_t *trx, const dict_index_t &index)
-{
- char db_buf[NAME_LEN + 1];
- char tbl_buf[NAME_LEN + 1];
- ulint db_buf_len, tbl_buf_len;
-
- if (!index.table->parse_name(db_buf, tbl_buf, &db_buf_len, &tbl_buf_len))
- {
- WSREP_ERROR("Parse_name for bulk insert failed: %s",
- wsrep_thd_query(trx->mysql_thd));
- trx->error_state = DB_ROLLBACK;
- return true;
- }
-
- /* Append table-level exclusive key for bulk insert. */
- const int rcode = wsrep_thd_append_table_key(trx->mysql_thd, db_buf,
- tbl_buf, WSREP_SERVICE_KEY_EXCLUSIVE);
- if (rcode)
- {
- WSREP_ERROR("Appending table key for bulk insert failed: %s, %d",
- wsrep_thd_query(trx->mysql_thd), rcode);
- trx->error_state = DB_ROLLBACK;
- return true;
- }
-
- return false;
-}
-#endif
-
/***************************************************************//**
Tries to insert an entry into a clustered index, ignoring foreign key
constraints. If a record with the same unique key is found, the other
@@ -2780,10 +2745,13 @@ avoid_bulk:
#ifdef WITH_WSREP
if (trx->is_wsrep())
{
- if (!wsrep_thd_is_local_transaction(trx->mysql_thd))
- goto skip_bulk_insert;
- if (row_ins_wsrep_start_bulk(trx, *index))
- goto err_exit;
+ if (!wsrep_thd_is_local_transaction(trx->mysql_thd))
+ goto skip_bulk_insert;
+ if (wsrep_append_table_key(trx->mysql_thd, *index->table))
+ {
+ trx->error_state = DB_ROLLBACK;
+ goto err_exit;
+ }
}
#endif /* WITH_WSREP */
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index a82bbc7cde6..b35783f1a92 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -758,11 +758,6 @@ error:
row_field, field, col->len,
old_table->space->zip_size(),
conv_heap);
- } else {
- /* Field length mismatch should not
- happen when rebuilding redundant row
- format table. */
- ut_ad(index->table->not_redundant());
}
}
}
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 81879431096..27f48c1a4de 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -66,17 +66,23 @@ Created 9/17/2000 Heikki Tuuri
#include <thread>
-/*******************************************************************//**
-Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */
-static
-void
-row_mysql_delay_if_needed(void)
-/*===========================*/
+/** Delay an INSERT, DELETE or UPDATE operation if the purge is lagging. */
+static void row_mysql_delay_if_needed()
{
- if (srv_dml_needed_delay) {
- std::this_thread::sleep_for(
- std::chrono::microseconds(srv_dml_needed_delay));
- }
+ const auto delay= srv_dml_needed_delay;
+ if (UNIV_UNLIKELY(delay != 0))
+ {
+ /* Adjust for purge_coordinator_state::refresh() */
+ log_sys.latch.rd_lock(SRW_LOCK_CALL);
+ const lsn_t last= log_sys.last_checkpoint_lsn,
+ max_age= log_sys.max_checkpoint_age;
+ log_sys.latch.rd_unlock();
+ const lsn_t lsn= log_sys.get_lsn();
+ if ((lsn - last) / 4 >= max_age / 5)
+ buf_flush_ahead(last + max_age / 5, false);
+ srv_wake_purge_thread_if_not_active();
+ std::this_thread::sleep_for(std::chrono::microseconds(delay));
+ }
}
/*******************************************************************//**
diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc
index 0a2647e8d6d..f716625ea59 100644
--- a/storage/innobase/row/row0purge.cc
+++ b/storage/innobase/row/row0purge.cc
@@ -162,8 +162,9 @@ close_and_exit:
ut_ad("corrupted SYS_INDEXES record" == 0);
}
- if (const uint32_t space_id = dict_drop_index_tree(
- &node->pcur, nullptr, &mtr)) {
+ const uint32_t space_id = dict_drop_index_tree(
+ &node->pcur, nullptr, &mtr);
+ if (space_id) {
if (table) {
if (table->get_ref_count() == 0) {
dict_sys.remove(table);
diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc
index 059aee6f140..5b0676a3e0d 100644
--- a/storage/innobase/row/row0quiesce.cc
+++ b/storage/innobase/row/row0quiesce.cc
@@ -540,7 +540,7 @@ row_quiesce_table_start(
if (!trx_is_interrupted(trx)) {
/* Ensure that all asynchronous IO is completed. */
- os_aio_wait_until_no_pending_writes();
+ os_aio_wait_until_no_pending_writes(true);
table->space->flush<false>();
if (row_quiesce_write_cfg(table, trx->mysql_thd)
diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc
index 6b4393d4113..f0f1ba74f26 100644
--- a/storage/innobase/row/row0uins.cc
+++ b/storage/innobase/row/row0uins.cc
@@ -146,8 +146,9 @@ restart:
pfs_os_file_t d = OS_FILE_CLOSED;
- if (const uint32_t space_id = dict_drop_index_tree(
- &node->pcur, node->trx, &mtr)) {
+ const uint32_t space_id = dict_drop_index_tree(
+ &node->pcur, node->trx, &mtr);
+ if (space_id) {
if (table) {
lock_release_on_rollback(node->trx,
table);
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index a4b52fd2a2f..9b11b7fbc3f 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -859,6 +859,30 @@ static bool dtuple_coll_eq(const dtuple_t &tuple1, const dtuple_t &tuple2)
return true;
}
+/** Find out whether data tuple has missing data type
+for indexed virtual column.
+@param tuple data tuple
+@param index virtual index
+@return true if tuple has missing column type */
+static bool dtuple_vcol_data_missing(const dtuple_t &tuple,
+ dict_index_t *index)
+{
+ for (ulint i= 0; i < index->n_uniq; i++)
+ {
+ dict_col_t *col= index->fields[i].col;
+ if (!col->is_virtual())
+ continue;
+ dict_v_col_t *vcol= reinterpret_cast<dict_v_col_t*>(col);
+ for (ulint j= 0; j < index->table->n_v_cols; j++)
+ {
+ if (vcol == &index->table->v_cols[j]
+ && tuple.v_fields[j].type.mtype == DATA_MISSING)
+ return true;
+ }
+ }
+ return false;
+}
+
/** Finds out if a version of the record, where the version >= the current
purge_sys.view, should have ientry as its secondary index entry. We check
if there is any not delete marked version of the record where the trx
@@ -1068,6 +1092,9 @@ unsafe_to_purge:
if (dict_index_has_virtual(index)) {
if (vrow) {
+ if (dtuple_vcol_data_missing(*vrow, index)) {
+ goto nochange_index;
+ }
/* Keep the virtual row info for the next
version, unless it is changed */
mem_heap_empty(v_heap);
@@ -1078,6 +1105,7 @@ unsafe_to_purge:
if (!cur_vrow) {
/* Nothing for this index has changed,
continue */
+nochange_index:
version = prev_version;
continue;
}
diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc
index 987d3d185d9..d4761a080b0 100644
--- a/storage/innobase/srv/srv0mon.cc
+++ b/storage/innobase/srv/srv0mon.cc
@@ -647,16 +647,18 @@ static monitor_info_t innodb_counter_info[] =
{"trx_rseg_history_len", "transaction",
"Length of the TRX_RSEG_HISTORY list",
static_cast<monitor_type_t>(
- MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT | MONITOR_DEFAULT_ON),
+ MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
MONITOR_DEFAULT_START, MONITOR_RSEG_HISTORY_LEN},
{"trx_undo_slots_used", "transaction", "Number of undo slots used",
- MONITOR_NONE,
+ static_cast<monitor_type_t>(
+ MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_USED},
{"trx_undo_slots_cached", "transaction",
"Number of undo slots cached",
- MONITOR_NONE,
+ static_cast<monitor_type_t>(
+ MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT | MONITOR_DEFAULT_ON),
MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_CACHED},
{"trx_rseg_current_size", "transaction",
@@ -693,7 +695,8 @@ static monitor_info_t innodb_counter_info[] =
{"purge_dml_delay_usec", "purge",
"Microseconds DML to be delayed due to purge lagging",
- MONITOR_DISPLAY_CURRENT,
+ static_cast<monitor_type_t>(
+ MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
MONITOR_DEFAULT_START, MONITOR_DML_PURGE_DELAY},
{"purge_stop_count", "purge",
@@ -1211,6 +1214,24 @@ TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_size()
return size;
}
+/** @return number of used undo log slots */
+TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_used()
+{
+ ulint size= 0;
+ for (const auto &rseg : trx_sys.rseg_array)
+ size+= UT_LIST_GET_LEN(rseg.undo_list);
+ return size;
+}
+
+/** @return number of cached undo log slots */
+TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_cached()
+{
+ ulint size= 0;
+ for (const auto &rseg : trx_sys.rseg_array)
+ size+= UT_LIST_GET_LEN(rseg.undo_cached);
+ return size;
+}
+
/****************************************************************//**
This function consolidates some existing server counters used
by "system status variables". These existing system variables do not have
@@ -1448,7 +1469,15 @@ srv_mon_process_existing_counter(
case MONITOR_RSEG_CUR_SIZE:
value = srv_mon_get_rseg_size();
break;
-
+ case MONITOR_DML_PURGE_DELAY:
+ value = srv_max_purge_lag_delay;
+ break;
+ case MONITOR_NUM_UNDO_SLOT_USED:
+ value = srv_mon_get_rseg_used();
+ break;
+ case MONITOR_NUM_UNDO_SLOT_CACHED:
+ value = srv_mon_get_rseg_cached();
+ break;
case MONITOR_OVLD_N_FILE_OPENED:
value = fil_system.n_open;
break;
@@ -1527,7 +1556,6 @@ srv_mon_process_existing_counter(
case MONITOR_TIMEOUT:
value = lock_sys.timeouts;
break;
-
default:
ut_error;
}
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index edc19126558..a86a2337813 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -882,12 +882,13 @@ srv_export_innodb_status(void)
export_vars.innodb_data_writes = os_n_file_writes;
buf_dblwr.lock();
- ulint dblwr = buf_dblwr.submitted();
- export_vars.innodb_dblwr_pages_written = buf_dblwr.written();
+ ulint dblwr = buf_dblwr.written();
+ export_vars.innodb_dblwr_pages_written = dblwr;
export_vars.innodb_dblwr_writes = buf_dblwr.batches();
buf_dblwr.unlock();
- export_vars.innodb_data_written = srv_stats.data_written + dblwr;
+ export_vars.innodb_data_written = srv_stats.data_written
+ + (dblwr << srv_page_size_shift);
export_vars.innodb_buffer_pool_bytes_data =
buf_pool.stat.LRU_bytes
@@ -1468,27 +1469,32 @@ fewer_threads:
m_history_length= history_size;
- if (history_size &&
- trx_purge(n_use_threads,
- !(++count % srv_purge_rseg_truncate_frequency) ||
- purge_sys.truncate.current ||
- (srv_shutdown_state != SRV_SHUTDOWN_NONE &&
- srv_fast_shutdown == 0)))
+ if (!history_size)
+ srv_dml_needed_delay= 0;
+ else if (trx_purge(n_use_threads, history_size,
+ !(++count % srv_purge_rseg_truncate_frequency) ||
+ purge_sys.truncate.current ||
+ (srv_shutdown_state != SRV_SHUTDOWN_NONE &&
+ srv_fast_shutdown == 0)))
continue;
- if (m_running == sigcount)
+ if (srv_dml_needed_delay);
+ else if (m_running == sigcount)
{
/* Purge was not woken up by srv_wake_purge_thread_if_not_active() */
/* The magic number 5000 is an approximation for the case where we have
cached undo log records which prevent truncate of rollback segments. */
- wakeup= history_size &&
- (history_size >= 5000 ||
- history_size != trx_sys.history_size_approx());
+ wakeup= history_size >= 5000 ||
+ (history_size && history_size != trx_sys.history_size_approx());
break;
}
- else if (!trx_sys.history_exists())
+
+ if (!trx_sys.history_exists())
+ {
+ srv_dml_needed_delay= 0;
break;
+ }
if (!srv_purge_should_exit())
goto loop;
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 0a96a4fbaab..12643dd1768 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -188,7 +188,11 @@ static dberr_t create_log_file(bool create_new_db, lsn_t lsn)
ib_logfile0 in log_t::rename_resized(). */
delete_log_files();
- DBUG_ASSERT(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.set_capacity();
@@ -687,14 +691,12 @@ err_exit:
fil_set_max_space_id_if_bigger(space_id);
+ mysql_mutex_lock(&fil_system.mutex);
fil_space_t *space= fil_space_t::create(space_id, fsp_flags,
FIL_TYPE_TABLESPACE, nullptr,
FIL_ENCRYPTION_DEFAULT, true);
- ut_a(fil_validate());
- ut_a(space);
-
+ ut_ad(space);
fil_node_t *file= space->add(name, fh, 0, false, true);
- mysql_mutex_lock(&fil_system.mutex);
if (create)
{
@@ -838,7 +840,7 @@ dberr_t srv_undo_tablespaces_init(bool create_new_undo, mtr_t *mtr)
ut_ad(!create_new_undo || mtr);
ut_a(srv_undo_tablespaces <= TRX_SYS_N_RSEGS);
- ut_a(!create_new_undo || srv_operation == SRV_OPERATION_NORMAL);
+ ut_a(!create_new_undo || srv_operation <= SRV_OPERATION_EXPORT_RESTORED);
if (srv_undo_tablespaces == 1)
srv_undo_tablespaces= 0;
@@ -1092,7 +1094,11 @@ same_size:
log_write_up_to(flushed_lsn, false);
ut_ad(flushed_lsn == log_sys.get_lsn());
- ut_ad(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
+ ut_d(os_aio_wait_until_no_pending_writes(false));
DBUG_RETURN(flushed_lsn);
}
@@ -1108,7 +1114,11 @@ ATTRIBUTE_COLD static dberr_t srv_log_rebuild()
/* Prohibit redo log writes from any other threads until creating a
log checkpoint at the end of create_log_file(). */
ut_d(recv_no_log_write= true);
- DBUG_ASSERT(!buf_pool.any_io_pending());
+ ut_ad(!os_aio_pending_reads());
+ ut_ad(!os_aio_pending_writes());
+ ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
+ ut_ad(!buf_pool.get_oldest_modification(0));
+ ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
/* Close the redo log file, so that we can replace it */
log_sys.close_file();
@@ -1171,7 +1181,7 @@ dberr_t srv_start(bool create_new_db)
dberr_t err = DB_SUCCESS;
mtr_t mtr;
- ut_ad(srv_operation == SRV_OPERATION_NORMAL
+ ut_ad(srv_operation <= SRV_OPERATION_RESTORE_EXPORT
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT);
@@ -1507,7 +1517,8 @@ dberr_t srv_start(bool create_new_db)
bool must_upgrade_ibuf = false;
switch (srv_operation) {
- case SRV_OPERATION_NORMAL:
+ case SRV_OPERATION_NORMAL:
+ case SRV_OPERATION_EXPORT_RESTORED:
case SRV_OPERATION_RESTORE_EXPORT:
if (err != DB_SUCCESS) {
break;
@@ -1664,7 +1675,7 @@ dberr_t srv_start(bool create_new_db)
}
}
- if (srv_operation != SRV_OPERATION_NORMAL) {
+ if (srv_operation > SRV_OPERATION_EXPORT_RESTORED) {
ut_ad(srv_operation == SRV_OPERATION_RESTORE_EXPORT
|| srv_operation == SRV_OPERATION_RESTORE);
return(err);
@@ -1839,7 +1850,8 @@ skip_monitors:
return(srv_init_abort(err));
}
- if (!srv_read_only_mode && srv_operation == SRV_OPERATION_NORMAL) {
+ if (!srv_read_only_mode
+ && srv_operation <= SRV_OPERATION_EXPORT_RESTORED) {
/* Initialize the innodb_temporary tablespace and keep
it open until shutdown. */
err = srv_open_tmp_tablespace(create_new_db);
@@ -1919,7 +1931,7 @@ void innodb_preshutdown()
if (srv_read_only_mode)
return;
- if (!srv_fast_shutdown && srv_operation == SRV_OPERATION_NORMAL)
+ if (!srv_fast_shutdown && srv_operation <= SRV_OPERATION_EXPORT_RESTORED)
{
if (trx_sys.is_initialised())
while (trx_sys.any_active_transactions())
@@ -1955,6 +1967,7 @@ void innodb_shutdown()
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
break;
case SRV_OPERATION_NORMAL:
+ case SRV_OPERATION_EXPORT_RESTORED:
/* Shut down the persistent files. */
logs_empty_and_mark_files_at_shutdown();
}
diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc
index 841b014019b..f5795c9c128 100644
--- a/storage/innobase/trx/trx0purge.cc
+++ b/storage/innobase/trx/trx0purge.cc
@@ -274,13 +274,11 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
if (undo->state != TRX_UNDO_CACHED) {
/* The undo log segment will not be reused */
ut_a(undo->id < TRX_RSEG_N_SLOTS);
- compile_time_assert(FIL_NULL == 0xffffffff);
+ static_assert(FIL_NULL == 0xffffffff, "");
mtr->memset(rseg_header,
TRX_RSEG + TRX_RSEG_UNDO_SLOTS
+ undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff);
- MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
-
uint32_t hist_size = mach_read_from_4(
TRX_RSEG_HISTORY_SIZE + TRX_RSEG
+ rseg_header->page.frame);
@@ -362,7 +360,6 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr)
if (undo->state == TRX_UNDO_CACHED) {
UT_LIST_ADD_FIRST(rseg->undo_cached, undo);
- MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
} else {
ut_ad(undo->state == TRX_UNDO_TO_PURGE);
ut_free(undo);
@@ -384,161 +381,168 @@ static dberr_t trx_purge_remove_log_hdr(buf_block_t *rseg, buf_block_t* log,
uint16_t(offset + TRX_UNDO_HISTORY_NODE), mtr);
}
-MY_ATTRIBUTE((nonnull, warn_unused_result))
-/** Free an undo log segment, and remove the header from the history list.
-@param[in,out] mtr mini-transaction
-@param[in,out] rseg rollback segment
-@param[in] hdr_addr file address of log_hdr
-@return error code */
-static dberr_t
-trx_purge_free_segment(mtr_t &mtr, trx_rseg_t* rseg, fil_addr_t hdr_addr)
+/** Free an undo log segment.
+@param block rollback segment header page
+@param mtr mini-transaction */
+static void trx_purge_free_segment(buf_block_t *block, mtr_t &mtr)
{
- mtr.commit();
- log_free_check();
- mtr.start();
-
- const page_id_t hdr_page_id{rseg->space->id, hdr_addr.page};
- dberr_t err;
- buf_block_t *rseg_hdr= rseg->get(&mtr, &err);
- if (!rseg_hdr)
- return err;
- buf_block_t *block= buf_page_get_gen(hdr_page_id, 0, RW_X_LATCH,
- nullptr, BUF_GET_POSSIBLY_FREED,
- &mtr, &err);
- if (!block)
- return err;
-
- const uint32_t seg_size=
- flst_get_len(TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + block->page.frame);
-
- err= trx_purge_remove_log_hdr(rseg_hdr, block, hdr_addr.boffset, &mtr);
- if (UNIV_UNLIKELY(err != DB_SUCCESS))
- return err;
-
- ut_ad(rseg->curr_size >= seg_size);
- rseg->curr_size-= seg_size;
- rseg->history_size--;
-
- byte *hist= TRX_RSEG + TRX_RSEG_HISTORY_SIZE + rseg_hdr->page.frame;
- ut_ad(mach_read_from_4(hist) >= seg_size);
- mtr.write<4>(*rseg_hdr, hist, mach_read_from_4(hist) - seg_size);
-
while (!fseg_free_step_not_header(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER +
block->page.frame, &mtr))
{
block->fix();
+ const page_id_t id{block->page.id()};
mtr.commit();
/* NOTE: If the server is killed after the log that was produced
up to this point was written, and before the log from the mtr.commit()
in our caller is written, then the pages belonging to the
undo log will become unaccessible garbage.
- This does not matters when using multiple innodb_undo_tablespaces;
+ This does not matter when using multiple innodb_undo_tablespaces;
innodb_undo_log_truncate=ON will be able to reclaim the space. */
log_free_check();
mtr.start();
block->page.lock.x_lock();
- mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
+ if (UNIV_UNLIKELY(block->page.id() != id))
+ {
+ block->unfix();
+ block->page.lock.x_unlock();
+ block= buf_page_get_gen(id, 0, RW_X_LATCH, nullptr, BUF_GET, &mtr);
+ if (!block)
+ return;
+ }
+ else
+ mtr.memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
}
while (!fseg_free_step(TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER +
block->page.frame, &mtr));
- return DB_SUCCESS;
}
/** Remove unnecessary history data from a rollback segment.
@param[in,out] rseg rollback segment
@param[in] limit truncate anything before this
@return error code */
-static
-dberr_t
-trx_purge_truncate_rseg_history(
- trx_rseg_t& rseg,
- const purge_sys_t::iterator& limit)
+static dberr_t
+trx_purge_truncate_rseg_history(trx_rseg_t& rseg,
+ const purge_sys_t::iterator& limit)
{
- fil_addr_t hdr_addr;
- mtr_t mtr;
+ fil_addr_t hdr_addr;
+ mtr_t mtr;
- mtr.start();
+ log_free_check();
+ mtr.start();
- dberr_t err;
- buf_block_t* rseg_hdr = rseg.get(&mtr, &err);
- if (!rseg_hdr) {
- goto func_exit;
- }
+ dberr_t err;
+reget:
+ buf_block_t *rseg_hdr= rseg.get(&mtr, &err);
+ if (!rseg_hdr)
+ {
+func_exit:
+ mtr.commit();
+ return err;
+ }
- hdr_addr = flst_get_last(TRX_RSEG + TRX_RSEG_HISTORY
- + rseg_hdr->page.frame);
- hdr_addr.boffset = static_cast<uint16_t>(hdr_addr.boffset
- - TRX_UNDO_HISTORY_NODE);
+ hdr_addr= flst_get_last(TRX_RSEG + TRX_RSEG_HISTORY + rseg_hdr->page.frame);
+ hdr_addr.boffset= static_cast<uint16_t>(hdr_addr.boffset -
+ TRX_UNDO_HISTORY_NODE);
loop:
- if (hdr_addr.page == FIL_NULL) {
-func_exit:
- mtr.commit();
- return err;
- }
+ if (hdr_addr.page == FIL_NULL)
+ goto func_exit;
- buf_block_t* block = buf_page_get_gen(page_id_t(rseg.space->id,
- hdr_addr.page),
- 0, RW_X_LATCH, nullptr,
- BUF_GET_POSSIBLY_FREED,
- &mtr, &err);
- if (!block) {
- goto func_exit;
- }
+ buf_block_t *b=
+ buf_page_get_gen(page_id_t(rseg.space->id, hdr_addr.page),
+ 0, RW_X_LATCH, nullptr, BUF_GET_POSSIBLY_FREED,
+ &mtr, &err);
+ if (!b)
+ goto func_exit;
- const trx_id_t undo_trx_no = mach_read_from_8(
- block->page.frame + hdr_addr.boffset + TRX_UNDO_TRX_NO);
+ const trx_id_t undo_trx_no=
+ mach_read_from_8(b->page.frame + hdr_addr.boffset + TRX_UNDO_TRX_NO);
- if (undo_trx_no >= limit.trx_no) {
- if (undo_trx_no == limit.trx_no) {
- err = trx_undo_truncate_start(
- &rseg, hdr_addr.page,
- hdr_addr.boffset, limit.undo_no);
- }
+ if (undo_trx_no >= limit.trx_no)
+ {
+ if (undo_trx_no == limit.trx_no)
+ err = trx_undo_truncate_start(&rseg, hdr_addr.page,
+ hdr_addr.boffset, limit.undo_no);
+ goto func_exit;
+ }
- goto func_exit;
- }
+ fil_addr_t prev_hdr_addr=
+ flst_get_prev_addr(b->page.frame + hdr_addr.boffset +
+ TRX_UNDO_HISTORY_NODE);
+ prev_hdr_addr.boffset= static_cast<uint16_t>(prev_hdr_addr.boffset -
+ TRX_UNDO_HISTORY_NODE);
+ err= trx_purge_remove_log_hdr(rseg_hdr, b, hdr_addr.boffset, &mtr);
+ if (UNIV_UNLIKELY(err != DB_SUCCESS))
+ goto func_exit;
- fil_addr_t prev_hdr_addr = flst_get_prev_addr(
- block->page.frame + hdr_addr.boffset + TRX_UNDO_HISTORY_NODE);
- prev_hdr_addr.boffset = static_cast<uint16_t>(prev_hdr_addr.boffset
- - TRX_UNDO_HISTORY_NODE);
-
- if (!rseg.is_referenced()
- && rseg.needs_purge <= (purge_sys.head.trx_no
- ? purge_sys.head.trx_no
- : purge_sys.tail.trx_no)
- && mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE
- + block->page.frame)
- == TRX_UNDO_TO_PURGE
- && !mach_read_from_2(block->page.frame + hdr_addr.boffset
- + TRX_UNDO_NEXT_LOG)) {
- /* We can free the whole log segment.
- This will call trx_purge_remove_log_hdr(). */
- err = trx_purge_free_segment(mtr, &rseg, hdr_addr);
- } else {
- /* Remove the log hdr from the rseg history. */
- rseg.history_size--;
- err = trx_purge_remove_log_hdr(rseg_hdr, block,
- hdr_addr.boffset, &mtr);
- }
+ rseg_hdr->fix();
- mtr.commit();
- if (err != DB_SUCCESS) {
- return err;
- }
- mtr.start();
+ if (mach_read_from_2(b->page.frame + hdr_addr.boffset + TRX_UNDO_NEXT_LOG) ||
+ rseg.is_referenced() ||
+ rseg.needs_purge > (purge_sys.head.trx_no
+ ? purge_sys.head.trx_no
+ : purge_sys.tail.trx_no))
+ /* We cannot free the entire undo page. */;
+ else
+ {
+ const uint32_t seg_size=
+ flst_get_len(TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + b->page.frame);
+ switch (mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE +
+ b->page.frame)) {
+ case TRX_UNDO_TO_PURGE:
+ {
+ byte *hist= TRX_RSEG + TRX_RSEG_HISTORY_SIZE + rseg_hdr->page.frame;
+ ut_ad(mach_read_from_4(hist) >= seg_size);
+ mtr.write<4>(*rseg_hdr, hist, mach_read_from_4(hist) - seg_size);
+ }
+ free_segment:
+ ut_ad(rseg.curr_size >= seg_size);
+ rseg.curr_size-= seg_size;
+ trx_purge_free_segment(b, mtr);
+ break;
+ case TRX_UNDO_CACHED:
+ /* rseg.undo_cached must point to this page */
+ trx_undo_t *undo= UT_LIST_GET_FIRST(rseg.undo_cached);
+ for (; undo; undo= UT_LIST_GET_NEXT(undo_list, undo))
+ if (undo->hdr_page_no == hdr_addr.page)
+ goto found_cached;
+ ut_ad("inconsistent undo logs" == 0);
+ break;
+ found_cached:
+ UT_LIST_REMOVE(rseg.undo_cached, undo);
+ static_assert(FIL_NULL == 0xffffffff, "");
+ if (UNIV_UNLIKELY(mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT +
+ rseg_hdr->page.frame)))
+ trx_rseg_format_upgrade(rseg_hdr, &mtr);
+ mtr.memset(rseg_hdr, TRX_RSEG + TRX_RSEG_UNDO_SLOTS +
+ undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff);
+ ut_free(undo);
+ mtr.write<8,mtr_t::MAYBE_NOP>(*rseg_hdr, TRX_RSEG + TRX_RSEG_MAX_TRX_ID +
+ rseg_hdr->page.frame,
+ trx_sys.get_max_trx_id() - 1);
+ goto free_segment;
+ }
+ }
- hdr_addr = prev_hdr_addr;
+ hdr_addr= prev_hdr_addr;
- rseg_hdr = rseg.get(&mtr, &err);
- if (!rseg_hdr) {
- goto func_exit;
- }
+ mtr.commit();
+ ut_ad(rseg.history_size > 0);
+ rseg.history_size--;
+ log_free_check();
+ mtr.start();
+ rseg_hdr->page.lock.x_lock();
+ if (UNIV_UNLIKELY(rseg_hdr->page.id() != rseg.page_id()))
+ {
+ rseg_hdr->unfix();
+ rseg_hdr->page.lock.x_unlock();
+ goto reget;
+ }
+ mtr.memo_push(rseg_hdr, MTR_MEMO_PAGE_X_MODIFY);
- goto loop;
+ goto loop;
}
/** Cleanse purge queue to remove the rseg that reside in undo-tablespace
@@ -1234,43 +1238,6 @@ trx_purge_attach_undo_recs(ulint n_purge_threads)
return(n_pages_handled);
}
-/*******************************************************************//**
-Calculate the DML delay required.
-@return delay in microseconds or ULINT_MAX */
-static
-ulint
-trx_purge_dml_delay(void)
-/*=====================*/
-{
- /* Determine how much data manipulation language (DML) statements
- need to be delayed in order to reduce the lagging of the purge
- thread. */
- ulint delay = 0; /* in microseconds; default: no delay */
-
- /* If purge lag is set then calculate the new DML delay. */
-
- if (srv_max_purge_lag > 0) {
- double ratio = static_cast<double>(trx_sys.history_size()) /
- static_cast<double>(srv_max_purge_lag);
-
- if (ratio > 1.0) {
- /* If the history list length exceeds the
- srv_max_purge_lag, the data manipulation
- statements are delayed by at least 5000
- microseconds. */
- delay = (ulint) ((ratio - .5) * 10000);
- }
-
- if (delay > srv_max_purge_lag_delay) {
- delay = srv_max_purge_lag_delay;
- }
-
- MONITOR_SET(MONITOR_DML_PURGE_DELAY, delay);
- }
-
- return(delay);
-}
-
extern tpool::waitable_task purge_worker_task;
/** Wait for pending purge jobs to complete. */
@@ -1314,18 +1281,18 @@ TRANSACTIONAL_INLINE void purge_sys_t::clone_end_view()
/**
Run a purge batch.
-@param n_tasks number of purge tasks to submit to the queue
-@param truncate whether to truncate the history at the end of the batch
+@param n_tasks number of purge tasks to submit to the queue
+@param history_size trx_sys.history_size()
+@param truncate whether to truncate the history at the end of the batch
@return number of undo log pages handled in the batch */
-TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, bool truncate)
+TRANSACTIONAL_TARGET
+ulint trx_purge(ulint n_tasks, ulint history_size, bool truncate)
{
que_thr_t* thr = NULL;
ulint n_pages_handled;
ut_ad(n_tasks > 0);
- srv_dml_needed_delay = trx_purge_dml_delay();
-
purge_sys.clone_oldest_view();
#ifdef UNIV_DEBUG
@@ -1337,6 +1304,24 @@ TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, bool truncate)
/* Fetch the UNDO recs that need to be purged. */
n_pages_handled = trx_purge_attach_undo_recs(n_tasks);
+ {
+ ulint delay = n_pages_handled ? srv_max_purge_lag : 0;
+ if (UNIV_UNLIKELY(delay)) {
+ if (delay >= history_size) {
+ no_throttle:
+ delay = 0;
+ } else if (const ulint max_delay =
+ srv_max_purge_lag_delay) {
+ delay = std::min(max_delay,
+ 10000 * history_size / delay
+ - 5000);
+ } else {
+ goto no_throttle;
+ }
+ }
+ srv_dml_needed_delay = delay;
+ }
+
/* Submit tasks to workers queue if using multi-threaded purge. */
for (ulint i = n_tasks; --i; ) {
thr = que_fork_scheduler_round_robin(purge_sys.query, thr);
diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc
index e70516a2d2d..c1a7b08b717 100644
--- a/storage/innobase/trx/trx0rec.cc
+++ b/storage/innobase/trx/trx0rec.cc
@@ -1875,26 +1875,28 @@ trx_undo_report_row_operation(
}
mtr_t mtr;
+ dberr_t err;
mtr.start();
trx_undo_t** pundo;
trx_rseg_t* rseg;
const bool is_temp = index->table->is_temporary();
+ buf_block_t* undo_block;
if (is_temp) {
mtr.set_log_mode(MTR_LOG_NO_REDO);
-
rseg = trx->get_temp_rseg();
pundo = &trx->rsegs.m_noredo.undo;
+ undo_block = trx_undo_assign_low<true>(trx, rseg, pundo,
+ &mtr, &err);
} else {
ut_ad(!trx->read_only);
ut_ad(trx->id);
pundo = &trx->rsegs.m_redo.undo;
rseg = trx->rsegs.m_redo.rseg;
+ undo_block = trx_undo_assign_low<false>(trx, rseg, pundo,
+ &mtr, &err);
}
- dberr_t err;
- buf_block_t* undo_block = trx_undo_assign_low(trx, rseg, pundo,
- &err, &mtr);
trx_undo_t* undo = *pundo;
ut_ad((err == DB_SUCCESS) == (undo_block != NULL));
if (UNIV_UNLIKELY(undo_block == NULL)) {
diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc
index 1dc3c18fc09..e730530adb2 100644
--- a/storage/innobase/trx/trx0rseg.cc
+++ b/storage/innobase/trx/trx0rseg.cc
@@ -395,7 +395,6 @@ void trx_rseg_t::reinit(uint32_t page)
{
next= UT_LIST_GET_NEXT(undo_list, undo);
UT_LIST_REMOVE(undo_cached, undo);
- MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED);
ut_free(undo);
}
@@ -404,6 +403,7 @@ void trx_rseg_t::reinit(uint32_t page)
last_commit_and_offset= 0;
last_page_no= FIL_NULL;
curr_size= 1;
+ ref.store(0, std::memory_order_release);
}
/** Read the undo log lists.
@@ -428,7 +428,6 @@ static dberr_t trx_undo_lists_init(trx_rseg_t *rseg,
if (is_undo_empty)
is_undo_empty= !undo->size || undo->state == TRX_UNDO_CACHED;
rseg->curr_size+= undo->size;
- MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED);
}
}
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index e88f7824ba6..0f85aec540f 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -816,28 +816,17 @@ static void trx_assign_rseg_low(trx_t *trx)
static Atomic_counter<unsigned> rseg_slot;
unsigned slot = rseg_slot++ % TRX_SYS_N_RSEGS;
ut_d(if (trx_rseg_n_slots_debug) slot = 0);
+ ut_d(const auto start_scan_slot = slot);
+ ut_d(bool look_for_rollover = false);
trx_rseg_t* rseg;
-#ifdef UNIV_DEBUG
- ulint start_scan_slot = slot;
- bool look_for_rollover = false;
-#endif /* UNIV_DEBUG */
-
bool allocated;
do {
for (;;) {
rseg = &trx_sys.rseg_array[slot];
-
-#ifdef UNIV_DEBUG
- /* Ensure that we are not revisiting the same
- slot that we have already inspected. */
- if (look_for_rollover) {
- ut_ad(start_scan_slot != slot);
- }
- look_for_rollover = true;
-#endif /* UNIV_DEBUG */
-
+ ut_ad(!look_for_rollover || start_scan_slot != slot);
+ ut_d(look_for_rollover = true);
ut_d(if (!trx_rseg_n_slots_debug))
slot = (slot + 1) % TRX_SYS_N_RSEGS;
@@ -1038,7 +1027,13 @@ trx_write_serialisation_history(
mtr_t temp_mtr;
temp_mtr.start();
temp_mtr.set_log_mode(MTR_LOG_NO_REDO);
- trx_undo_set_state_at_finish(undo, &temp_mtr);
+ buf_block_t* block= buf_page_get(page_id_t(SRV_TMP_SPACE_ID,
+ undo->hdr_page_no),
+ 0, RW_X_LATCH, mtr);
+ ut_a(block);
+ temp_mtr.write<2>(*block, TRX_UNDO_SEG_HDR + TRX_UNDO_STATE
+ + block->page.frame, TRX_UNDO_TO_PURGE);
+ undo->state = TRX_UNDO_TO_PURGE;
temp_mtr.commit();
}
diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc
index 3b9c598e745..cbbf316fe69 100644
--- a/storage/innobase/trx/trx0undo.cc
+++ b/storage/innobase/trx/trx0undo.cc
@@ -535,8 +535,6 @@ trx_undo_seg_create(fil_space_t *space, buf_block_t *rseg_hdr, ulint *id,
+ slot_no * TRX_RSEG_SLOT_SIZE + rseg_hdr->page.frame,
block->page.id().page_no());
- MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED);
-
*err = DB_SUCCESS;
return block;
}
@@ -991,7 +989,6 @@ static void trx_undo_seg_free(const trx_undo_t *undo)
static_assert(FIL_NULL == 0xffffffff, "compatibility");
mtr.memset(rseg_header, TRX_RSEG + TRX_RSEG_UNDO_SLOTS +
undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff);
- MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_USED);
}
}
@@ -1150,7 +1147,6 @@ corrupted_type:
UT_LIST_ADD_LAST(rseg->undo_list, undo);
} else {
UT_LIST_ADD_LAST(rseg->undo_cached, undo);
- MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
}
mtr.commit();
@@ -1289,27 +1285,25 @@ trx_undo_create(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
@param[in,out] rseg rollback segment
@param[out] pundo the undo log memory object
@param[in,out] mtr mini-transaction
+@param[out] err error code
@return the undo log block
@retval NULL if none cached */
static
buf_block_t*
trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
- mtr_t* mtr)
+ mtr_t* mtr, dberr_t *err)
{
- if (rseg->is_persistent()) {
- ut_ad(rseg->is_referenced());
- if (rseg->needs_purge <= trx->id) {
- /* trx_purge_truncate_history() compares
- rseg->needs_purge <= head.trx_no
- so we need to compensate for that.
- The rseg->needs_purge after crash
- recovery would be at least trx->id + 1,
- because that is the minimum possible value
- assigned by trx_serialise() on commit. */
- rseg->needs_purge = trx->id + 1;
- }
- } else {
- ut_ad(!rseg->is_referenced());
+ ut_ad(rseg->is_persistent());
+ ut_ad(rseg->is_referenced());
+ if (rseg->needs_purge <= trx->id) {
+ /* trx_purge_truncate_history() compares
+ rseg->needs_purge <= head.trx_no
+ so we need to compensate for that.
+ The rseg->needs_purge after crash
+ recovery would be at least trx->id + 1,
+ because that is the minimum possible value
+ assigned by trx_serialise() on commit. */
+ rseg->needs_purge = trx->id + 1;
}
trx_undo_t* undo = UT_LIST_GET_FIRST(rseg->undo_cached);
@@ -1320,15 +1314,15 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
ut_ad(undo->size == 1);
ut_ad(undo->id < TRX_RSEG_N_SLOTS);
- buf_block_t* block = buf_page_get(page_id_t(undo->rseg->space->id,
- undo->hdr_page_no),
- 0, RW_X_LATCH, mtr);
+ buf_block_t* block = buf_page_get_gen(page_id_t(undo->rseg->space->id,
+ undo->hdr_page_no),
+ 0, RW_X_LATCH, nullptr, BUF_GET,
+ mtr, err);
if (!block) {
return NULL;
}
UT_LIST_REMOVE(rseg->undo_cached, undo);
- MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED);
*pundo = undo;
@@ -1374,11 +1368,12 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr)
BUF_GET, mtr, err);
}
+ *err = DB_SUCCESS;
trx_rseg_t* rseg = trx->rsegs.m_redo.rseg;
rseg->latch.wr_lock(SRW_LOCK_CALL);
buf_block_t* block = trx_undo_reuse_cached(
- trx, rseg, &trx->rsegs.m_redo.undo, mtr);
+ trx, rseg, &trx->rsegs.m_redo.undo, mtr, err);
if (!block) {
block = trx_undo_create(trx, rseg, &trx->rsegs.m_redo.undo,
@@ -1387,8 +1382,6 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr)
if (!block) {
goto func_exit;
}
- } else {
- *err = DB_SUCCESS;
}
UT_LIST_ADD_FIRST(rseg->undo_list, trx->rsegs.m_redo.undo);
@@ -1400,18 +1393,20 @@ func_exit:
/** Assign an undo log for a transaction.
A new undo log is created or a cached undo log reused.
+@tparam is_temp whether this is temporary undo log
@param[in,out] trx transaction
@param[in] rseg rollback segment
@param[out] undo the undo log
-@param[out] err error code
@param[in,out] mtr mini-transaction
+@param[out] err error code
@return the undo log block
-@retval NULL on error */
+@retval nullptr on error */
+template<bool is_temp>
buf_block_t*
-trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
- dberr_t* err, mtr_t* mtr)
+trx_undo_assign_low(trx_t *trx, trx_rseg_t *rseg, trx_undo_t **undo,
+ mtr_t *mtr, dberr_t *err)
{
- ut_d(const bool is_temp = rseg == trx->rsegs.m_noredo.rseg);
+ ut_ad(is_temp == (rseg == trx->rsegs.m_noredo.rseg));
ut_ad(is_temp || rseg == trx->rsegs.m_redo.rseg);
ut_ad(undo == (is_temp
? &trx->rsegs.m_noredo.undo
@@ -1431,19 +1426,24 @@ trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
*err = DB_TOO_MANY_CONCURRENT_TRXS; return NULL;
);
+ *err = DB_SUCCESS;
rseg->latch.wr_lock(SRW_LOCK_CALL);
- buf_block_t* block = trx_undo_reuse_cached(trx, rseg, undo, mtr);
-
- if (!block) {
- block = trx_undo_create(trx, rseg, undo, err, mtr);
- ut_ad(!block == (*err != DB_SUCCESS));
- if (!block) {
- goto func_exit;
- }
+ buf_block_t* block;
+ if (is_temp) {
+ ut_ad(!UT_LIST_GET_LEN(rseg->undo_cached));
} else {
- *err = DB_SUCCESS;
+ block = trx_undo_reuse_cached(trx, rseg, undo, mtr, err);
+ if (block) {
+ goto got_block;
+ }
+ }
+ block = trx_undo_create(trx, rseg, undo, err, mtr);
+ ut_ad(!block == (*err != DB_SUCCESS));
+ if (!block) {
+ goto func_exit;
}
+got_block:
UT_LIST_ADD_FIRST(rseg->undo_list, *undo);
func_exit:
@@ -1451,6 +1451,13 @@ func_exit:
return block;
}
+template buf_block_t*
+trx_undo_assign_low<false>(trx_t *trx, trx_rseg_t *rseg, trx_undo_t **undo,
+ mtr_t *mtr, dberr_t *err);
+template buf_block_t*
+trx_undo_assign_low<true>(trx_t *trx, trx_rseg_t *rseg, trx_undo_t **undo,
+ mtr_t *mtr, dberr_t *err);
+
/******************************************************************//**
Sets the state of the undo log segment at a transaction finish.
@return undo log segment header page, x-latched */
@@ -1461,6 +1468,7 @@ trx_undo_set_state_at_finish(
mtr_t* mtr) /*!< in: mtr */
{
ut_ad(undo->id < TRX_RSEG_N_SLOTS);
+ ut_ad(undo->rseg->is_persistent());
buf_block_t *block=
buf_page_get(page_id_t(undo->rseg->space->id, undo->hdr_page_no), 0,
@@ -1532,29 +1540,19 @@ the data can be discarded.
@param undo temporary undo log */
void trx_undo_commit_cleanup(trx_undo_t *undo)
{
- trx_rseg_t* rseg = undo->rseg;
- ut_ad(rseg->space == fil_system.temp_space);
-
- rseg->latch.wr_lock(SRW_LOCK_CALL);
-
- UT_LIST_REMOVE(rseg->undo_list, undo);
-
- if (undo->state == TRX_UNDO_CACHED) {
- UT_LIST_ADD_FIRST(rseg->undo_cached, undo);
- MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED);
- undo = nullptr;
- } else {
- ut_ad(undo->state == TRX_UNDO_TO_PURGE);
-
- /* Delete first the undo log segment in the file */
- trx_undo_seg_free(undo);
+ trx_rseg_t *rseg= undo->rseg;
+ ut_ad(rseg->space == fil_system.temp_space);
+ rseg->latch.wr_lock(SRW_LOCK_CALL);
- ut_ad(rseg->curr_size > undo->size);
- rseg->curr_size -= undo->size;
- }
+ UT_LIST_REMOVE(rseg->undo_list, undo);
+ ut_ad(undo->state == TRX_UNDO_TO_PURGE);
+ /* Delete first the undo log segment in the file */
+ trx_undo_seg_free(undo);
+ ut_ad(rseg->curr_size > undo->size);
+ rseg->curr_size-= undo->size;
- rseg->latch.wr_unlock();
- ut_free(undo);
+ rseg->latch.wr_unlock();
+ ut_free(undo);
}
/** At shutdown, frees the undo logs of a transaction. */
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index f82823dba2b..2f58110cb91 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -188,7 +188,7 @@ static MYSQL_SYSVAR_BOOL(page_checksum, maria_page_checksums, 0,
/* It is only command line argument */
static MYSQL_SYSVAR_CONST_STR(log_dir_path, maria_data_root,
- PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to the directory where to store transactional log",
NULL, NULL, mysql_real_data_home);
@@ -1082,7 +1082,8 @@ const char *ha_maria::index_type(uint key_number)
ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const
{
ulong flags;
- if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT)
+ if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT ||
+ table_share->key_info[inx].algorithm == HA_KEY_ALG_UNIQUE_HASH)
flags= 0;
else
if ((table_share->key_info[inx].flags & HA_SPATIAL ||
diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc
index ee5d44b5d26..8d03320ea58 100644
--- a/storage/myisammrg/ha_myisammrg.cc
+++ b/storage/myisammrg/ha_myisammrg.cc
@@ -343,7 +343,7 @@ IO_AND_CPU_COST ha_myisammrg::rnd_pos_time(ha_rows rows)
{
IO_AND_CPU_COST cost= handler::rnd_pos_time(rows);
/*
- Row data is notcached. costs.row_lookup_cost includes the cost of
+ Row data is not cached. costs.row_lookup_cost includes the cost of
the reading the row from system (probably cached by the OS).
*/
cost.io= 0;
@@ -1300,26 +1300,17 @@ int ha_myisammrg::info(uint flag)
table->s->keys_in_use.set_prefix(table->s->keys);
stats.mean_rec_length= mrg_info.reclength;
- /*
+ /*
The handler::block_size is used all over the code in index scan cost
calculations. It is used to get number of disk seeks required to
retrieve a number of index tuples.
- If the merge table has N underlying tables, then (assuming underlying
- tables have equal size, the only "simple" approach we can use)
- retrieving X index records from a merge table will require N times more
- disk seeks compared to doing the same on a MyISAM table with equal
- number of records.
- In the edge case (file_tables > myisam_block_size) we'll get
- block_size==0, and index calculation code will act as if we need one
- disk seek to retrieve one index tuple.
-
- TODO: In 5.2 index scan cost calculation will be factored out into a
- virtual function in class handler and we'll be able to remove this hack.
+ If the merge table has N underlying tables, there will be
+ N more disk seeks compared to a scanning a normal MyISAM table.
+ The number of bytes read is the rougly the same for a normal MyISAM
+ and a MyISAM merge tables.
*/
- stats.block_size= 0;
- if (file->tables)
- stats.block_size= myisam_block_size / file->tables;
-
+ stats.block_size= myisam_block_size;
+
stats.update_time= 0;
#if SIZEOF_OFF_T > 4
ref_length=6; // Should be big enough
diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt
index 56ea79755a3..b4f5e96b607 100644
--- a/storage/perfschema/CMakeLists.txt
+++ b/storage/perfschema/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2022, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2023, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_account.cc b/storage/perfschema/cursor_by_account.cc
index 25e3ed662d1..2fa224d3526 100644
--- a/storage/perfschema/cursor_by_account.cc
+++ b/storage/perfschema/cursor_by_account.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_account.h b/storage/perfschema/cursor_by_account.h
index 59adf2e0fc8..44175ceb3a2 100644
--- a/storage/perfschema/cursor_by_account.h
+++ b/storage/perfschema/cursor_by_account.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_host.cc b/storage/perfschema/cursor_by_host.cc
index 956644cfce2..aa22e8c0431 100644
--- a/storage/perfschema/cursor_by_host.cc
+++ b/storage/perfschema/cursor_by_host.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_host.h b/storage/perfschema/cursor_by_host.h
index a2ddae4b644..c8a83a47ec6 100644
--- a/storage/perfschema/cursor_by_host.h
+++ b/storage/perfschema/cursor_by_host.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_thread.cc b/storage/perfschema/cursor_by_thread.cc
index ff90c77e47d..307cb32943a 100644
--- a/storage/perfschema/cursor_by_thread.cc
+++ b/storage/perfschema/cursor_by_thread.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_thread.h b/storage/perfschema/cursor_by_thread.h
index 89d97997a41..50e162294cf 100644
--- a/storage/perfschema/cursor_by_thread.h
+++ b/storage/perfschema/cursor_by_thread.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_thread_connect_attr.cc b/storage/perfschema/cursor_by_thread_connect_attr.cc
index 877056074f6..1db97f72b16 100644
--- a/storage/perfschema/cursor_by_thread_connect_attr.cc
+++ b/storage/perfschema/cursor_by_thread_connect_attr.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_thread_connect_attr.h b/storage/perfschema/cursor_by_thread_connect_attr.h
index 3c273708e39..4f48b40c870 100644
--- a/storage/perfschema/cursor_by_thread_connect_attr.h
+++ b/storage/perfschema/cursor_by_thread_connect_attr.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_user.cc b/storage/perfschema/cursor_by_user.cc
index 9778e240b8c..f1c9969f783 100644
--- a/storage/perfschema/cursor_by_user.cc
+++ b/storage/perfschema/cursor_by_user.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/cursor_by_user.h b/storage/perfschema/cursor_by_user.h
index f5b6800d9b1..6438515cf1e 100644
--- a/storage/perfschema/cursor_by_user.h
+++ b/storage/perfschema/cursor_by_user.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc
index 57aa40c7e86..c6d2f23d653 100644
--- a/storage/perfschema/ha_perfschema.cc
+++ b/storage/perfschema/ha_perfschema.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/ha_perfschema.h b/storage/perfschema/ha_perfschema.h
index 20ed7448a1e..f1929d2334b 100644
--- a/storage/perfschema/ha_perfschema.h
+++ b/storage/perfschema/ha_perfschema.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc
index 244b11a30fc..8b3a159f7a2 100644
--- a/storage/perfschema/pfs.cc
+++ b/storage/perfschema/pfs.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
@@ -3068,7 +3068,8 @@ pfs_start_table_io_wait_v1(PSI_table_locker_state *state,
PFS_table_share *share= pfs_table->m_share;
wait->m_thread_internal_id= pfs_thread->m_thread_internal_id;
- wait->m_class= &global_table_io_class;
+ if (wait->m_class == NULL || wait->m_class->m_type != PFS_CLASS_TABLE_LOCK)
+ wait->m_class= &global_table_io_class;
wait->m_timer_start= timer_start;
wait->m_timer_end= 0;
wait->m_object_instance_addr= pfs_table->m_identity;
diff --git a/storage/perfschema/pfs.h b/storage/perfschema/pfs.h
index 94d349a5fd2..6e0cf258c91 100644
--- a/storage/perfschema/pfs.h
+++ b/storage/perfschema/pfs.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_account.cc b/storage/perfschema/pfs_account.cc
index 53a45bcfd9b..ecf26cd77ea 100644
--- a/storage/perfschema/pfs_account.cc
+++ b/storage/perfschema/pfs_account.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_account.h b/storage/perfschema/pfs_account.h
index 196f3595082..0aa36204e12 100644
--- a/storage/perfschema/pfs_account.h
+++ b/storage/perfschema/pfs_account.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_atomic.h b/storage/perfschema/pfs_atomic.h
index 54c4cba163c..8543cdabc88 100644
--- a/storage/perfschema/pfs_atomic.h
+++ b/storage/perfschema/pfs_atomic.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2009, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_autosize.cc b/storage/perfschema/pfs_autosize.cc
index d418ea594e2..36087d0cd3c 100644
--- a/storage/perfschema/pfs_autosize.cc
+++ b/storage/perfschema/pfs_autosize.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_buffer_container.cc b/storage/perfschema/pfs_buffer_container.cc
index dfae6e0ad2e..04f6f5219a3 100644
--- a/storage/perfschema/pfs_buffer_container.cc
+++ b/storage/perfschema/pfs_buffer_container.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_buffer_container.h b/storage/perfschema/pfs_buffer_container.h
index 0f856ceee86..d5745e76249 100644
--- a/storage/perfschema/pfs_buffer_container.h
+++ b/storage/perfschema/pfs_buffer_container.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_builtin_memory.cc b/storage/perfschema/pfs_builtin_memory.cc
index 60e97451852..c8b9e62f528 100644
--- a/storage/perfschema/pfs_builtin_memory.cc
+++ b/storage/perfschema/pfs_builtin_memory.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_builtin_memory.h b/storage/perfschema/pfs_builtin_memory.h
index c0f0aa86c45..956b31c5dcf 100644
--- a/storage/perfschema/pfs_builtin_memory.h
+++ b/storage/perfschema/pfs_builtin_memory.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_column_types.h b/storage/perfschema/pfs_column_types.h
index 1985c6ea719..862916fa4fc 100644
--- a/storage/perfschema/pfs_column_types.h
+++ b/storage/perfschema/pfs_column_types.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_column_values.cc b/storage/perfschema/pfs_column_values.cc
index fe3d16df21c..88da190ba3d 100644
--- a/storage/perfschema/pfs_column_values.cc
+++ b/storage/perfschema/pfs_column_values.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_column_values.h b/storage/perfschema/pfs_column_values.h
index e3f36512ef5..75fd7b1de8d 100644
--- a/storage/perfschema/pfs_column_values.h
+++ b/storage/perfschema/pfs_column_values.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_con_slice.cc b/storage/perfschema/pfs_con_slice.cc
index 9a3e2a60929..4c99a32f429 100644
--- a/storage/perfschema/pfs_con_slice.cc
+++ b/storage/perfschema/pfs_con_slice.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_con_slice.h b/storage/perfschema/pfs_con_slice.h
index d71e9f5a90a..f0a89c8fcd0 100644
--- a/storage/perfschema/pfs_con_slice.h
+++ b/storage/perfschema/pfs_con_slice.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_defaults.cc b/storage/perfschema/pfs_defaults.cc
index d5c415a5f77..23599c9ed87 100644
--- a/storage/perfschema/pfs_defaults.cc
+++ b/storage/perfschema/pfs_defaults.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_defaults.h b/storage/perfschema/pfs_defaults.h
index 0225010f8b3..23e8755f265 100644
--- a/storage/perfschema/pfs_defaults.h
+++ b/storage/perfschema/pfs_defaults.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_digest.cc b/storage/perfschema/pfs_digest.cc
index 0cb1b023a3e..fd5fdc5f8ff 100644
--- a/storage/perfschema/pfs_digest.cc
+++ b/storage/perfschema/pfs_digest.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_digest.h b/storage/perfschema/pfs_digest.h
index 6611cfbfd76..bec2c28ef59 100644
--- a/storage/perfschema/pfs_digest.h
+++ b/storage/perfschema/pfs_digest.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc
index 6a9351b9d91..76095b5311b 100644
--- a/storage/perfschema/pfs_engine_table.cc
+++ b/storage/perfschema/pfs_engine_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_engine_table.h b/storage/perfschema/pfs_engine_table.h
index 1f31c4fcdf6..02ef9b07010 100644
--- a/storage/perfschema/pfs_engine_table.h
+++ b/storage/perfschema/pfs_engine_table.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events.h b/storage/perfschema/pfs_events.h
index 41175596cf6..0f5022fee9c 100644
--- a/storage/perfschema/pfs_events.h
+++ b/storage/perfschema/pfs_events.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_stages.cc b/storage/perfschema/pfs_events_stages.cc
index 2e3ad4af786..aa1bdf4f7a0 100644
--- a/storage/perfschema/pfs_events_stages.cc
+++ b/storage/perfschema/pfs_events_stages.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_stages.h b/storage/perfschema/pfs_events_stages.h
index ff85f568c0f..f0b669cf846 100644
--- a/storage/perfschema/pfs_events_stages.h
+++ b/storage/perfschema/pfs_events_stages.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_events_statements.cc b/storage/perfschema/pfs_events_statements.cc
index c0f1809a2f3..05bdc83fc5c 100644
--- a/storage/perfschema/pfs_events_statements.cc
+++ b/storage/perfschema/pfs_events_statements.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_transactions.cc b/storage/perfschema/pfs_events_transactions.cc
index 6f6b1a4cbc6..5ccdb0345d7 100644
--- a/storage/perfschema/pfs_events_transactions.cc
+++ b/storage/perfschema/pfs_events_transactions.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_transactions.h b/storage/perfschema/pfs_events_transactions.h
index 46d42b1e121..b649f7f820a 100644
--- a/storage/perfschema/pfs_events_transactions.h
+++ b/storage/perfschema/pfs_events_transactions.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_waits.cc b/storage/perfschema/pfs_events_waits.cc
index 0462c2cf9ef..3ec6a671913 100644
--- a/storage/perfschema/pfs_events_waits.cc
+++ b/storage/perfschema/pfs_events_waits.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_events_waits.h b/storage/perfschema/pfs_events_waits.h
index 034d0f5c740..93dcb136834 100644
--- a/storage/perfschema/pfs_events_waits.h
+++ b/storage/perfschema/pfs_events_waits.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates..
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates..
Copyright (c) 2017, 2012, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_global.cc b/storage/perfschema/pfs_global.cc
index ccb43369907..8860be797be 100644
--- a/storage/perfschema/pfs_global.cc
+++ b/storage/perfschema/pfs_global.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights
reserved.
Copyright (c) 2022, MariaDB Corporation.
diff --git a/storage/perfschema/pfs_global.h b/storage/perfschema/pfs_global.h
index 243d67bbb86..6b73fd9f8a5 100644
--- a/storage/perfschema/pfs_global.h
+++ b/storage/perfschema/pfs_global.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_host.cc b/storage/perfschema/pfs_host.cc
index ca049054133..d54725fe9a8 100644
--- a/storage/perfschema/pfs_host.cc
+++ b/storage/perfschema/pfs_host.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_host.h b/storage/perfschema/pfs_host.h
index d05c37bfd01..56bcccb94ac 100644
--- a/storage/perfschema/pfs_host.h
+++ b/storage/perfschema/pfs_host.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc
index 0a7c8f8ffc9..f08d1a25174 100644
--- a/storage/perfschema/pfs_instr.cc
+++ b/storage/perfschema/pfs_instr.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_instr.h b/storage/perfschema/pfs_instr.h
index b9f31e63636..868f772267c 100644
--- a/storage/perfschema/pfs_instr.h
+++ b/storage/perfschema/pfs_instr.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_instr_class.cc b/storage/perfschema/pfs_instr_class.cc
index 2a6be8be6d4..2b1a80d3e11 100644
--- a/storage/perfschema/pfs_instr_class.cc
+++ b/storage/perfschema/pfs_instr_class.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_instr_class.h b/storage/perfschema/pfs_instr_class.h
index c3f83c45b7e..f353c410d4c 100644
--- a/storage/perfschema/pfs_instr_class.h
+++ b/storage/perfschema/pfs_instr_class.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_lock.h b/storage/perfschema/pfs_lock.h
index ae90ebd0784..0f4bcb6de8f 100644
--- a/storage/perfschema/pfs_lock.h
+++ b/storage/perfschema/pfs_lock.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2009, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_memory.cc b/storage/perfschema/pfs_memory.cc
index 4b4b14fc186..0ee8e3dd7df 100644
--- a/storage/perfschema/pfs_memory.cc
+++ b/storage/perfschema/pfs_memory.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_memory.h b/storage/perfschema/pfs_memory.h
index 085f8af8bad..ee90b7d90e9 100644
--- a/storage/perfschema/pfs_memory.h
+++ b/storage/perfschema/pfs_memory.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_prepared_stmt.cc b/storage/perfschema/pfs_prepared_stmt.cc
index e0e10553680..50e4e27bb1e 100644
--- a/storage/perfschema/pfs_prepared_stmt.cc
+++ b/storage/perfschema/pfs_prepared_stmt.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_prepared_stmt.h b/storage/perfschema/pfs_prepared_stmt.h
index d89ad80cbd8..1a06122382c 100644
--- a/storage/perfschema/pfs_prepared_stmt.h
+++ b/storage/perfschema/pfs_prepared_stmt.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_program.cc b/storage/perfschema/pfs_program.cc
index 9bd9f06b22c..de456610519 100644
--- a/storage/perfschema/pfs_program.cc
+++ b/storage/perfschema/pfs_program.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_program.h b/storage/perfschema/pfs_program.h
index 56abcee97f7..a5a6245c1cc 100644
--- a/storage/perfschema/pfs_program.h
+++ b/storage/perfschema/pfs_program.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_server.cc b/storage/perfschema/pfs_server.cc
index f5b1bf9c03f..258c2153d24 100644
--- a/storage/perfschema/pfs_server.cc
+++ b/storage/perfschema/pfs_server.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_server.h b/storage/perfschema/pfs_server.h
index d87d48ac19b..7c22812fca8 100644
--- a/storage/perfschema/pfs_server.h
+++ b/storage/perfschema/pfs_server.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_setup_actor.cc b/storage/perfschema/pfs_setup_actor.cc
index ca45547d6ee..efe19b3c8b3 100644
--- a/storage/perfschema/pfs_setup_actor.cc
+++ b/storage/perfschema/pfs_setup_actor.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_setup_actor.h b/storage/perfschema/pfs_setup_actor.h
index ede8f6c4b4e..8e401dcd42a 100644
--- a/storage/perfschema/pfs_setup_actor.h
+++ b/storage/perfschema/pfs_setup_actor.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_setup_object.cc b/storage/perfschema/pfs_setup_object.cc
index 64a54e9369a..78617d1b2c6 100644
--- a/storage/perfschema/pfs_setup_object.cc
+++ b/storage/perfschema/pfs_setup_object.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_setup_object.h b/storage/perfschema/pfs_setup_object.h
index 259c3dc8340..e934e01eccc 100644
--- a/storage/perfschema/pfs_setup_object.h
+++ b/storage/perfschema/pfs_setup_object.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_stat.h b/storage/perfschema/pfs_stat.h
index 1349b7ba4df..af0be085431 100644
--- a/storage/perfschema/pfs_stat.h
+++ b/storage/perfschema/pfs_stat.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_status.cc b/storage/perfschema/pfs_status.cc
index 62aed2e8de9..2596c53c4ad 100644
--- a/storage/perfschema/pfs_status.cc
+++ b/storage/perfschema/pfs_status.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_status.h b/storage/perfschema/pfs_status.h
index a415fcc4704..42329ffb492 100644
--- a/storage/perfschema/pfs_status.h
+++ b/storage/perfschema/pfs_status.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_timer.cc b/storage/perfschema/pfs_timer.cc
index 36cd0df141d..15e1a188bb0 100644
--- a/storage/perfschema/pfs_timer.cc
+++ b/storage/perfschema/pfs_timer.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_timer.h b/storage/perfschema/pfs_timer.h
index 6218bc603d8..e5393a4a8a4 100644
--- a/storage/perfschema/pfs_timer.h
+++ b/storage/perfschema/pfs_timer.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_user.cc b/storage/perfschema/pfs_user.cc
index bd5fc3eadce..1f299d9b9b6 100644
--- a/storage/perfschema/pfs_user.cc
+++ b/storage/perfschema/pfs_user.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_user.h b/storage/perfschema/pfs_user.h
index acffaf9a724..e15e733e5ac 100644
--- a/storage/perfschema/pfs_user.h
+++ b/storage/perfschema/pfs_user.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_variable.cc b/storage/perfschema/pfs_variable.cc
index 982409baf82..239c55b623c 100644
--- a/storage/perfschema/pfs_variable.cc
+++ b/storage/perfschema/pfs_variable.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/pfs_variable.h b/storage/perfschema/pfs_variable.h
index 948baf4e3b8..d3ad4c7f900 100644
--- a/storage/perfschema/pfs_variable.h
+++ b/storage/perfschema/pfs_variable.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_visitor.cc b/storage/perfschema/pfs_visitor.cc
index 17ef39448f9..92a5c99e13b 100644
--- a/storage/perfschema/pfs_visitor.cc
+++ b/storage/perfschema/pfs_visitor.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/pfs_visitor.h b/storage/perfschema/pfs_visitor.h
index c5e5f826b7c..03684ba9ca6 100644
--- a/storage/perfschema/pfs_visitor.h
+++ b/storage/perfschema/pfs_visitor.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_accounts.cc b/storage/perfschema/table_accounts.cc
index fcf636b8e3e..654a4400eef 100644
--- a/storage/perfschema/table_accounts.cc
+++ b/storage/perfschema/table_accounts.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_accounts.h b/storage/perfschema/table_accounts.h
index 239f278051d..28348190e69 100644
--- a/storage/perfschema/table_accounts.h
+++ b/storage/perfschema/table_accounts.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_all_instr.cc b/storage/perfschema/table_all_instr.cc
index c4d05cf13f0..1ca0525acd7 100644
--- a/storage/perfschema/table_all_instr.cc
+++ b/storage/perfschema/table_all_instr.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_all_instr.h b/storage/perfschema/table_all_instr.h
index 6895b0b2c47..d7f3fe6aa1a 100644
--- a/storage/perfschema/table_all_instr.h
+++ b/storage/perfschema/table_all_instr.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_account_by_event_name.cc b/storage/perfschema/table_esgs_by_account_by_event_name.cc
index cfc325f352e..42d3592ad10 100644
--- a/storage/perfschema/table_esgs_by_account_by_event_name.cc
+++ b/storage/perfschema/table_esgs_by_account_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_account_by_event_name.h b/storage/perfschema/table_esgs_by_account_by_event_name.h
index 98bf82e2b96..fa0c7d8ec2d 100644
--- a/storage/perfschema/table_esgs_by_account_by_event_name.h
+++ b/storage/perfschema/table_esgs_by_account_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_host_by_event_name.cc b/storage/perfschema/table_esgs_by_host_by_event_name.cc
index 2a3e72353b6..e5982164824 100644
--- a/storage/perfschema/table_esgs_by_host_by_event_name.cc
+++ b/storage/perfschema/table_esgs_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_host_by_event_name.h b/storage/perfschema/table_esgs_by_host_by_event_name.h
index 64349ecc7d9..f71a479c8fa 100644
--- a/storage/perfschema/table_esgs_by_host_by_event_name.h
+++ b/storage/perfschema/table_esgs_by_host_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_thread_by_event_name.cc b/storage/perfschema/table_esgs_by_thread_by_event_name.cc
index 69111680704..c393eae902e 100644
--- a/storage/perfschema/table_esgs_by_thread_by_event_name.cc
+++ b/storage/perfschema/table_esgs_by_thread_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_thread_by_event_name.h b/storage/perfschema/table_esgs_by_thread_by_event_name.h
index 4f32d76e256..f9a52ebe189 100644
--- a/storage/perfschema/table_esgs_by_thread_by_event_name.h
+++ b/storage/perfschema/table_esgs_by_thread_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_user_by_event_name.cc b/storage/perfschema/table_esgs_by_user_by_event_name.cc
index d8b6af382a3..fee2efe3786 100644
--- a/storage/perfschema/table_esgs_by_user_by_event_name.cc
+++ b/storage/perfschema/table_esgs_by_user_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_by_user_by_event_name.h b/storage/perfschema/table_esgs_by_user_by_event_name.h
index 3a211d19ad4..e8b421089c8 100644
--- a/storage/perfschema/table_esgs_by_user_by_event_name.h
+++ b/storage/perfschema/table_esgs_by_user_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_global_by_event_name.cc b/storage/perfschema/table_esgs_global_by_event_name.cc
index 288891861c9..37d134db1dc 100644
--- a/storage/perfschema/table_esgs_global_by_event_name.cc
+++ b/storage/perfschema/table_esgs_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esgs_global_by_event_name.h b/storage/perfschema/table_esgs_global_by_event_name.h
index 013e04308eb..bfcd70174ec 100644
--- a/storage/perfschema/table_esgs_global_by_event_name.h
+++ b/storage/perfschema/table_esgs_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_account_by_event_name.cc b/storage/perfschema/table_esms_by_account_by_event_name.cc
index a1805170332..cb27e9dbfc0 100644
--- a/storage/perfschema/table_esms_by_account_by_event_name.cc
+++ b/storage/perfschema/table_esms_by_account_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_account_by_event_name.h b/storage/perfschema/table_esms_by_account_by_event_name.h
index 3ea7620204b..638cc28ed7b 100644
--- a/storage/perfschema/table_esms_by_account_by_event_name.h
+++ b/storage/perfschema/table_esms_by_account_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_digest.cc b/storage/perfschema/table_esms_by_digest.cc
index 6a3f2bf3c3c..0dccaf1aca5 100644
--- a/storage/perfschema/table_esms_by_digest.cc
+++ b/storage/perfschema/table_esms_by_digest.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_digest.h b/storage/perfschema/table_esms_by_digest.h
index d231d3388f8..4711ffc56bf 100644
--- a/storage/perfschema/table_esms_by_digest.h
+++ b/storage/perfschema/table_esms_by_digest.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_host_by_event_name.cc b/storage/perfschema/table_esms_by_host_by_event_name.cc
index 3e7355fef80..bd7a9f575c0 100644
--- a/storage/perfschema/table_esms_by_host_by_event_name.cc
+++ b/storage/perfschema/table_esms_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_host_by_event_name.h b/storage/perfschema/table_esms_by_host_by_event_name.h
index 7c8c0e777e8..65a7256b9cb 100644
--- a/storage/perfschema/table_esms_by_host_by_event_name.h
+++ b/storage/perfschema/table_esms_by_host_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_program.cc b/storage/perfschema/table_esms_by_program.cc
index ab3e1a440b8..e898d8abe1c 100644
--- a/storage/perfschema/table_esms_by_program.cc
+++ b/storage/perfschema/table_esms_by_program.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_program.h b/storage/perfschema/table_esms_by_program.h
index a9aa47c2300..f9e686efc6f 100644
--- a/storage/perfschema/table_esms_by_program.h
+++ b/storage/perfschema/table_esms_by_program.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_thread_by_event_name.cc b/storage/perfschema/table_esms_by_thread_by_event_name.cc
index ad22fa3c63f..08d244362a1 100644
--- a/storage/perfschema/table_esms_by_thread_by_event_name.cc
+++ b/storage/perfschema/table_esms_by_thread_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_thread_by_event_name.h b/storage/perfschema/table_esms_by_thread_by_event_name.h
index e4b1ba63eb8..87a4e3c3ed4 100644
--- a/storage/perfschema/table_esms_by_thread_by_event_name.h
+++ b/storage/perfschema/table_esms_by_thread_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_user_by_event_name.cc b/storage/perfschema/table_esms_by_user_by_event_name.cc
index 82479d329b3..4be0f09fccf 100644
--- a/storage/perfschema/table_esms_by_user_by_event_name.cc
+++ b/storage/perfschema/table_esms_by_user_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_by_user_by_event_name.h b/storage/perfschema/table_esms_by_user_by_event_name.h
index 18516dfdb48..cbd388ef606 100644
--- a/storage/perfschema/table_esms_by_user_by_event_name.h
+++ b/storage/perfschema/table_esms_by_user_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_global_by_event_name.cc b/storage/perfschema/table_esms_global_by_event_name.cc
index cde0ef5deee..0fe61e2cc8e 100644
--- a/storage/perfschema/table_esms_global_by_event_name.cc
+++ b/storage/perfschema/table_esms_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_esms_global_by_event_name.h b/storage/perfschema/table_esms_global_by_event_name.h
index 67dd631c71c..21a6b1a18b9 100644
--- a/storage/perfschema/table_esms_global_by_event_name.h
+++ b/storage/perfschema/table_esms_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_account_by_event_name.cc b/storage/perfschema/table_ets_by_account_by_event_name.cc
index 95746b57e5a..f2eef2efb6e 100644
--- a/storage/perfschema/table_ets_by_account_by_event_name.cc
+++ b/storage/perfschema/table_ets_by_account_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_account_by_event_name.h b/storage/perfschema/table_ets_by_account_by_event_name.h
index e227db2e08e..a5202b299e0 100644
--- a/storage/perfschema/table_ets_by_account_by_event_name.h
+++ b/storage/perfschema/table_ets_by_account_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_host_by_event_name.cc b/storage/perfschema/table_ets_by_host_by_event_name.cc
index 5b89e9cbfd2..cbdddbaa330 100644
--- a/storage/perfschema/table_ets_by_host_by_event_name.cc
+++ b/storage/perfschema/table_ets_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_host_by_event_name.h b/storage/perfschema/table_ets_by_host_by_event_name.h
index add2d1a32a6..00b4dbd02f8 100644
--- a/storage/perfschema/table_ets_by_host_by_event_name.h
+++ b/storage/perfschema/table_ets_by_host_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_thread_by_event_name.cc b/storage/perfschema/table_ets_by_thread_by_event_name.cc
index 1dc876bd293..aff08f7f9b2 100644
--- a/storage/perfschema/table_ets_by_thread_by_event_name.cc
+++ b/storage/perfschema/table_ets_by_thread_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_thread_by_event_name.h b/storage/perfschema/table_ets_by_thread_by_event_name.h
index a69e19653ee..1fa62f84e51 100644
--- a/storage/perfschema/table_ets_by_thread_by_event_name.h
+++ b/storage/perfschema/table_ets_by_thread_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_user_by_event_name.cc b/storage/perfschema/table_ets_by_user_by_event_name.cc
index 3883e8c7e69..6aff6838f8c 100644
--- a/storage/perfschema/table_ets_by_user_by_event_name.cc
+++ b/storage/perfschema/table_ets_by_user_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_by_user_by_event_name.h b/storage/perfschema/table_ets_by_user_by_event_name.h
index fc18a3e94e6..9bd5b859ef9 100644
--- a/storage/perfschema/table_ets_by_user_by_event_name.h
+++ b/storage/perfschema/table_ets_by_user_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_global_by_event_name.cc b/storage/perfschema/table_ets_global_by_event_name.cc
index 209ecf47aac..b44d11511c2 100644
--- a/storage/perfschema/table_ets_global_by_event_name.cc
+++ b/storage/perfschema/table_ets_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ets_global_by_event_name.h b/storage/perfschema/table_ets_global_by_event_name.h
index a2136a23210..d5a67f43505 100644
--- a/storage/perfschema/table_ets_global_by_event_name.h
+++ b/storage/perfschema/table_ets_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_stages.cc b/storage/perfschema/table_events_stages.cc
index e2689ad0ad9..7b9b59a19f9 100644
--- a/storage/perfschema/table_events_stages.cc
+++ b/storage/perfschema/table_events_stages.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_stages.h b/storage/perfschema/table_events_stages.h
index b4941db54eb..d8b973acc8b 100644
--- a/storage/perfschema/table_events_stages.h
+++ b/storage/perfschema/table_events_stages.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_statements.cc b/storage/perfschema/table_events_statements.cc
index 4b27db19ca2..7801dab5086 100644
--- a/storage/perfschema/table_events_statements.cc
+++ b/storage/perfschema/table_events_statements.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_statements.h b/storage/perfschema/table_events_statements.h
index ca8bc804b01..6acad7bb90d 100644
--- a/storage/perfschema/table_events_statements.h
+++ b/storage/perfschema/table_events_statements.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_transactions.cc b/storage/perfschema/table_events_transactions.cc
index e9fe172d8cf..0dea61cbd47 100644
--- a/storage/perfschema/table_events_transactions.cc
+++ b/storage/perfschema/table_events_transactions.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_transactions.h b/storage/perfschema/table_events_transactions.h
index 940546093c8..f6024c63766 100644
--- a/storage/perfschema/table_events_transactions.h
+++ b/storage/perfschema/table_events_transactions.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_waits.cc b/storage/perfschema/table_events_waits.cc
index e0052b8f656..59b99dabc0f 100644
--- a/storage/perfschema/table_events_waits.cc
+++ b/storage/perfschema/table_events_waits.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_waits.h b/storage/perfschema/table_events_waits.h
index dcd0ea6231b..62df9ae2521 100644
--- a/storage/perfschema/table_events_waits.h
+++ b/storage/perfschema/table_events_waits.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_waits_summary.cc b/storage/perfschema/table_events_waits_summary.cc
index 3ee14e9a3e8..c848ebf4418 100644
--- a/storage/perfschema/table_events_waits_summary.cc
+++ b/storage/perfschema/table_events_waits_summary.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_events_waits_summary.h b/storage/perfschema/table_events_waits_summary.h
index a2b45c41fae..d84a79effc1 100644
--- a/storage/perfschema/table_events_waits_summary.h
+++ b/storage/perfschema/table_events_waits_summary.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_account_by_event_name.cc b/storage/perfschema/table_ews_by_account_by_event_name.cc
index 661fff768a8..bec37022517 100644
--- a/storage/perfschema/table_ews_by_account_by_event_name.cc
+++ b/storage/perfschema/table_ews_by_account_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_account_by_event_name.h b/storage/perfschema/table_ews_by_account_by_event_name.h
index b50704e788b..df72f25809b 100644
--- a/storage/perfschema/table_ews_by_account_by_event_name.h
+++ b/storage/perfschema/table_ews_by_account_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_host_by_event_name.cc b/storage/perfschema/table_ews_by_host_by_event_name.cc
index 6fb54deb4b2..d6b702e04a7 100644
--- a/storage/perfschema/table_ews_by_host_by_event_name.cc
+++ b/storage/perfschema/table_ews_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_host_by_event_name.h b/storage/perfschema/table_ews_by_host_by_event_name.h
index 0a554385511..c88b3d77a3f 100644
--- a/storage/perfschema/table_ews_by_host_by_event_name.h
+++ b/storage/perfschema/table_ews_by_host_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_thread_by_event_name.cc b/storage/perfschema/table_ews_by_thread_by_event_name.cc
index 35d82378717..7d84bda74e3 100644
--- a/storage/perfschema/table_ews_by_thread_by_event_name.cc
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_thread_by_event_name.h b/storage/perfschema/table_ews_by_thread_by_event_name.h
index 9c526182bc8..7ac6638a1cd 100644
--- a/storage/perfschema/table_ews_by_thread_by_event_name.h
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_user_by_event_name.cc b/storage/perfschema/table_ews_by_user_by_event_name.cc
index 62ea8aaa7be..e299ed04360 100644
--- a/storage/perfschema/table_ews_by_user_by_event_name.cc
+++ b/storage/perfschema/table_ews_by_user_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_by_user_by_event_name.h b/storage/perfschema/table_ews_by_user_by_event_name.h
index 3a61c8bcd54..82c7319c19a 100644
--- a/storage/perfschema/table_ews_by_user_by_event_name.h
+++ b/storage/perfschema/table_ews_by_user_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_global_by_event_name.cc b/storage/perfschema/table_ews_global_by_event_name.cc
index 777112da092..c5d134c98e8 100644
--- a/storage/perfschema/table_ews_global_by_event_name.cc
+++ b/storage/perfschema/table_ews_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_ews_global_by_event_name.h b/storage/perfschema/table_ews_global_by_event_name.h
index 46aad715c22..84d8a742b3c 100644
--- a/storage/perfschema/table_ews_global_by_event_name.h
+++ b/storage/perfschema/table_ews_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_instances.cc b/storage/perfschema/table_file_instances.cc
index c5fd7db2c23..5af6f0551b6 100644
--- a/storage/perfschema/table_file_instances.cc
+++ b/storage/perfschema/table_file_instances.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_instances.h b/storage/perfschema/table_file_instances.h
index 6b8ffaeb591..5b1b9016f41 100644
--- a/storage/perfschema/table_file_instances.h
+++ b/storage/perfschema/table_file_instances.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_summary_by_event_name.cc b/storage/perfschema/table_file_summary_by_event_name.cc
index d91fb02fe06..fc9006c29fa 100644
--- a/storage/perfschema/table_file_summary_by_event_name.cc
+++ b/storage/perfschema/table_file_summary_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_summary_by_event_name.h b/storage/perfschema/table_file_summary_by_event_name.h
index 0c2b592ab60..80b08773b55 100644
--- a/storage/perfschema/table_file_summary_by_event_name.h
+++ b/storage/perfschema/table_file_summary_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_summary_by_instance.cc b/storage/perfschema/table_file_summary_by_instance.cc
index 5cd98955d62..89e08d49161 100644
--- a/storage/perfschema/table_file_summary_by_instance.cc
+++ b/storage/perfschema/table_file_summary_by_instance.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_file_summary_by_instance.h b/storage/perfschema/table_file_summary_by_instance.h
index b8b2115aeed..750ba904484 100644
--- a/storage/perfschema/table_file_summary_by_instance.h
+++ b/storage/perfschema/table_file_summary_by_instance.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_global_status.cc b/storage/perfschema/table_global_status.cc
index d9a20dc7e24..08531b555f7 100644
--- a/storage/perfschema/table_global_status.cc
+++ b/storage/perfschema/table_global_status.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_global_status.h b/storage/perfschema/table_global_status.h
index 45c57fb6900..5b5f6e60c37 100644
--- a/storage/perfschema/table_global_status.h
+++ b/storage/perfschema/table_global_status.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_global_variables.cc b/storage/perfschema/table_global_variables.cc
index fbe6b977cd1..39bf22438e4 100644
--- a/storage/perfschema/table_global_variables.cc
+++ b/storage/perfschema/table_global_variables.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_global_variables.h b/storage/perfschema/table_global_variables.h
index f5429c671a2..49083e63292 100644
--- a/storage/perfschema/table_global_variables.h
+++ b/storage/perfschema/table_global_variables.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_helper.cc b/storage/perfschema/table_helper.cc
index 477a1cd6006..dd5a765f4bf 100644
--- a/storage/perfschema/table_helper.cc
+++ b/storage/perfschema/table_helper.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_helper.h b/storage/perfschema/table_helper.h
index 0e39b80875f..ddea4c08b36 100644
--- a/storage/perfschema/table_helper.h
+++ b/storage/perfschema/table_helper.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_host_cache.cc b/storage/perfschema/table_host_cache.cc
index 79318223e21..03bfc151e37 100644
--- a/storage/perfschema/table_host_cache.cc
+++ b/storage/perfschema/table_host_cache.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_host_cache.h b/storage/perfschema/table_host_cache.h
index 482b8a2d66a..59e3a973421 100644
--- a/storage/perfschema/table_host_cache.h
+++ b/storage/perfschema/table_host_cache.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_hosts.cc b/storage/perfschema/table_hosts.cc
index 443cb12e6e0..bfb3ecad492 100644
--- a/storage/perfschema/table_hosts.cc
+++ b/storage/perfschema/table_hosts.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_hosts.h b/storage/perfschema/table_hosts.h
index cf94bdcbf79..1f82cc5c60b 100644
--- a/storage/perfschema/table_hosts.h
+++ b/storage/perfschema/table_hosts.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_md_locks.cc b/storage/perfschema/table_md_locks.cc
index 2b69e385a79..e7b76c12764 100644
--- a/storage/perfschema/table_md_locks.cc
+++ b/storage/perfschema/table_md_locks.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_md_locks.h b/storage/perfschema/table_md_locks.h
index ddb133ea7ff..5c9ad9b5638 100644
--- a/storage/perfschema/table_md_locks.h
+++ b/storage/perfschema/table_md_locks.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_account_by_event_name.cc b/storage/perfschema/table_mems_by_account_by_event_name.cc
index ec074872733..4168d83eadd 100644
--- a/storage/perfschema/table_mems_by_account_by_event_name.cc
+++ b/storage/perfschema/table_mems_by_account_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_account_by_event_name.h b/storage/perfschema/table_mems_by_account_by_event_name.h
index 626190461d5..e242bc40ac6 100644
--- a/storage/perfschema/table_mems_by_account_by_event_name.h
+++ b/storage/perfschema/table_mems_by_account_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_host_by_event_name.cc b/storage/perfschema/table_mems_by_host_by_event_name.cc
index d08444c311d..cbe71d079ec 100644
--- a/storage/perfschema/table_mems_by_host_by_event_name.cc
+++ b/storage/perfschema/table_mems_by_host_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_host_by_event_name.h b/storage/perfschema/table_mems_by_host_by_event_name.h
index f46f3c889e0..7920b362b5e 100644
--- a/storage/perfschema/table_mems_by_host_by_event_name.h
+++ b/storage/perfschema/table_mems_by_host_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_thread_by_event_name.cc b/storage/perfschema/table_mems_by_thread_by_event_name.cc
index eb76a016030..2335688af03 100644
--- a/storage/perfschema/table_mems_by_thread_by_event_name.cc
+++ b/storage/perfschema/table_mems_by_thread_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_thread_by_event_name.h b/storage/perfschema/table_mems_by_thread_by_event_name.h
index 17196e0fd80..0f698990b47 100644
--- a/storage/perfschema/table_mems_by_thread_by_event_name.h
+++ b/storage/perfschema/table_mems_by_thread_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_user_by_event_name.cc b/storage/perfschema/table_mems_by_user_by_event_name.cc
index 708c5681c3c..4a142cc9f5c 100644
--- a/storage/perfschema/table_mems_by_user_by_event_name.cc
+++ b/storage/perfschema/table_mems_by_user_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_by_user_by_event_name.h b/storage/perfschema/table_mems_by_user_by_event_name.h
index c2ad8bd7462..c17f5d3302b 100644
--- a/storage/perfschema/table_mems_by_user_by_event_name.h
+++ b/storage/perfschema/table_mems_by_user_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_global_by_event_name.cc b/storage/perfschema/table_mems_global_by_event_name.cc
index c84fa1a1529..69112a3bb51 100644
--- a/storage/perfschema/table_mems_global_by_event_name.cc
+++ b/storage/perfschema/table_mems_global_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_mems_global_by_event_name.h b/storage/perfschema/table_mems_global_by_event_name.h
index eaff095f8d7..ae3cd0435d6 100644
--- a/storage/perfschema/table_mems_global_by_event_name.h
+++ b/storage/perfschema/table_mems_global_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_os_global_by_type.cc b/storage/perfschema/table_os_global_by_type.cc
index ac1c123e5f4..19629d449eb 100644
--- a/storage/perfschema/table_os_global_by_type.cc
+++ b/storage/perfschema/table_os_global_by_type.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_os_global_by_type.h b/storage/perfschema/table_os_global_by_type.h
index 632bed522ed..7d0ed58ce5b 100644
--- a/storage/perfschema/table_os_global_by_type.h
+++ b/storage/perfschema/table_os_global_by_type.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_performance_timers.cc b/storage/perfschema/table_performance_timers.cc
index c89ad8d9021..da5f38c9076 100644
--- a/storage/perfschema/table_performance_timers.cc
+++ b/storage/perfschema/table_performance_timers.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_performance_timers.h b/storage/perfschema/table_performance_timers.h
index 15bdb5bfa93..a28b4d3f2c9 100644
--- a/storage/perfschema/table_performance_timers.h
+++ b/storage/perfschema/table_performance_timers.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_prepared_stmt_instances.cc b/storage/perfschema/table_prepared_stmt_instances.cc
index 8ff699eb03c..f064d8f03ae 100644
--- a/storage/perfschema/table_prepared_stmt_instances.cc
+++ b/storage/perfschema/table_prepared_stmt_instances.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_prepared_stmt_instances.h b/storage/perfschema/table_prepared_stmt_instances.h
index e7afe5d48b0..8bd9acafce5 100644
--- a/storage/perfschema/table_prepared_stmt_instances.h
+++ b/storage/perfschema/table_prepared_stmt_instances.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_processlist.cc b/storage/perfschema/table_processlist.cc
index 25d9ca7129c..8c91a5230e9 100644
--- a/storage/perfschema/table_processlist.cc
+++ b/storage/perfschema/table_processlist.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_processlist.h b/storage/perfschema/table_processlist.h
index 0944b5619fe..2cf55e1ed0f 100644
--- a/storage/perfschema/table_processlist.h
+++ b/storage/perfschema/table_processlist.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_configuration.cc b/storage/perfschema/table_replication_applier_configuration.cc
index ce66fa9fecd..601e2b49878 100644
--- a/storage/perfschema/table_replication_applier_configuration.cc
+++ b/storage/perfschema/table_replication_applier_configuration.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_configuration.h b/storage/perfschema/table_replication_applier_configuration.h
index 917778a5a03..580b78cfb3b 100644
--- a/storage/perfschema/table_replication_applier_configuration.h
+++ b/storage/perfschema/table_replication_applier_configuration.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status.cc b/storage/perfschema/table_replication_applier_status.cc
index 053ed997760..fda3c9274d9 100644
--- a/storage/perfschema/table_replication_applier_status.cc
+++ b/storage/perfschema/table_replication_applier_status.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status.h b/storage/perfschema/table_replication_applier_status.h
index 11dbbc43105..4da2087a32a 100644
--- a/storage/perfschema/table_replication_applier_status.h
+++ b/storage/perfschema/table_replication_applier_status.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status_by_coordinator.cc b/storage/perfschema/table_replication_applier_status_by_coordinator.cc
index c795cdb6624..02419fd3e89 100644
--- a/storage/perfschema/table_replication_applier_status_by_coordinator.cc
+++ b/storage/perfschema/table_replication_applier_status_by_coordinator.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status_by_coordinator.h b/storage/perfschema/table_replication_applier_status_by_coordinator.h
index 2424304be72..991e46afe50 100644
--- a/storage/perfschema/table_replication_applier_status_by_coordinator.h
+++ b/storage/perfschema/table_replication_applier_status_by_coordinator.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status_by_worker.cc b/storage/perfschema/table_replication_applier_status_by_worker.cc
index e982b5203ec..94aa305af02 100644
--- a/storage/perfschema/table_replication_applier_status_by_worker.cc
+++ b/storage/perfschema/table_replication_applier_status_by_worker.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_applier_status_by_worker.h b/storage/perfschema/table_replication_applier_status_by_worker.h
index 14689f83f57..2e400783c61 100644
--- a/storage/perfschema/table_replication_applier_status_by_worker.h
+++ b/storage/perfschema/table_replication_applier_status_by_worker.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_connection_configuration.cc b/storage/perfschema/table_replication_connection_configuration.cc
index ce79cc73362..81135074754 100644
--- a/storage/perfschema/table_replication_connection_configuration.cc
+++ b/storage/perfschema/table_replication_connection_configuration.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_connection_configuration.h b/storage/perfschema/table_replication_connection_configuration.h
index 3949975e397..5390c51e596 100644
--- a/storage/perfschema/table_replication_connection_configuration.h
+++ b/storage/perfschema/table_replication_connection_configuration.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_connection_status.cc b/storage/perfschema/table_replication_connection_status.cc
index 71c02e314ed..315392ef080 100644
--- a/storage/perfschema/table_replication_connection_status.cc
+++ b/storage/perfschema/table_replication_connection_status.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_connection_status.h b/storage/perfschema/table_replication_connection_status.h
index a40ae408dea..57cc9a944df 100644
--- a/storage/perfschema/table_replication_connection_status.h
+++ b/storage/perfschema/table_replication_connection_status.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_group_member_stats.cc b/storage/perfschema/table_replication_group_member_stats.cc
index e4a38bac44f..245b4ffbe20 100644
--- a/storage/perfschema/table_replication_group_member_stats.cc
+++ b/storage/perfschema/table_replication_group_member_stats.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_group_member_stats.h b/storage/perfschema/table_replication_group_member_stats.h
index 628e87e891d..d3d00a7a5f2 100644
--- a/storage/perfschema/table_replication_group_member_stats.h
+++ b/storage/perfschema/table_replication_group_member_stats.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2014, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2014, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_group_members.cc b/storage/perfschema/table_replication_group_members.cc
index 850191373b0..80f67ccca88 100644
--- a/storage/perfschema/table_replication_group_members.cc
+++ b/storage/perfschema/table_replication_group_members.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_replication_group_members.h b/storage/perfschema/table_replication_group_members.h
index 454f58de048..3ea5787877a 100644
--- a/storage/perfschema/table_replication_group_members.h
+++ b/storage/perfschema/table_replication_group_members.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+ Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_account_connect_attrs.cc b/storage/perfschema/table_session_account_connect_attrs.cc
index 075d66dd5cb..3caa43bfca8 100644
--- a/storage/perfschema/table_session_account_connect_attrs.cc
+++ b/storage/perfschema/table_session_account_connect_attrs.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_account_connect_attrs.h b/storage/perfschema/table_session_account_connect_attrs.h
index d556394515c..6a405db6cef 100644
--- a/storage/perfschema/table_session_account_connect_attrs.h
+++ b/storage/perfschema/table_session_account_connect_attrs.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_connect.cc b/storage/perfschema/table_session_connect.cc
index 9d9b1eafc13..54511e1bac2 100644
--- a/storage/perfschema/table_session_connect.cc
+++ b/storage/perfschema/table_session_connect.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_connect.h b/storage/perfschema/table_session_connect.h
index 89ae4f221d3..bcc42beb574 100644
--- a/storage/perfschema/table_session_connect.h
+++ b/storage/perfschema/table_session_connect.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_connect_attrs.cc b/storage/perfschema/table_session_connect_attrs.cc
index 5983f3f18a2..8265a0f59e9 100644
--- a/storage/perfschema/table_session_connect_attrs.cc
+++ b/storage/perfschema/table_session_connect_attrs.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_connect_attrs.h b/storage/perfschema/table_session_connect_attrs.h
index f115ea1b168..43c929ea599 100644
--- a/storage/perfschema/table_session_connect_attrs.h
+++ b/storage/perfschema/table_session_connect_attrs.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_status.cc b/storage/perfschema/table_session_status.cc
index 403b2acabfe..3baad528f66 100644
--- a/storage/perfschema/table_session_status.cc
+++ b/storage/perfschema/table_session_status.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_status.h b/storage/perfschema/table_session_status.h
index d338ccafa8a..0b3e16c6011 100644
--- a/storage/perfschema/table_session_status.h
+++ b/storage/perfschema/table_session_status.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_variables.cc b/storage/perfschema/table_session_variables.cc
index 2a37686f6d9..b3b751c9515 100644
--- a/storage/perfschema/table_session_variables.cc
+++ b/storage/perfschema/table_session_variables.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_session_variables.h b/storage/perfschema/table_session_variables.h
index 0223438824a..f46d9967e5c 100644
--- a/storage/perfschema/table_session_variables.h
+++ b/storage/perfschema/table_session_variables.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_actors.cc b/storage/perfschema/table_setup_actors.cc
index e2733a94fcc..38a7de43d81 100644
--- a/storage/perfschema/table_setup_actors.cc
+++ b/storage/perfschema/table_setup_actors.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_actors.h b/storage/perfschema/table_setup_actors.h
index da5fdc37950..1909d41e24b 100644
--- a/storage/perfschema/table_setup_actors.h
+++ b/storage/perfschema/table_setup_actors.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_consumers.cc b/storage/perfschema/table_setup_consumers.cc
index ab2fb030468..3fc4004e5cf 100644
--- a/storage/perfschema/table_setup_consumers.cc
+++ b/storage/perfschema/table_setup_consumers.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_consumers.h b/storage/perfschema/table_setup_consumers.h
index c72108beb46..c7386d7a050 100644
--- a/storage/perfschema/table_setup_consumers.h
+++ b/storage/perfschema/table_setup_consumers.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_instruments.cc b/storage/perfschema/table_setup_instruments.cc
index 40a17bc1deb..1e3cd964165 100644
--- a/storage/perfschema/table_setup_instruments.cc
+++ b/storage/perfschema/table_setup_instruments.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_instruments.h b/storage/perfschema/table_setup_instruments.h
index ce979c40e48..9ea142857ce 100644
--- a/storage/perfschema/table_setup_instruments.h
+++ b/storage/perfschema/table_setup_instruments.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_objects.cc b/storage/perfschema/table_setup_objects.cc
index d43ac4ae5e5..dbe953614fb 100644
--- a/storage/perfschema/table_setup_objects.cc
+++ b/storage/perfschema/table_setup_objects.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_objects.h b/storage/perfschema/table_setup_objects.h
index d6cb9bc30c3..32853b36497 100644
--- a/storage/perfschema/table_setup_objects.h
+++ b/storage/perfschema/table_setup_objects.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_timers.cc b/storage/perfschema/table_setup_timers.cc
index 4109f4fc5e6..3c6f8451030 100644
--- a/storage/perfschema/table_setup_timers.cc
+++ b/storage/perfschema/table_setup_timers.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_setup_timers.h b/storage/perfschema/table_setup_timers.h
index 9fff43c33a3..e606fcbfa8b 100644
--- a/storage/perfschema/table_setup_timers.h
+++ b/storage/perfschema/table_setup_timers.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_instances.cc b/storage/perfschema/table_socket_instances.cc
index 7d2e06955f4..2435d19df3c 100644
--- a/storage/perfschema/table_socket_instances.cc
+++ b/storage/perfschema/table_socket_instances.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_instances.h b/storage/perfschema/table_socket_instances.h
index fdd978b5c3a..c8a4a5b6a5d 100644
--- a/storage/perfschema/table_socket_instances.h
+++ b/storage/perfschema/table_socket_instances.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_summary_by_event_name.cc b/storage/perfschema/table_socket_summary_by_event_name.cc
index 77461ea3ede..222294cf8d7 100644
--- a/storage/perfschema/table_socket_summary_by_event_name.cc
+++ b/storage/perfschema/table_socket_summary_by_event_name.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_summary_by_event_name.h b/storage/perfschema/table_socket_summary_by_event_name.h
index 3a243572979..726d16abb0a 100644
--- a/storage/perfschema/table_socket_summary_by_event_name.h
+++ b/storage/perfschema/table_socket_summary_by_event_name.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_summary_by_instance.cc b/storage/perfschema/table_socket_summary_by_instance.cc
index 17ea3d1abe6..eb0568c05c2 100644
--- a/storage/perfschema/table_socket_summary_by_instance.cc
+++ b/storage/perfschema/table_socket_summary_by_instance.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_socket_summary_by_instance.h b/storage/perfschema/table_socket_summary_by_instance.h
index b8a08db3e36..21e811baabf 100644
--- a/storage/perfschema/table_socket_summary_by_instance.h
+++ b/storage/perfschema/table_socket_summary_by_instance.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_account.cc b/storage/perfschema/table_status_by_account.cc
index 7ee8c116f70..55a6fc10158 100644
--- a/storage/perfschema/table_status_by_account.cc
+++ b/storage/perfschema/table_status_by_account.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_account.h b/storage/perfschema/table_status_by_account.h
index 3da5077ebc6..c8d270c5926 100644
--- a/storage/perfschema/table_status_by_account.h
+++ b/storage/perfschema/table_status_by_account.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_host.cc b/storage/perfschema/table_status_by_host.cc
index 3837df5cb34..52d723dca4e 100644
--- a/storage/perfschema/table_status_by_host.cc
+++ b/storage/perfschema/table_status_by_host.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_host.h b/storage/perfschema/table_status_by_host.h
index c697638bacf..4e28966c016 100644
--- a/storage/perfschema/table_status_by_host.h
+++ b/storage/perfschema/table_status_by_host.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_thread.cc b/storage/perfschema/table_status_by_thread.cc
index 8b1d945609b..ea1218a04ec 100644
--- a/storage/perfschema/table_status_by_thread.cc
+++ b/storage/perfschema/table_status_by_thread.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_thread.h b/storage/perfschema/table_status_by_thread.h
index c3f50941597..770490438f1 100644
--- a/storage/perfschema/table_status_by_thread.h
+++ b/storage/perfschema/table_status_by_thread.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_user.cc b/storage/perfschema/table_status_by_user.cc
index 8ea45205ae4..dcafa3a8b76 100644
--- a/storage/perfschema/table_status_by_user.cc
+++ b/storage/perfschema/table_status_by_user.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_status_by_user.h b/storage/perfschema/table_status_by_user.h
index 4cf348fdec7..1954b15d820 100644
--- a/storage/perfschema/table_status_by_user.h
+++ b/storage/perfschema/table_status_by_user.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_sync_instances.cc b/storage/perfschema/table_sync_instances.cc
index 5f2c709170f..497f7fa1854 100644
--- a/storage/perfschema/table_sync_instances.cc
+++ b/storage/perfschema/table_sync_instances.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_sync_instances.h b/storage/perfschema/table_sync_instances.h
index 2682c7c88a8..75424d56540 100644
--- a/storage/perfschema/table_sync_instances.h
+++ b/storage/perfschema/table_sync_instances.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_table_handles.cc b/storage/perfschema/table_table_handles.cc
index d878ce2f7c1..7ea2b0a3316 100644
--- a/storage/perfschema/table_table_handles.cc
+++ b/storage/perfschema/table_table_handles.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_table_handles.h b/storage/perfschema/table_table_handles.h
index 3f2f8c5c1ad..7e184deb9a0 100644
--- a/storage/perfschema/table_table_handles.h
+++ b/storage/perfschema/table_table_handles.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2012, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_threads.cc b/storage/perfschema/table_threads.cc
index c98a612eca2..92fcf96d6d8 100644
--- a/storage/perfschema/table_threads.cc
+++ b/storage/perfschema/table_threads.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_threads.h b/storage/perfschema/table_threads.h
index ff9f7ccb2a3..1f981ded4d7 100644
--- a/storage/perfschema/table_threads.h
+++ b/storage/perfschema/table_threads.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tiws_by_index_usage.cc b/storage/perfschema/table_tiws_by_index_usage.cc
index b8f3bfa4039..80b62bbef22 100644
--- a/storage/perfschema/table_tiws_by_index_usage.cc
+++ b/storage/perfschema/table_tiws_by_index_usage.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tiws_by_index_usage.h b/storage/perfschema/table_tiws_by_index_usage.h
index 5f0c85874bd..6bc009fcf20 100644
--- a/storage/perfschema/table_tiws_by_index_usage.h
+++ b/storage/perfschema/table_tiws_by_index_usage.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tiws_by_table.cc b/storage/perfschema/table_tiws_by_table.cc
index 75eaf70cd8a..ee4f54a322a 100644
--- a/storage/perfschema/table_tiws_by_table.cc
+++ b/storage/perfschema/table_tiws_by_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tiws_by_table.h b/storage/perfschema/table_tiws_by_table.h
index 933a6164de9..2970ee64b06 100644
--- a/storage/perfschema/table_tiws_by_table.h
+++ b/storage/perfschema/table_tiws_by_table.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tlws_by_table.cc b/storage/perfschema/table_tlws_by_table.cc
index 17bdf6449a6..709f22a1b0a 100644
--- a/storage/perfschema/table_tlws_by_table.cc
+++ b/storage/perfschema/table_tlws_by_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_tlws_by_table.h b/storage/perfschema/table_tlws_by_table.h
index 49188abd905..5755e33f7a7 100644
--- a/storage/perfschema/table_tlws_by_table.h
+++ b/storage/perfschema/table_tlws_by_table.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_users.cc b/storage/perfschema/table_users.cc
index 14fc8bf7db1..b30c36e1c68 100644
--- a/storage/perfschema/table_users.cc
+++ b/storage/perfschema/table_users.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_users.h b/storage/perfschema/table_users.h
index a81c143ae2e..9255ec9546a 100644
--- a/storage/perfschema/table_users.h
+++ b/storage/perfschema/table_users.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_uvar_by_thread.cc b/storage/perfschema/table_uvar_by_thread.cc
index 43b9bf347d3..74b6165d039 100644
--- a/storage/perfschema/table_uvar_by_thread.cc
+++ b/storage/perfschema/table_uvar_by_thread.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_uvar_by_thread.h b/storage/perfschema/table_uvar_by_thread.h
index 82faf1a52ec..61c521069c7 100644
--- a/storage/perfschema/table_uvar_by_thread.h
+++ b/storage/perfschema/table_uvar_by_thread.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_variables_by_thread.cc b/storage/perfschema/table_variables_by_thread.cc
index db9e4c2c9ec..d673fa436c5 100644
--- a/storage/perfschema/table_variables_by_thread.cc
+++ b/storage/perfschema/table_variables_by_thread.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/table_variables_by_thread.h b/storage/perfschema/table_variables_by_thread.h
index a9e70388366..99adcda4e98 100644
--- a/storage/perfschema/table_variables_by_thread.h
+++ b/storage/perfschema/table_variables_by_thread.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt
index ce20006a00e..2a22990f807 100644
--- a/storage/perfschema/unittest/CMakeLists.txt
+++ b/storage/perfschema/unittest/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2022, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2023, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/conf.txt b/storage/perfschema/unittest/conf.txt
index a22d8fd41b2..38d1e3d39a4 100644
--- a/storage/perfschema/unittest/conf.txt
+++ b/storage/perfschema/unittest/conf.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2022, Oracle and/or its affiliates.
+# Copyright (c) 2009, 2023, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc
index 412184ecbed..981792f99e2 100644
--- a/storage/perfschema/unittest/pfs-t.cc
+++ b/storage/perfschema/unittest/pfs-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_account-oom-t.cc b/storage/perfschema/unittest/pfs_account-oom-t.cc
index 68190218b74..97aea4c5aac 100644
--- a/storage/perfschema/unittest/pfs_account-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_account-oom-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_connect_attr-t.cc b/storage/perfschema/unittest/pfs_connect_attr-t.cc
index c09f10fd7de..dee56ebcd51 100644
--- a/storage/perfschema/unittest/pfs_connect_attr-t.cc
+++ b/storage/perfschema/unittest/pfs_connect_attr-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_host-oom-t.cc b/storage/perfschema/unittest/pfs_host-oom-t.cc
index 1e46963fcb8..f903561de82 100644
--- a/storage/perfschema/unittest/pfs_host-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_host-oom-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_instr-oom-t.cc b/storage/perfschema/unittest/pfs_instr-oom-t.cc
index eff2385ef48..579aec6c5ae 100644
--- a/storage/perfschema/unittest/pfs_instr-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_instr-t.cc b/storage/perfschema/unittest/pfs_instr-t.cc
index b0d3bd9c36f..9667d7ff2be 100644
--- a/storage/perfschema/unittest/pfs_instr-t.cc
+++ b/storage/perfschema/unittest/pfs_instr-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
index 612cc5adf3f..b7c17d06bae 100644
--- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_instr_class-t.cc b/storage/perfschema/unittest/pfs_instr_class-t.cc
index b5f08f739ac..7651898d684 100644
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_misc-t.cc b/storage/perfschema/unittest/pfs_misc-t.cc
index 6765dca0550..f596434813e 100644
--- a/storage/perfschema/unittest/pfs_misc-t.cc
+++ b/storage/perfschema/unittest/pfs_misc-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_noop-t.cc b/storage/perfschema/unittest/pfs_noop-t.cc
index 896a29d1bd4..57e8cfd8a0a 100644
--- a/storage/perfschema/unittest/pfs_noop-t.cc
+++ b/storage/perfschema/unittest/pfs_noop-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2013, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/unittest/pfs_server_stubs.cc b/storage/perfschema/unittest/pfs_server_stubs.cc
index a873bdcbd10..1ec84c2538e 100644
--- a/storage/perfschema/unittest/pfs_server_stubs.cc
+++ b/storage/perfschema/unittest/pfs_server_stubs.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/unittest/pfs_timer-t.cc b/storage/perfschema/unittest/pfs_timer-t.cc
index 07f61f59fe7..20a5cb9742b 100644
--- a/storage/perfschema/unittest/pfs_timer-t.cc
+++ b/storage/perfschema/unittest/pfs_timer-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/pfs_user-oom-t.cc b/storage/perfschema/unittest/pfs_user-oom-t.cc
index 62748648ea1..acc3d8c612f 100644
--- a/storage/perfschema/unittest/pfs_user-oom-t.cc
+++ b/storage/perfschema/unittest/pfs_user-oom-t.cc
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2011, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/stub_global_status_var.h b/storage/perfschema/unittest/stub_global_status_var.h
index e985ad25bbf..70644981b55 100644
--- a/storage/perfschema/unittest/stub_global_status_var.h
+++ b/storage/perfschema/unittest/stub_global_status_var.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2015, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/stub_pfs_defaults.h b/storage/perfschema/unittest/stub_pfs_defaults.h
index 354d2291fa3..4b064b57166 100644
--- a/storage/perfschema/unittest/stub_pfs_defaults.h
+++ b/storage/perfschema/unittest/stub_pfs_defaults.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2010, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h
index b43d53a43f4..4b792f9bfef 100644
--- a/storage/perfschema/unittest/stub_pfs_global.h
+++ b/storage/perfschema/unittest/stub_pfs_global.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
diff --git a/storage/perfschema/unittest/stub_print_error.h b/storage/perfschema/unittest/stub_print_error.h
index 7f6df940515..a02e2478d27 100644
--- a/storage/perfschema/unittest/stub_print_error.h
+++ b/storage/perfschema/unittest/stub_print_error.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2022, Oracle and/or its affiliates.
+/* Copyright (c) 2008, 2023, Oracle and/or its affiliates.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt
index 544ae62e6e2..76e9a4ab5a1 100644
--- a/storage/rocksdb/CMakeLists.txt
+++ b/storage/rocksdb/CMakeLists.txt
@@ -30,6 +30,11 @@ IF(WITH_VALGRIND)
ADD_DEFINITIONS(-DROCKSDB_VALGRIND_RUN=1)
ENDIF()
+ADD_DEFINITIONS(-Duint64_t=u_int64_t)
+ADD_DEFINITIONS(-Duint32_t=u_int32_t)
+ADD_DEFINITIONS(-Duint16_t=u_int16_t)
+ADD_DEFINITIONS(-Duint8_t=u_int8_t)
+
# We've had our builders hang during the build process. This prevents MariaRocks
# to be built on 32 bit intel OS kernels.
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i[36]86")
diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake
index 096185af08f..27a8616cfda 100644
--- a/storage/rocksdb/build_rocksdb.cmake
+++ b/storage/rocksdb/build_rocksdb.cmake
@@ -134,8 +134,8 @@ option(WITH_FALLOCATE "build with fallocate" ON)
if(WITH_FALLOCATE AND UNIX)
include(CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
+#define _GNU_SOURCE
#include <fcntl.h>
-#include <linux/falloc.h>
int main() {
int fd = open(\"/dev/null\", 0);
fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, 1024);
diff --git a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc
index 81cd2200ae0..a87fe01b3a1 100644
--- a/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc
+++ b/storage/rocksdb/mysql-test/rocksdb/include/restart_mysqld_with_option.inc
@@ -9,8 +9,8 @@ if ($rpl_inited)
# Write file to make mysql-test-run.pl expect the "crash", but don't start
# it until it's told to
---let $_server_id= `SELECT @@server_id`
---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect
--exec echo "wait" > $_expect_file_name
# Send shutdown to the connected server and give
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
index d2974438ecb..8612b922cab 100644
--- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
+++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result
@@ -133,8 +133,8 @@ trx_commits_insert_update transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NUL
trx_rollbacks transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back
trx_rollbacks_savepoint transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of transactions rolled back to savepoint
trx_rseg_history_len transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Length of the TRX_RSEG_HISTORY list
-trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots used
-trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of undo slots cached
+trx_undo_slots_used transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots used
+trx_undo_slots_cached transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Number of undo slots cached
trx_rseg_current_size transaction 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 value Current rollback segment size in pages
purge_del_mark_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of delete-marked rows purged
purge_upd_exist_or_extern_records purge 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of purges on updates of existing records and updates on delete marked record with externally stored field
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test
index e084b57fbda..88a02c469bb 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/allow_to_start_after_corruption.test
@@ -16,6 +16,7 @@
# restart server to change error log and ignore corruptopn on startup
--let $_mysqld_option=--log-error=$LOG --rocksdb_allow_to_start_after_corruption=1
--source include/restart_mysqld_with_option.inc
+--let $_server_id= `SELECT @@server_id`
--echo #
--echo # Test server crashes on corrupted data and restarts
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test
index 49e5e5c1172..da9d8602c01 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/persistent_cache.test
@@ -4,8 +4,8 @@
DROP TABLE IF EXISTS t1;
--enable_warnings
---let $_server_id= `SELECT @@server_id`
---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect
--let $_cache_file_name= $MYSQLTEST_VARDIR/tmp/persistent_cache
--exec echo "wait" >$_expect_file_name
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test
index e7ab37d2658..b2647b38e08 100644
--- a/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test
+++ b/storage/rocksdb/mysql-test/rocksdb/t/validate_datadic.test
@@ -17,8 +17,8 @@ CREATE TABLE t2 (pk int primary key) ENGINE=ROCKSDB PARTITION BY KEY(pk) PARTITI
# Write file to make mysql-test-run.pl expect the "crash", but don't restart the
# server until it is told to
---let $_server_id= `SELECT @@server_id`
---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect
--let LOG=$MYSQLTEST_VARDIR/tmp/validate_datadic.err
--exec echo "wait" >$_expect_file_name
diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test
index 743f942af9c..1daa9898c1a 100644
--- a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test
+++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_rate_limiter_bytes_per_sec_basic.test
@@ -7,8 +7,8 @@ SET @@global.rocksdb_rate_limiter_bytes_per_sec = 10000;
# Write file to make mysql-test-run.pl expect the "crash", but don't restart the
# server until it is told to
---let $_server_id= `SELECT @@server_id`
---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect
--exec echo "wait" >$_expect_file_name
# Send shutdown to the connected server and give it 10 seconds to die before
diff --git a/storage/rocksdb/ut0counter.h b/storage/rocksdb/ut0counter.h
index 7b1885810c3..5267508faba 100644
--- a/storage/rocksdb/ut0counter.h
+++ b/storage/rocksdb/ut0counter.h
@@ -61,7 +61,7 @@ struct get_sched_indexer_t : public generic_indexer_t<Type, N> {
size_t cpu = sched_getcpu();
if (cpu == (size_t) -1) {
- cpu = get_curr_thread_id();
+ cpu = (size_t) get_curr_thread_id();
}
return(cpu);
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index e5ef9499eda..8af57895b93 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -309,10 +309,10 @@ int ha_spider::open(
no_bytes_in_map(table->read_set));
wide_handler_alloc = TRUE;
- if (!share && !spider_get_share(name, table, thd, this, &error_num))
- goto error_get_share;
+ if (!share && !spider_get_share(name, table, thd, this, &error_num))
+ goto error_get_share;
- wide_share = share->wide_share;
+ wide_share = share->wide_share;
DBUG_PRINT("info",("spider create partition_handler"));
DBUG_PRINT("info",("spider table=%p", table));
@@ -6559,13 +6559,6 @@ int ha_spider::info(
auto_inc_temporary = FALSE;
#endif
wide_handler->sql_command = thd_sql_command(thd);
-/*
- if (
- sql_command == SQLCOM_DROP_TABLE ||
- sql_command == SQLCOM_ALTER_TABLE ||
- sql_command == SQLCOM_SHOW_CREATE
- ) {
-*/
if (flag & HA_STATUS_AUTO)
{
if (share->lgtm_tblhnd_share->auto_increment_value)
@@ -6583,9 +6576,6 @@ int ha_spider::info(
wide_handler->sql_command == SQLCOM_ALTER_TABLE
)
DBUG_RETURN(0);
-/*
- }
-*/
if (flag &
(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE | HA_STATUS_AUTO))
diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h
index ac865e78f2c..50266739b63 100644
--- a/storage/spider/ha_spider.h
+++ b/storage/spider/ha_spider.h
@@ -63,8 +63,10 @@ public:
char *conn_keys_first_ptr;
char **conn_keys;
SPIDER_CONN **conns;
- /* for active-standby mode */
+ /* array of indexes of active servers */
uint *conn_link_idx;
+ /* A bitmap indicating whether each active server have some higher
+ numbered server in the same "group" left to try (can fail over) */
uchar *conn_can_fo;
void **quick_targets;
int *need_mons;
diff --git a/storage/spider/mysql-test/spider/bugfix/disabled.def b/storage/spider/mysql-test/spider/bugfix/disabled.def
index e19ea07b76b..2314e88ea0c 100644
--- a/storage/spider/mysql-test/spider/bugfix/disabled.def
+++ b/storage/spider/mysql-test/spider/bugfix/disabled.def
@@ -1 +1,2 @@
wait_timeout : MDEV-26045
+mdev_29676 : MDEV-31138
diff --git a/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc b/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc
deleted file mode 100644
index a5446a6188d..00000000000
--- a/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc
+++ /dev/null
@@ -1,8 +0,0 @@
---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
-
---exec echo "wait" > $_expect_file_name
---shutdown_server
---source include/wait_until_disconnected.inc
---exec echo "restart" > $_expect_file_name
---enable_reconnect
---source include/wait_until_connected_again.inc
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result
index 5715edf2bd6..975d3834d42 100644
--- a/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result
@@ -9,4 +9,5 @@ CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
ERROR HY000: Can't execute the query because you have a conflicting read lock
SELECT * FROM t;
c
+# restart
DROP TABLE t;
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29644.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29644.result
new file mode 100644
index 00000000000..b52cecc5bb7
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29644.result
@@ -0,0 +1,41 @@
+#
+# MDEV-29644 a potential bug of null pointer dereference in spider_db_mbase::print_warnings()
+#
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
+connection child2_1;
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+CREATE TABLE tbl_a (
+a CHAR(5)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+SET GLOBAL sql_mode='';
+connection master_1;
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+CREATE TABLE tbl_a (
+a CHAR(255)
+) ENGINE=Spider DEFAULT CHARSET=utf8 COMMENT='table "tbl_a", srv "s_2_1"';
+SET sql_mode='';
+INSERT INTO tbl_a VALUES ("this will be truncated");
+NOT FOUND /\[WARN SPIDER RESULT\].* Warning 1265 Data truncated for column 'a' at row 1.*/ in mysqld.1.1.err
+SET GLOBAL spider_log_result_errors=4;
+INSERT INTO tbl_a VALUES ("this will be truncated");
+FOUND 1 /\[WARN SPIDER RESULT\].* Warning 1265 Data truncated for column 'a' at row 1.*/ in mysqld.1.1.err
+connection master_1;
+SET GLOBAL spider_log_result_errors=DEFAULT;
+SET sql_mode=DEFAULT;
+DROP DATABASE IF EXISTS auto_test_local;
+connection child2_1;
+SET GLOBAL sql_mode=DEFAULT;
+DROP DATABASE IF EXISTS auto_test_remote;
+for master_1
+for child2
+child2_1
+child2_2
+child2_3
+for child3
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29676.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29676.result
new file mode 100644
index 00000000000..72c624c926b
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29676.result
@@ -0,0 +1,47 @@
+#
+# MDEV-29676 Dual thread hang in 'closing tables' and 'Waiting for table metadata lock' on Spider CREATE OR REPLACE TABLE
+#
+for master_1
+for child2
+for child3
+CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
+
+# length-0 self-reference
+
+CREATE TABLE t (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t"';
+CREATE OR REPLACE TABLE t (c INT);
+Warnings:
+Error 1205 Lock wait timeout exceeded; try restarting transaction
+Error 12722 Table test.t open lock wait timeout. Please check for self-reference.
+SHOW CREATE TABLE t;
+Table Create Table
+t CREATE TABLE `t` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+DROP TABLE t;
+
+# length-2 self-reference
+
+CREATE TABLE t2 (c int);
+CREATE TABLE t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
+CREATE TABLE t0 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
+ALTER TABLE t2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t0"';
+CREATE OR REPLACE TABLE t0 (c int);
+Warnings:
+Error 1205 Lock wait timeout exceeded; try restarting transaction
+Error 12722 Table test.t1 open lock wait timeout. Please check for self-reference.
+SHOW CREATE TABLE t0;
+Table Create Table
+t0 CREATE TABLE `t0` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+CREATE OR REPLACE TABLE t1 (c int);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+drop TABLE t0, t1, t2;
+for master_1
+for child2
+for child3
diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29904.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29904.result
new file mode 100644
index 00000000000..c89309a514d
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29904.result
@@ -0,0 +1,4 @@
+#
+# MDEV-29904 SPIDER plugin initialization fails upon startup
+#
+# restart: --plugin-load-add=ha_spider
diff --git a/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result
new file mode 100644
index 00000000000..c4399ddf9d2
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/r/self_reference_multi.result
@@ -0,0 +1,21 @@
+for master_1
+for child2
+for child3
+
+MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever
+
+CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
+create table t2 (c int);
+create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
+create table t0 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
+alter table t2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t0"';
+select * from t0;
+ERROR HY000: An infinite loop is detected when opening table test.t0
+select * from t1;
+ERROR HY000: An infinite loop is detected when opening table test.t0
+select * from t2;
+ERROR HY000: An infinite loop is detected when opening table test.t0
+drop table t0, t1, t2;
+for master_1
+for child2
+for child3
diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result
index e84d42bbc8a..ffccf2d5ef1 100644
--- a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result
+++ b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result
@@ -50,6 +50,10 @@ SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argum
argument
set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-'
SET NAMES utf8mb3
+set @old_lock_wait_timeout=@@session.lock_wait_timeout;set session lock_wait_timeout=1
+set session lock_wait_timeout=@old_lock_wait_timeout
+set @old_lock_wait_timeout=@@session.lock_wait_timeout;set session lock_wait_timeout=1
+set session lock_wait_timeout=@old_lock_wait_timeout
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'
SELECT pkey FROM tbl_a ORDER BY pkey;
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test
index 00d8ee73ebc..626364efb99 100644
--- a/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test
@@ -6,6 +6,6 @@ FLUSH TABLES WITH READ LOCK;
CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so';
SELECT * FROM t;
---source include/restart_spider.inc
+--source include/restart_mysqld.inc
DROP TABLE t;
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.cnf b/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.cnf
new file mode 100644
index 00000000000..05dfd8a0bce
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.cnf
@@ -0,0 +1,3 @@
+!include include/default_mysqld.cnf
+!include ../my_1_1.cnf
+!include ../my_2_1.cnf
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.test
new file mode 100644
index 00000000000..3a8fbb251e1
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29644.test
@@ -0,0 +1,56 @@
+--echo #
+--echo # MDEV-29644 a potential bug of null pointer dereference in spider_db_mbase::print_warnings()
+--echo #
+
+# The test case below does not cause the potential null pointer dereference.
+# It is just for checking spider_db_mbase::fetch_and_print_warnings() works.
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_init.inc
+--enable_result_log
+--enable_query_log
+
+--connection child2_1
+CREATE DATABASE auto_test_remote;
+USE auto_test_remote;
+eval CREATE TABLE tbl_a (
+ a CHAR(5)
+) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
+
+SET GLOBAL sql_mode='';
+
+--connection master_1
+CREATE DATABASE auto_test_local;
+USE auto_test_local;
+eval CREATE TABLE tbl_a (
+ a CHAR(255)
+) $MASTER_1_ENGINE $MASTER_1_CHARSET COMMENT='table "tbl_a", srv "s_2_1"';
+
+SET sql_mode='';
+
+let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.1.err;
+let SEARCH_PATTERN= \[WARN SPIDER RESULT\].* Warning 1265 Data truncated for column 'a' at row 1.*;
+
+INSERT INTO tbl_a VALUES ("this will be truncated");
+--source include/search_pattern_in_file.inc # should not find
+
+SET GLOBAL spider_log_result_errors=4;
+
+INSERT INTO tbl_a VALUES ("this will be truncated");
+--source include/search_pattern_in_file.inc # should find
+
+--connection master_1
+SET GLOBAL spider_log_result_errors=DEFAULT;
+SET sql_mode=DEFAULT;
+DROP DATABASE IF EXISTS auto_test_local;
+
+--connection child2_1
+SET GLOBAL sql_mode=DEFAULT;
+DROP DATABASE IF EXISTS auto_test_remote;
+
+--disable_query_log
+--disable_result_log
+--source ../t/test_deinit.inc
+--enable_query_log
+--enable_result_log
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29676.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29676.test
new file mode 100644
index 00000000000..565d95dfaac
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29676.test
@@ -0,0 +1,41 @@
+--echo #
+--echo # MDEV-29676 Dual thread hang in 'closing tables' and 'Waiting for table metadata lock' on Spider CREATE OR REPLACE TABLE
+--echo #
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_init.inc
+--enable_result_log
+--enable_query_log
+
+--replace_regex /SOCKET ".*"/SOCKET "$MASTER_1_MYSOCK"/
+eval CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
+
+--echo
+--echo # length-0 self-reference
+--echo
+CREATE TABLE t (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t"';
+CREATE OR REPLACE TABLE t (c INT);
+SHOW CREATE TABLE t;
+DROP TABLE t;
+
+--echo
+--echo # length-2 self-reference
+--echo
+CREATE TABLE t2 (c int);
+CREATE TABLE t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
+CREATE TABLE t0 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
+ALTER TABLE t2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t0"';
+# warnings
+CREATE OR REPLACE TABLE t0 (c int);
+SHOW CREATE TABLE t0;
+# no warnings
+CREATE OR REPLACE TABLE t1 (c int);
+SHOW CREATE TABLE t1;
+drop TABLE t0, t1, t2;
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29904.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29904.test
new file mode 100644
index 00000000000..d3dcb363890
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29904.test
@@ -0,0 +1,6 @@
+--echo #
+--echo # MDEV-29904 SPIDER plugin initialization fails upon startup
+--echo #
+
+--let $restart_parameters=--plugin-load-add=ha_spider
+--source include/restart_mysqld.inc
diff --git a/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test b/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test
new file mode 100644
index 00000000000..8b6f070d167
--- /dev/null
+++ b/storage/spider/mysql-test/spider/bugfix/t/self_reference_multi.test
@@ -0,0 +1,29 @@
+--disable_query_log
+--disable_result_log
+--source ../../t/test_init.inc
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo MDEV-6268 SPIDER table with no COMMENT clause causes queries to wait forever
+--echo
+
+--replace_regex /SOCKET ".*"/SOCKET "$MASTER_1_MYSOCK"/
+eval CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
+create table t2 (c int);
+create table t1 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t2"';
+create table t0 (c int) ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
+alter table t2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv",TABLE "t0"';
+--error 12719
+select * from t0;
+--error 12719
+select * from t1;
+--error 12719
+select * from t2;
+drop table t0, t1, t2;
+
+--disable_query_log
+--disable_result_log
+--source ../../t/test_deinit.inc
+--enable_result_log
+--enable_query_log
diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result
index 28aaf74fa3d..c48d68758bf 100644
--- a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result
+++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result
@@ -53,6 +53,10 @@ SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argum
argument
set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-'
SET NAMES utf8mb3
+set @old_lock_wait_timeout=@@session.lock_wait_timeout;set session lock_wait_timeout=1
+set session lock_wait_timeout=@old_lock_wait_timeout
+set @old_lock_wait_timeout=@@session.lock_wait_timeout;set session lock_wait_timeout=1
+set session lock_wait_timeout=@old_lock_wait_timeout
set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction
SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'
SELECT pkey FROM tbl_a ORDER BY pkey;
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index ca556702c65..1baf6a30e7c 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -2992,12 +2992,6 @@ void *spider_bg_sts_action(
if (spider.search_link_idx < 0)
{
spider_trx_set_link_idx_for_all(&spider);
-/*
- spider.search_link_idx = spider_conn_next_link_idx(
- thd, share->link_statuses, share->access_balances,
- spider.conn_link_idx, spider.search_link_idx, share->link_count,
- SPIDER_LINK_STATUS_OK);
-*/
spider.search_link_idx = spider_conn_first_link_idx(thd,
share->link_statuses, share->access_balances, spider.conn_link_idx,
share->link_count, SPIDER_LINK_STATUS_OK);
@@ -3013,32 +3007,6 @@ void *spider_bg_sts_action(
share->conn_keys[spider.search_link_idx], trx,
&spider, FALSE, FALSE, &error_num);
conns[spider.search_link_idx]->error_mode = 0;
-/*
- if (
- error_num &&
- share->monitoring_kind[spider.search_link_idx] &&
- need_mons[spider.search_link_idx]
- ) {
- lex_start(thd);
- error_num = spider_ping_table_mon_from_table(
- trx,
- thd,
- share,
- spider.search_link_idx,
- (uint32) share->monitoring_sid[spider.search_link_idx],
- share->table_name,
- share->table_name_length,
- spider.conn_link_idx[spider.search_link_idx],
- NULL,
- 0,
- share->monitoring_kind[spider.search_link_idx],
- share->monitoring_limit[spider.search_link_idx],
- share->monitoring_flag[spider.search_link_idx],
- TRUE
- );
- lex_end(thd->lex);
- }
-*/
spider.search_link_idx = -1;
}
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
@@ -3049,31 +3017,6 @@ void *spider_bg_sts_action(
share->bg_sts_sync,
2, HA_STATUS_CONST | HA_STATUS_VARIABLE))
{
-/*
- if (
- share->monitoring_kind[spider.search_link_idx] &&
- need_mons[spider.search_link_idx]
- ) {
- lex_start(thd);
- error_num = spider_ping_table_mon_from_table(
- trx,
- thd,
- share,
- spider.search_link_idx,
- (uint32) share->monitoring_sid[spider.search_link_idx],
- share->table_name,
- share->table_name_length,
- spider.conn_link_idx[spider.search_link_idx],
- NULL,
- 0,
- share->monitoring_kind[spider.search_link_idx],
- share->monitoring_limit[spider.search_link_idx],
- share->monitoring_flag[spider.search_link_idx],
- TRUE
- );
- lex_end(thd->lex);
- }
-*/
spider.search_link_idx = -1;
}
}
@@ -3316,12 +3259,6 @@ void *spider_bg_crd_action(
if (spider.search_link_idx < 0)
{
spider_trx_set_link_idx_for_all(&spider);
-/*
- spider.search_link_idx = spider_conn_next_link_idx(
- thd, share->link_statuses, share->access_balances,
- spider.conn_link_idx, spider.search_link_idx, share->link_count,
- SPIDER_LINK_STATUS_OK);
-*/
spider.search_link_idx = spider_conn_first_link_idx(thd,
share->link_statuses, share->access_balances, spider.conn_link_idx,
share->link_count, SPIDER_LINK_STATUS_OK);
@@ -3747,6 +3684,24 @@ void *spider_bg_mon_action(
}
}
+/**
+ Returns a random (active) server with a maximum required link status
+
+ Calculate the sum of balances of all servers whose link status is at
+ most the specified status ("eligible"), generate a random number
+ less than this balance, then find the first server cumulatively
+ exceeding this balance
+
+ @param thd Connection used for generating a random number
+ @param link_statuses The link statuses of servers
+ @param access_balances The access balances of servers
+ @param conn_link_idx Array of indexes to servers
+ @param link_count Number of servers
+ @param link_status The maximum required link status
+ @retval Index to the found server
+ @retval -1 if no eligible servers
+ @retval -2 if out of memory
+*/
int spider_conn_first_link_idx(
THD *thd,
long *link_statuses,
@@ -3755,35 +3710,35 @@ int spider_conn_first_link_idx(
int link_count,
int link_status
) {
- int roop_count, active_links = 0;
- longlong balance_total = 0, balance_val;
+ int eligible_link_idx, eligible_links = 0;
+ longlong balance_total = 0, balance_threshold;
double rand_val;
- int *link_idxs, link_idx;
- long *balances;
+ int *link_idxs, result;
DBUG_ENTER("spider_conn_first_link_idx");
char *ptr;
- ptr = (char *) my_alloca((sizeof(int) * link_count) + (sizeof(long) * link_count));
+ /* Allocate memory for link_idxs */
+ ptr = (char *) my_alloca((sizeof(int) * link_count));
if (!ptr)
{
DBUG_PRINT("info",("spider out of memory"));
DBUG_RETURN(-2);
}
link_idxs = (int *) ptr;
- ptr += sizeof(int) * link_count;
- balances = (long *) ptr;
- for (roop_count = 0; roop_count < link_count; roop_count++)
+
+ /* Filter for eligible servers, store their indexes and calculate
+ the total balances */
+ for (int link_idx = 0; link_idx < link_count; link_idx++)
{
- DBUG_ASSERT((conn_link_idx[roop_count] - roop_count) % link_count == 0);
- if (link_statuses[conn_link_idx[roop_count]] <= link_status)
+ DBUG_ASSERT((conn_link_idx[link_idx] - link_idx) % link_count == 0);
+ if (link_statuses[conn_link_idx[link_idx]] <= link_status)
{
- link_idxs[active_links] = roop_count;
- balances[active_links] = access_balances[roop_count];
- balance_total += access_balances[roop_count];
- active_links++;
+ link_idxs[eligible_links] = link_idx;
+ balance_total += access_balances[link_idx];
+ eligible_links++;
}
}
- if (active_links == 0)
+ if (eligible_links == 0)
{
DBUG_PRINT("info",("spider all links are failed"));
my_afree(link_idxs);
@@ -3793,21 +3748,25 @@ int spider_conn_first_link_idx(
DBUG_PRINT("info",("spider thread_id=%lu", thd_get_thread_id(thd)));
rand_val = spider_rand(thd->variables.server_id + thd_get_thread_id(thd));
DBUG_PRINT("info",("spider rand_val=%f", rand_val));
- balance_val = (longlong) (rand_val * balance_total);
- DBUG_PRINT("info",("spider balance_val=%lld", balance_val));
- for (roop_count = 0; roop_count < active_links - 1; roop_count++)
- {
+ balance_threshold = (longlong) (rand_val * balance_total);
+ DBUG_PRINT("info",("spider balance_threshold=%lld", balance_threshold));
+ /* Since balance_threshold < total balance, this loop WILL break */
+ for (eligible_link_idx = 0;
+ eligible_link_idx < eligible_links;
+ eligible_link_idx++)
+ {
+ result = link_idxs[eligible_link_idx];
+ const long balance = access_balances[result];
DBUG_PRINT("info",("spider balances[%d]=%ld",
- roop_count, balances[roop_count]));
- if (balance_val < balances[roop_count])
+ link_idxs[eligible_link_idx], balance));
+ if (balance_threshold < balance)
break;
- balance_val -= balances[roop_count];
+ balance_threshold -= balance;
}
- DBUG_PRINT("info",("spider first link_idx=%d", link_idxs[roop_count]));
- link_idx = link_idxs[roop_count];
+ DBUG_PRINT("info",("spider first link_idx=%d", result));
my_afree(link_idxs);
- DBUG_RETURN(link_idx);
+ DBUG_RETURN(result);
}
int spider_conn_next_link_idx(
@@ -3842,6 +3801,17 @@ int spider_conn_next_link_idx(
DBUG_RETURN(tmp_link_idx);
}
+/**
+ Finds the next active server with a maximum required link status
+
+ @param link_statuses The statuses of servers
+ @param conn_link_idx The array of active servers
+ @param link_idx The index of the current active server
+ @param link_count The number of active servers
+ @param link_status The required maximum link status
+ @return The next active server whose link status is
+ at most the required one.
+*/
int spider_conn_link_idx_next(
long *link_statuses,
uint *conn_link_idx,
@@ -3854,6 +3824,8 @@ int spider_conn_link_idx_next(
link_idx++;
if (link_idx >= link_count)
break;
+ /* Asserts that the `link_idx`th active server is in the correct
+ "group" */
DBUG_ASSERT((conn_link_idx[link_idx] - link_idx) % link_count == 0);
} while (link_statuses[conn_link_idx[link_idx]] > link_status);
DBUG_PRINT("info",("spider link_idx=%d", link_idx));
diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc
index 0d6f05dfdbd..64b86722099 100644
--- a/storage/spider/spd_copy_tables.cc
+++ b/storage/spider/spd_copy_tables.cc
@@ -398,7 +398,7 @@ int spider_udf_get_copy_tgt_tables(
(error_num = spider_get_sys_tables_connect_info(
table_tables, tmp_share, 0, mem_root)) ||
(error_num = spider_get_sys_tables_link_status(
- table_tables, tmp_share, 0, mem_root)) ||
+ table_tables, tmp_share->link_statuses, mem_root)) ||
(error_num = spider_get_sys_tables_link_idx(
table_tables, &table_conn->link_idx, mem_root))
) {
diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h
index 3c7b3892c02..46dca8221b2 100644
--- a/storage/spider/spd_db_include.h
+++ b/storage/spider/spd_db_include.h
@@ -19,12 +19,19 @@
#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \
init_alloc_root(PSI_INSTRUMENT_ME, A, B, C, D)
+/** Maximum possible number of `SPIDER_DBTON`s available to use */
#define SPIDER_DBTON_SIZE 15
#ifndef SIZEOF_STORED_DOUBLE
#define SIZEOF_STORED_DOUBLE 8
#endif
+/**
+ Possible wrapper values, e.g. for `SPIDER_DBTON::wrapper` and
+ `SPIDER_SHARE::tgt_wrappers`.
+
+ fixme: change this to enum
+*/
#define SPIDER_DB_WRAPPER_MYSQL "mysql"
#define SPIDER_DB_WRAPPER_MARIADB "mariadb"
@@ -678,6 +685,8 @@ struct st_spider_db_request_key
class spider_db_util
{
public:
+ /** Same as the `SPIDER_DBTON::dbton_id` of the `SPIDER_DBTON`
+ containing this `spider_db_util` */
uint dbton_id;
spider_db_util() = default;
virtual ~spider_db_util() = default;
@@ -1678,7 +1687,10 @@ static const LEX_CSTRING maturity_name[] =
typedef struct st_spider_dbton
{
+ /** The index of this dbton in `spider_dbton` */
uint dbton_id;
+ /** The wrapper of this dbton, same possible values as each element
+ of `SPIDER_SHARE::tgt_wrappers` */
const char *wrapper;
enum spider_db_access_type db_access_type;
int (*init)();
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 3dd8db9e898..90b8ededd6c 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -307,6 +307,7 @@ bool spider_mariadb_support_direct_join(
DBUG_RETURN(TRUE);
}
+/** Available `SPIDER_DBTON`s */
SPIDER_DBTON spider_dbton_mysql = {
0,
SPIDER_DB_WRAPPER_MYSQL,
@@ -803,6 +804,7 @@ SPIDER_DB_ROW *spider_db_mbase_result::fetch_row_from_tmp_table(
DBUG_RETURN((SPIDER_DB_ROW *) &row);
}
+/* Fetches table status into `stat` */
int spider_db_mbase_result::fetch_table_status(
int mode,
ha_statistics &stat
@@ -2141,7 +2143,7 @@ int spider_db_mbase::exec_query(
db_conn->affected_rows, db_conn->insert_id,
db_conn->server_status, db_conn->warning_count);
if (spider_param_log_result_errors() >= 3)
- print_warnings(l_time);
+ fetch_and_print_warnings(l_time);
} else if (log_result_errors >= 4)
{
time_t cur_time = (time_t) time((time_t*) 0);
@@ -2223,76 +2225,63 @@ bool spider_db_mbase::is_xa_nota_error(
DBUG_RETURN(xa_nota);
}
-int spider_db_mbase::print_warnings(
- struct tm *l_time
-) {
+int spider_db_mbase::fetch_and_print_warnings(struct tm *l_time)
+{
int error_num = 0;
- DBUG_ENTER("spider_db_mbase::print_warnings");
+ DBUG_ENTER("spider_db_mbase::fetch_and_print_warnings");
DBUG_PRINT("info",("spider this=%p", this));
- if (db_conn->status == MYSQL_STATUS_READY)
+
+ if (spider_param_dry_access() || db_conn->status != MYSQL_STATUS_READY ||
+ db_conn->server_status & SERVER_MORE_RESULTS_EXISTS ||
+ !db_conn->warning_count)
+ DBUG_RETURN(0);
+
+ if (mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR,
+ SPIDER_SQL_SHOW_WARNINGS_LEN))
+ DBUG_RETURN(0);
+
+ MYSQL_RES *res= mysql_store_result(db_conn);
+ if (!res)
+ DBUG_RETURN(0);
+
+ uint num_fields= mysql_num_fields(res);
+ if (num_fields != 3)
{
- if (
- !(db_conn->server_status & SERVER_MORE_RESULTS_EXISTS) &&
- db_conn->warning_count
- ) {
- if (
- spider_param_dry_access() ||
- !mysql_real_query(db_conn, SPIDER_SQL_SHOW_WARNINGS_STR,
- SPIDER_SQL_SHOW_WARNINGS_LEN)
- ) {
- MYSQL_RES *res = NULL;
- MYSQL_ROW row = NULL;
- uint num_fields;
- if (
- spider_param_dry_access() ||
- !(res = mysql_store_result(db_conn)) ||
- !(row = mysql_fetch_row(res))
- ) {
- if (mysql_errno(db_conn))
- {
- if (res)
- mysql_free_result(res);
- DBUG_RETURN(0);
- }
- /* no record is ok */
- }
- num_fields = mysql_num_fields(res);
- if (num_fields != 3)
- {
- mysql_free_result(res);
- DBUG_RETURN(0);
- }
- if (l_time)
- {
- while (row)
- {
- fprintf(stderr, "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] "
- "from [%s] %ld to %ld: %s %s %s\n",
+ mysql_free_result(res);
+ DBUG_RETURN(0);
+ }
+
+ MYSQL_ROW row= mysql_fetch_row(res);
+ if (l_time)
+ {
+ while (row)
+ {
+ fprintf(stderr,
+ "%04d%02d%02d %02d:%02d:%02d [WARN SPIDER RESULT] from [%s] %ld "
+ "to %ld: %s %s %s\n",
l_time->tm_year + 1900, l_time->tm_mon + 1, l_time->tm_mday,
- l_time->tm_hour, l_time->tm_min, l_time->tm_sec,
- conn->tgt_host, (ulong) db_conn->thread_id,
- (ulong) current_thd->thread_id, row[0], row[1], row[2]);
- row = mysql_fetch_row(res);
- }
- } else {
- while (row)
- {
- DBUG_PRINT("info",("spider row[0]=%s", row[0]));
- DBUG_PRINT("info",("spider row[1]=%s", row[1]));
- DBUG_PRINT("info",("spider row[2]=%s", row[2]));
- longlong res_num =
- (longlong) my_strtoll10(row[1], (char**) NULL, &error_num);
- DBUG_PRINT("info",("spider res_num=%lld", res_num));
- my_printf_error((int) res_num, row[2], MYF(0));
- error_num = (int) res_num;
- row = mysql_fetch_row(res);
- }
- }
- if (res)
- mysql_free_result(res);
- }
+ l_time->tm_hour, l_time->tm_min, l_time->tm_sec, conn->tgt_host,
+ (ulong) db_conn->thread_id, (ulong) current_thd->thread_id, row[0],
+ row[1], row[2]);
+ row= mysql_fetch_row(res);
+ }
+ } else {
+ while (row)
+ {
+ DBUG_PRINT("info",("spider row[0]=%s", row[0]));
+ DBUG_PRINT("info",("spider row[1]=%s", row[1]));
+ DBUG_PRINT("info",("spider row[2]=%s", row[2]));
+ longlong res_num =
+ (longlong) my_strtoll10(row[1], (char**) NULL, &error_num);
+ DBUG_PRINT("info",("spider res_num=%lld", res_num));
+ my_printf_error((int) res_num, row[2], MYF(0));
+ error_num = (int) res_num;
+ row = mysql_fetch_row(res);
}
}
+
+ mysql_free_result(res);
+
DBUG_RETURN(error_num);
}
@@ -5315,6 +5304,7 @@ int spider_db_mbase_util::append_sql_mode(
DBUG_RETURN(0);
}
+/** Append `set session time_zone = ...` to a query string */
int spider_db_mbase_util::append_time_zone(
spider_string *str,
Time_zone *time_zone
@@ -5333,6 +5323,14 @@ int spider_db_mbase_util::append_time_zone(
DBUG_RETURN(0);
}
+/**
+ Append a query for self-referencing check
+
+ The query is setting a user variable `@spider_lc$target_table_path`
+ to the value of `"$spider_unique_id$spider_table_path-"`, where
+ $target_table_path is the path to the data node table ("to"), and
+ $spider_table_path the path to the spider table ("from")
+*/
int spider_db_mbase_util::append_loop_check(
spider_string *str,
SPIDER_CONN *conn
@@ -13388,6 +13386,88 @@ int spider_mbase_handler::sts_mode_exchange(
DBUG_RETURN(sts_mode);
}
+/** Set the session lock wait time out */
+int spider_db_mbase::set_lock_wait_timeout(uint timeout)
+{
+ String query(0);
+ int error_num;
+ DBUG_ENTER("spider_db_set_lock_wait_timeout");
+ query.append(STRING_WITH_LEN(
+ "set @old_lock_wait_timeout=@@session.lock_wait_timeout;"
+ "set session lock_wait_timeout="));
+ query.append_ulonglong(timeout);
+ query.append(STRING_WITH_LEN(";"));
+ if ((error_num = exec_query(query.c_ptr(), query.length(), -1)))
+ DBUG_RETURN(error_num);
+ spider_db_result *result;
+ do {
+ st_spider_db_request_key request_key= {1, 1, NULL, 1, NULL};
+ if ((result = conn->db_conn->store_result(NULL, &request_key,
+ &error_num)))
+ {
+ result->free_result();
+ delete result;
+ } else if ((error_num = conn->db_conn->get_errno()))
+ break;
+ } while (!(error_num = conn->db_conn->next_result()));
+ DBUG_RETURN(0);
+}
+
+/** Reset the session lock wait time out */
+int spider_db_mbase::reset_lock_wait_timeout()
+{
+ const LEX_CSTRING query = {STRING_WITH_LEN(
+ "set session lock_wait_timeout=@old_lock_wait_timeout;")};
+ int error_num;
+ DBUG_ENTER("spider_db_set_lock_wait_timeout");
+ if ((error_num = exec_query(query.str, query.length, -1)))
+ DBUG_RETURN(error_num);
+ spider_db_result *result;
+ do {
+ st_spider_db_request_key request_key= {1, 1, NULL, 1, NULL};
+ if ((result = conn->db_conn->store_result(NULL, &request_key,
+ &error_num)))
+ {
+ result->free_result();
+ delete result;
+ } else if ((error_num = conn->db_conn->get_errno()))
+ break;
+ } while (!(error_num= conn->db_conn->next_result()));
+ DBUG_RETURN(0);
+}
+
+/** FIXME: refactor more functions to use spider_setup_for_query() and
+spider_teardown_after_query(). */
+void spider_setup_for_query(ha_spider *spider, SPIDER_CONN *conn, int link_idx)
+{
+ pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
+ pthread_mutex_lock(&conn->mta_conn_mutex);
+ SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ conn->need_mon= &spider->need_mons[link_idx];
+ DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
+ conn->mta_conn_mutex_lock_already= TRUE;
+ conn->mta_conn_mutex_unlock_later= TRUE;
+ conn->disable_connect_retry= TRUE;
+}
+
+int spider_teardown_after_query(SPIDER_CONN *conn, int error_num, bool clear)
+{
+ conn->disable_connect_retry= FALSE;
+ DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
+ DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
+ conn->mta_conn_mutex_lock_already= FALSE;
+ conn->mta_conn_mutex_unlock_later= FALSE;
+ if (clear)
+ {
+ SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
+ pthread_mutex_unlock(&conn->mta_conn_mutex);
+ }
+ return error_num;
+}
+/**
+ Executes show table status query and stores results in share->stat
+*/
int spider_mbase_handler::show_table_status(
int link_idx,
int sts_mode,
@@ -13397,329 +13477,136 @@ int spider_mbase_handler::show_table_status(
SPIDER_CONN *conn = spider->conns[link_idx];
SPIDER_DB_RESULT *res;
SPIDER_SHARE *share = spider->share;
- uint pos = (2 * spider->conn_link_idx[link_idx]);
+ const uint pos = 2 * spider->conn_link_idx[link_idx] +
+ (sts_mode == 1 ? 0 : 1);
ulonglong auto_increment_value = 0;
DBUG_ENTER("spider_mbase_handler::show_table_status");
DBUG_PRINT("info",("spider sts_mode=%d", sts_mode));
- if (sts_mode == 1)
+ spider_setup_for_query(spider, conn, link_idx);
+ spider_conn_set_timeout_from_share(
+ conn, link_idx, spider->wide_handler->trx->thd, share);
+ if ((error_num = spider_db_set_names(spider, conn, link_idx)) ||
+ (error_num =
+ ((spider_db_mbase *) conn->db_conn)->set_lock_wait_timeout(1)) ||
+ /* Executes the `show table status` query */
+ (spider_db_query(
+ conn,
+ mysql_share->show_table_status[pos].ptr(),
+ mysql_share->show_table_status[pos].length(),
+ -1,
+ &spider->need_mons[link_idx]) &&
+ (error_num = spider_db_errorno(conn))))
{
- pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- conn->disable_connect_retry = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- mysql_share->show_table_status[0 + pos].ptr(),
- mysql_share->show_table_status[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
+ if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
+ !conn->disable_reconnect)
+ {
+ /* retry */
+ if ((error_num = spider_db_ping(spider, conn, link_idx)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ if ((error_num = spider_db_set_names(spider, conn, link_idx)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ spider_conn_set_timeout_from_share(conn, link_idx,
+ spider->wide_handler->trx->thd,
+ share);
+ if ((error_num =
+ ((spider_db_mbase *) conn->db_conn)->set_lock_wait_timeout(1)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ if (spider_db_query(
+ conn,
+ mysql_share->show_table_status[pos].ptr(),
+ mysql_share->show_table_status[pos].length(),
+ -1,
+ &spider->need_mons[link_idx])
) {
- /* retry */
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (spider_db_query(
- conn,
- mysql_share->show_table_status[0 + pos].ptr(),
- mysql_share->show_table_status[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
+ spider_teardown_after_query(conn, 0, false);
+ DBUG_RETURN(spider_db_errorno(conn));
}
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id;
- request_key.query_id = spider->wide_handler->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (spider_param_dry_access())
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(0);
- }
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
+ } else
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ }
+ st_spider_db_request_key request_key = {
+ spider->wide_handler->trx->spider_thread_id,
+ spider->wide_handler->trx->thd->query_id, spider, 1, NULL};
+ if (spider_param_dry_access())
+ DBUG_RETURN(spider_teardown_after_query(conn, 0, true));
+ if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
+ {
+ if (sts_mode == 1) /* get from status table */
{
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
if (error_num)
- {
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- else if ((error_num = spider_db_errorno(conn)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ spider_teardown_after_query(conn, 0, false);
+ if ((error_num = spider_db_errorno(conn)))
DBUG_RETURN(error_num);
- else {
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
+ else
+ {
+ my_printf_error(
+ ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
DBUG_RETURN(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM);
}
- }
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- error_num = res->fetch_table_status(
- sts_mode,
- share->stat
- );
- auto_increment_value = share->stat.auto_increment_value;
- res->free_result();
- delete res;
- if (error_num)
+ } else /* get from information schema */
{
- switch (error_num)
- {
- case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
- ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
- my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
- ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- default:
- break;
- }
- DBUG_RETURN(error_num);
- }
- } else {
- pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- conn->disable_connect_retry = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- mysql_share->show_table_status[1 + pos].ptr(),
- mysql_share->show_table_status[1 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
- ) {
- /* retry */
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (spider_db_query(
- conn,
- mysql_share->show_table_status[1 + pos].ptr(),
- mysql_share->show_table_status[1 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id;
- request_key.query_id = spider->wide_handler->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (spider_param_dry_access())
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(0);
- }
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
- {
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- if (error_num || (error_num = spider_db_errorno(conn)))
+ spider_teardown_after_query(conn, error_num, false);
+ if (error_num || (error_num= spider_db_errorno(conn)))
DBUG_RETURN(error_num);
else
DBUG_RETURN(ER_QUERY_ON_FOREIGN_DATA_SOURCE);
}
- conn->disable_connect_retry = FALSE;
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- error_num = res->fetch_table_status(
- sts_mode,
- share->stat
- );
- auto_increment_value = share->stat.auto_increment_value;
- res->free_result();
- delete res;
- if (error_num)
+ }
+ spider_teardown_after_query(conn, 0, true);
+ /* Fetches query results into share->stat. */
+ error_num = res->fetch_table_status(sts_mode, share->stat);
+ auto_increment_value = share->stat.auto_increment_value;
+ res->free_result();
+ delete res;
+ if (error_num)
+ {
+ switch (error_num)
{
- switch (error_num)
- {
- case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
- ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
- my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
- ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- default:
- break;
- }
- DBUG_RETURN(error_num);
+ case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
+ my_printf_error(
+ ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
+ ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
+ mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
+ break;
+ case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
+ my_printf_error(
+ ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
+ ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
+ mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
+ break;
+ default:
+ break;
}
+ DBUG_RETURN(error_num);
}
- if ((error_num = ((spider_db_mbase *) conn->db_conn)->print_warnings(NULL)))
+ if ((error_num = ((spider_db_mbase *) conn->db_conn)->fetch_and_print_warnings(NULL)))
{
+ ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout();
+ if (error_num == ER_LOCK_WAIT_TIMEOUT)
+ {
+ error_num = ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM;
+ my_printf_error(
+ ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM,
+ ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_STR, MYF(0),
+ mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
+ }
DBUG_RETURN(error_num);
}
+ if ((error_num =
+ ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout()))
+ DBUG_RETURN(error_num);
if (share->static_records_for_status != -1)
- {
share->stat.records = (ha_rows) share->static_records_for_status;
- }
if (share->static_mean_rec_length != -1)
- {
share->stat.mean_rec_length = (ulong) share->static_mean_rec_length;
- }
if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value)
{
share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value;
@@ -13746,314 +13633,105 @@ int spider_mbase_handler::show_index(
SPIDER_SHARE *share = spider->share;
TABLE *table = spider->get_table();
SPIDER_DB_RESULT *res;
- int roop_count;
- longlong *tmp_cardinality;
- uint pos = (2 * spider->conn_link_idx[link_idx]);
+ int field;
+ longlong *tmp_crd;
+ const uint pos = 2 * spider->conn_link_idx[link_idx] +
+ (crd_mode == 1 ? 0 : 1);
DBUG_ENTER("spider_mbase_handler::show_index");
DBUG_PRINT("info",("spider crd_mode=%d", crd_mode));
- if (crd_mode == 1)
+ spider_setup_for_query(spider, conn, link_idx);
+ spider_conn_set_timeout_from_share(conn, link_idx,
+ spider->wide_handler->trx->thd, share);
+ if ((error_num = spider_db_set_names(spider, conn, link_idx)) ||
+ (error_num =
+ ((spider_db_mbase *) conn->db_conn)->set_lock_wait_timeout(1)) ||
+ (spider_db_query(
+ conn,
+ mysql_share->show_index[pos].ptr(),
+ mysql_share->show_index[pos].length(),
+ -1,
+ &spider->need_mons[link_idx]) &&
+ (error_num = spider_db_errorno(conn))))
{
- pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- mysql_share->show_index[0 + pos].ptr(),
- mysql_share->show_index[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
- ) {
- /* retry */
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (spider_db_query(
- conn,
- mysql_share->show_index[0 + pos].ptr(),
- mysql_share->show_index[0 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id;
- request_key.query_id = spider->wide_handler->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
- {
- if (error_num || (error_num = spider_db_errorno(conn)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- /* no record is ok */
- }
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- if (res)
- {
- error_num = res->fetch_table_cardinality(
- crd_mode,
- table,
- share->cardinality,
- share->cardinality_upd,
- share->bitmap_size
- );
- }
- for (roop_count = 0, tmp_cardinality = share->cardinality;
- roop_count < (int) table->s->fields;
- roop_count++, tmp_cardinality++)
- {
- if (!spider_bit_is_set(share->cardinality_upd, roop_count))
- {
- DBUG_PRINT("info",
- ("spider uninitialized column cardinality id=%d", roop_count));
- *tmp_cardinality = -1;
- }
- }
- if (res)
- {
- res->free_result();
- delete res;
- }
- if (error_num)
- {
- switch (error_num)
- {
- case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
- ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
- my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
- ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- default:
- break;
- }
- DBUG_RETURN(error_num);
- }
- } else {
- pthread_mutex_assert_not_owner(&conn->mta_conn_mutex);
- pthread_mutex_lock(&conn->mta_conn_mutex);
- SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
- conn->need_mon = &spider->need_mons[link_idx];
- DBUG_ASSERT(!conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(!conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = TRUE;
- conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (
- (error_num = spider_db_set_names(spider, conn, link_idx)) ||
- (
- spider_db_query(
- conn,
- mysql_share->show_index[1 + pos].ptr(),
- mysql_share->show_index[1 + pos].length(),
- -1,
- &spider->need_mons[link_idx]) &&
- (error_num = spider_db_errorno(conn))
- )
- ) {
- if (
- error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
- !conn->disable_reconnect
- ) {
- /* retry */
- if ((error_num = spider_db_ping(spider, conn, link_idx)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- if ((error_num = spider_db_set_names(spider, conn, link_idx)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- spider_conn_set_timeout_from_share(conn, link_idx,
- spider->wide_handler->trx->thd,
- share);
- if (spider_db_query(
- conn,
- mysql_share->show_index[1 + pos].ptr(),
- mysql_share->show_index[1 + pos].length(),
- -1,
- &spider->need_mons[link_idx])
- ) {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- DBUG_RETURN(spider_db_errorno(conn));
- }
- } else {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- }
- st_spider_db_request_key request_key;
- request_key.spider_thread_id = spider->wide_handler->trx->spider_thread_id;
- request_key.query_id = spider->wide_handler->trx->thd->query_id;
- request_key.handler = spider;
- request_key.request_id = 1;
- request_key.next = NULL;
- if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)))
+ if (error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
+ !conn->disable_reconnect)
{
- if (error_num || (error_num = spider_db_errorno(conn)))
- {
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- DBUG_RETURN(error_num);
- }
- /* no record is ok */
- }
- DBUG_ASSERT(conn->mta_conn_mutex_lock_already);
- DBUG_ASSERT(conn->mta_conn_mutex_unlock_later);
- conn->mta_conn_mutex_lock_already = FALSE;
- conn->mta_conn_mutex_unlock_later = FALSE;
- SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
- pthread_mutex_unlock(&conn->mta_conn_mutex);
- if (res)
- {
- error_num = res->fetch_table_cardinality(
- crd_mode,
- table,
- share->cardinality,
- share->cardinality_upd,
- share->bitmap_size
- );
- }
- for (roop_count = 0, tmp_cardinality = share->cardinality;
- roop_count < (int) table->s->fields;
- roop_count++, tmp_cardinality++)
- {
- if (!spider_bit_is_set(share->cardinality_upd, roop_count))
+ /* retry */
+ if ((error_num = spider_db_ping(spider, conn, link_idx)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ if ((error_num = spider_db_set_names(spider, conn, link_idx)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ spider_conn_set_timeout_from_share(conn, link_idx,
+ spider->wide_handler->trx->thd,
+ share);
+ if ((error_num =
+ ((spider_db_mbase *) conn->db_conn)->set_lock_wait_timeout(1)))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ if (spider_db_query(
+ conn,
+ mysql_share->show_index[pos].ptr(),
+ mysql_share->show_index[pos].length(),
+ -1,
+ &spider->need_mons[link_idx]))
{
- DBUG_PRINT("info",
- ("spider uninitialized column cardinality id=%d", roop_count));
- *tmp_cardinality = -1;
+ spider_teardown_after_query(conn, 0, false);
+ DBUG_RETURN(spider_db_errorno(conn));
}
- }
- if (res)
- {
- res->free_result();
- delete res;
- }
- if (error_num)
+ } else
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ }
+ st_spider_db_request_key request_key = {
+ spider->wide_handler->trx->spider_thread_id,
+ spider->wide_handler->trx->thd->query_id, spider, 1, NULL};
+ /* no record is ok */
+ if (!(res = conn->db_conn->store_result(NULL, &request_key, &error_num)) &&
+ (error_num || (error_num = spider_db_errorno(conn))))
+ DBUG_RETURN(spider_teardown_after_query(conn, error_num, true));
+ spider_teardown_after_query(conn, 0, true);
+ if (res)
+ error_num = res->fetch_table_cardinality(
+ crd_mode, table, share->cardinality, share->cardinality_upd,
+ share->bitmap_size);
+ for (field = 0, tmp_crd = share->cardinality;
+ field < (int) table->s->fields;
+ field++, tmp_crd++)
+ {
+ if (!spider_bit_is_set(share->cardinality_upd, field))
{
- switch (error_num)
- {
- case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
- my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
- ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
- my_printf_error(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
- ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
- mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
- mysql_share->table_names_str[spider->conn_link_idx[
- link_idx]].ptr());
- break;
- default:
- break;
- }
- DBUG_RETURN(error_num);
+ DBUG_PRINT("info",
+ ("spider uninitialized column cardinality id=%d", field));
+ *tmp_crd = -1;
}
}
- DBUG_RETURN(0);
+ if (res)
+ {
+ res->free_result();
+ delete res;
+ }
+ switch (error_num)
+ {
+ case ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM:
+ my_printf_error(
+ ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
+ ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
+ mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
+ break;
+ case ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM:
+ my_printf_error(
+ ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM,
+ ER_SPIDER_INVALID_REMOTE_TABLE_INFO_STR, MYF(0),
+ mysql_share->db_names_str[spider->conn_link_idx[link_idx]].ptr(),
+ mysql_share->table_names_str[spider->conn_link_idx[link_idx]].ptr());
+ break;
+ default:
+ break;
+ }
+ if (!error_num)
+ error_num = ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout();
+ else
+ ((spider_db_mbase *) conn->db_conn)->reset_lock_wait_timeout();
+ DBUG_RETURN(error_num);
}
int spider_mbase_handler::simple_action(
diff --git a/storage/spider/spd_db_mysql.h b/storage/spider/spd_db_mysql.h
index aa70d28e0ad..ba521a58fb8 100644
--- a/storage/spider/spd_db_mysql.h
+++ b/storage/spider/spd_db_mysql.h
@@ -434,9 +434,7 @@ public:
bool is_xa_nota_error(
int error_num
);
- int print_warnings(
- struct tm *l_time
- );
+ int fetch_and_print_warnings(struct tm *l_time);
spider_db_result *store_result(
spider_db_result_buffer **spider_res_buf,
st_spider_db_request_key *request_key,
@@ -515,6 +513,12 @@ public:
int wait_timeout,
int *need_mon
);
+
+ /** Set the global lock wait time out */
+ int set_lock_wait_timeout(uint timeout);
+ /** Reset the global lock wait time out */
+ int reset_lock_wait_timeout();
+
bool set_sql_mode_in_bulk_sql();
int set_sql_mode(
sql_mode_t sql_mode,
diff --git a/storage/spider/spd_err.h b/storage/spider/spd_err.h
index e9a4a41946e..e2098d4e751 100644
--- a/storage/spider/spd_err.h
+++ b/storage/spider/spd_err.h
@@ -134,6 +134,8 @@
#define ER_SPIDER_SAME_SERVER_LINK_STR2 "Host:%s and Port:%ld aim self server. Please change spider_same_server_link parameter if this link is required."
#define ER_SPIDER_CANT_NUM 12721
#define ER_SPIDER_CANT_STR1 "Can't %s%d"
+#define ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM 12722
+#define ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_STR "Table %s.%s open lock wait timeout. Please check for self-reference."
#define ER_SPIDER_COND_SKIP_NUM 12801
#define ER_SPIDER_UNKNOWN_NUM 12500
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index 35f348ca999..10675aee3ef 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -148,9 +148,14 @@ typedef start_new_trans *SPIDER_Open_tables_backup;
#define spider_bit_is_set(BITMAP, BIT) \
(uint) ((BITMAP)[(BIT) / 8] & (1 << ((BIT) & 7)))
+/* Change status of the remote backend server link. */
+/* 0 Doesn't change status. */
#define SPIDER_LINK_STATUS_NO_CHANGE 0
+/* 1 Changes status to OK. */
#define SPIDER_LINK_STATUS_OK 1
+/* 2 Changes status to RECOVERY. */
#define SPIDER_LINK_STATUS_RECOVERY 2
+/* 3 Changes status to no more in group communication. */
#define SPIDER_LINK_STATUS_NG 3
#define SPIDER_LINK_MON_OK 0
@@ -699,22 +704,30 @@ typedef struct st_spider_share
char *table_name;
uint table_name_length;
uint use_count;
+ /**
+ Probably equals `active_link_count`. See also commit ddff602 of
+ https://github.com/nayuta-yanagisawa/spider-history
+
+ FIXME: consider removing it and using `active_link_count` instead.
+ */
uint link_count;
+ /* Number of all links, i.e. all remote servers for the spider
+ table. */
uint all_link_count;
uint link_bitmap_size;
pthread_mutex_t mutex;
pthread_mutex_t sts_mutex;
pthread_mutex_t crd_mutex;
-/*
- pthread_mutex_t auto_increment_mutex;
-*/
TABLE_SHARE *table_share;
SPIDER_LGTM_TBLHND_SHARE *lgtm_tblhnd_share;
my_hash_value_type table_name_hash_value;
my_hash_value_type table_path_hash_value;
+ /* Whether the share has been initialised */
volatile bool init;
+ /* Whether an error occurred in initialisation of this share */
volatile bool init_error;
+ /* The time of the initialisation error */
volatile time_t init_error_time;
volatile bool link_status_init;
uchar *table_mon_mutex_bitmap;
@@ -770,10 +783,6 @@ typedef struct st_spider_share
MEM_ROOT mem_root;
-/*
- volatile bool auto_increment_init;
- volatile ulonglong auto_increment_lclval;
-*/
ha_statistics stat;
longlong static_records_for_status;
@@ -788,17 +797,27 @@ typedef struct st_spider_share
longlong additional_table_flags;
bool have_recovery_link;
+ /** See `mysql_sysvar_sts_bg_mode` */
int sts_bg_mode;
+ /** See `mysql_sysvar_sts_interval` */
double sts_interval;
+ /** See `mysql_sysvar_sts_mode` */
int sts_mode;
+ /** See `mysql_sysvar_sts_sync` */
int sts_sync;
int store_last_sts;
+ /** See `mysql_sysvar_load_sts_at_startup` */
int load_sts_at_startup;
+ /** See `mysql_sysvar_crd_bg_mode` */
int crd_bg_mode;
+ /** See `mysql_sysvar_crd_interval` */
double crd_interval;
+ /** See `mysql_sysvar_crd_mode` */
int crd_mode;
+ /** See `mysql_sysvar_crd_sync` */
int crd_sync;
int store_last_crd;
+ /** See `mysql_sysvar_load_crd_at_startup` */
int load_crd_at_startup;
int crd_type;
double crd_weight;
@@ -836,6 +855,7 @@ typedef struct st_spider_share
longlong bgs_second_read;
longlong first_read;
longlong second_read;
+ /** See `mysql_sysvar_auto_increment_mode` */
int auto_increment_mode;
int use_table_charset;
int use_pushdown_udf;
@@ -846,6 +866,8 @@ typedef struct st_spider_share
int read_only_mode;
int error_read_mode;
int error_write_mode;
+ /* Number of active remote servers, for use in load balancing read
+ connections */
int active_link_count;
#ifdef HA_CAN_FORCE_BULK_UPDATE
int force_bulk_update;
@@ -868,6 +890,8 @@ typedef struct st_spider_share
char **tgt_usernames;
char **tgt_passwords;
char **tgt_sockets;
+ /** The wrapper of target servers, each element has the same
+ possible values as `SPIDER_DBTON::wrapper` */
char **tgt_wrappers;
char **tgt_ssl_cas;
char **tgt_ssl_capaths;
@@ -885,6 +909,7 @@ typedef struct st_spider_share
char **conn_keys;
long *tgt_ports;
long *tgt_ssl_vscs;
+ /* See SPIDER_LINK_STATUS_* in spd_include.h */
long *link_statuses;
long *monitoring_bg_flag;
long *monitoring_bg_kind;
@@ -897,6 +922,7 @@ typedef struct st_spider_share
long *connect_timeouts;
long *net_read_timeouts;
long *net_write_timeouts;
+ /* Connection load balancing integer weight */
long *access_balances;
long *bka_table_name_types;
long *strict_group_bys;
@@ -988,10 +1014,16 @@ typedef struct st_spider_share
uint bka_table_name_types_length;
uint strict_group_bys_length;
- /* for dbton */
+ /*
+ For dbton. A `SPIDER_SHARE` uses all `SPIDER_DBTON`s with the same
+ wrappers as any its `tgt_wrappers`
+ */
+ /* Specifies which dbtons of the `spider_dbton` to use */
uchar dbton_bitmap[spider_bitmap_size(SPIDER_DBTON_SIZE)];
spider_db_share *dbton_share[SPIDER_DBTON_SIZE];
+ /* Number of `SPIDER_DBTON`s used */
uint use_dbton_count;
+ /* Index of each `SPIDER_DBTON` in `spider_dbton` to use */
uint use_dbton_ids[SPIDER_DBTON_SIZE];
uint dbton_id_to_seq[SPIDER_DBTON_SIZE];
uint use_sql_dbton_count;
@@ -1008,14 +1040,23 @@ typedef struct st_spider_link_pack
int link_idx;
} SPIDER_LINK_PACK;
+/** A struct storing the initialisation error of a table. All
+instances are in `spider_init_error_tables` */
typedef struct st_spider_init_error_table
{
+ /* The associated table name */
char *table_name;
+ /* Length of the associated table name */
uint table_name_length;
+ /* Hash value of the associated table name for lookup */
my_hash_value_type table_name_hash_value;
+ /* Whether the error has a message */
bool init_error_with_message;
+ /* The error message */
char init_error_msg[MYSQL_ERRMSG_SIZE];
+ /* The error code */
volatile int init_error;
+ /* The error time */
volatile time_t init_error_time;
} SPIDER_INIT_ERROR_TABLE;
diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc
index 0a5d881749c..dfd98b9fbc0 100644
--- a/storage/spider/spd_param.cc
+++ b/storage/spider/spd_param.cc
@@ -1771,7 +1771,7 @@ int spider_param_sts_mode(
/*
-1 :use table parameter
0 :No synchronization.
- 1 :Table state is synchronized when opening a table.
+ 1 :Table stat is synchronized when opening a table.
Then no synchronization.
2 :Synchronization.
*/
diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h
index 6abdca43492..a7573a6fb29 100644
--- a/storage/spider/spd_param.h
+++ b/storage/spider/spd_param.h
@@ -316,7 +316,6 @@ my_bool spider_param_index_hint_pushdown(
);
uint spider_param_max_connections();
uint spider_param_conn_wait_timeout();
-uint spider_param_internal_lock_wait_timeout();
uint spider_param_log_result_errors();
uint spider_param_log_result_error_with_sql();
uint spider_param_internal_xa_id_type(
diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc
index 3de30e6a80b..056c21e07ec 100644
--- a/storage/spider/spd_ping_table.cc
+++ b/storage/spider/spd_ping_table.cc
@@ -505,7 +505,7 @@ SPIDER_TABLE_MON_LIST *spider_get_ping_table_tgt(
(*error_num = spider_get_sys_tables_connect_info(
table_tables, tmp_share, 0, &mem_root)) ||
(*error_num = spider_get_sys_tables_link_status(
- table_tables, tmp_share, 0, &mem_root))
+ table_tables, tmp_share->link_statuses, &mem_root))
) {
table_tables->file->print_error(*error_num, MYF(0));
goto error;
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index b42215a2da3..7b96c483d5e 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -979,6 +979,16 @@ void spider_store_xa_member_info(
DBUG_VOID_RETURN;
}
+/**
+ Stores the DB and table names in a table
+
+ If `name` starts with "./", separates out db and table names from
+ `name`. Otherwise stores empty strings as names
+
+ @param table The table to store the info
+ @param name The name of the table
+ @param name_length The length of the name
+*/
void spider_store_tables_name(
TABLE *table,
const char *name,
@@ -1443,6 +1453,12 @@ void spider_store_binlog_pos_gtid(
DBUG_VOID_RETURN;
}
+/**
+ Stores sts info in the spider sts table
+
+ Stores all fields except the db name and table name, which are
+ stored in `spider_store_tables_name()`.
+*/
void spider_store_table_sts_info(
TABLE *table,
ha_statistics *stat
@@ -1595,6 +1611,18 @@ int spider_insert_sys_table(
DBUG_RETURN(error_num);
}
+/**
+ Inserts or updates a row in the spider sts system table
+
+ @param table The spider sts system table
+ @param name The name of the spider table whose stat will be
+ inserted / updated in the sts table
+ @param name_length Length of the name
+ @param stat The stat of the spider table that will be
+ inserted / updated in the sts table
+
+ @retval 0 or error
+*/
int spider_insert_or_update_table_sts(
TABLE *table,
const char *name,
@@ -2642,31 +2670,22 @@ int spider_get_sys_tables_monitoring_binlog_pos_at_failing(
DBUG_RETURN(error_num);
}
-int spider_get_sys_tables_link_status(
- TABLE *table,
- SPIDER_SHARE *share,
- int link_idx,
- MEM_ROOT *mem_root
-) {
- char *ptr;
- int error_num = 0;
- DBUG_ENTER("spider_get_sys_tables_link_status");
- if ((ptr = get_field(mem_root, table->field[SPIDER_TABLES_LINK_STATUS_POS])))
- {
- share->link_statuses[link_idx] =
- (long) my_strtoll10(ptr, (char**) NULL, &error_num);
- } else
- share->link_statuses[link_idx] = 1;
- DBUG_PRINT("info",("spider link_statuses[%d]=%ld",
- link_idx, share->link_statuses[link_idx]));
- DBUG_RETURN(error_num);
-}
-
+/**
+ Reads a table field and updates a link_status of a spider share
+
+ @param table The system table (`spider_tables` table) to read the
+ field from
+ @param share The share to update its link status with
+ @param link_idx Which link status to update
+ @param mem_root MEM_ROOT for allocating
+ @reval 0 for success, or error num
+*/
int spider_get_sys_tables_link_status(
TABLE *table,
long *link_status,
MEM_ROOT *mem_root
-) {
+)
+{
char *ptr;
int error_num = 0;
DBUG_ENTER("spider_get_sys_tables_link_status");
@@ -2674,7 +2693,6 @@ int spider_get_sys_tables_link_status(
*link_status = (long) my_strtoll10(ptr, (char**) NULL, &error_num);
else
*link_status = 1;
- DBUG_PRINT("info",("spider link_statuses=%ld", *link_status));
DBUG_RETURN(error_num);
}
@@ -2716,6 +2734,14 @@ int spider_get_sys_tables_static_link_id(
DBUG_RETURN(error_num);
}
+/**
+ Reads the table status from the system sts table
+
+ The result is set into `stat`
+
+ @param table The system sts table
+ @param stat The stat to read the table status into
+*/
void spider_get_sys_table_sts_info(
TABLE *table,
ha_statistics *stat
@@ -3173,6 +3199,15 @@ int spider_get_sys_link_mon_connect_info(
DBUG_RETURN(error_num);
}
+/**
+ Reads link statuses from the spider_tables system table into a
+ spider share
+
+ @param table The table to read from
+ @param share The spider share
+ @param mem_root MEM_ROOT for allocating
+ @reval 0 for success, or error code
+*/
int spider_get_link_statuses(
TABLE *table,
SPIDER_SHARE *share,
@@ -3191,14 +3226,10 @@ int spider_get_link_statuses(
{
if (
(error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE)
- ) {
-/*
- table->file->print_error(error_num, MYF(0));
-*/
+ )
DBUG_RETURN(error_num);
- }
- } else if ((error_num =
- spider_get_sys_tables_link_status(table, share, roop_count, mem_root)))
+ } else if ((error_num = spider_get_sys_tables_link_status(
+ table, &share->link_statuses[roop_count], mem_root)))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num);
@@ -3207,6 +3238,16 @@ int spider_get_link_statuses(
DBUG_RETURN(0);
}
+/**
+ Inserts or updates status of a table into the system sts table
+
+ @param thd Connection
+ @param name Name of the table whose status will be stored
+ @param name_length Length of `name`
+ @param stat The table status that will be stored into the
+ system sts table
+ @reval 0 for success, or error code
+*/
int spider_sys_insert_or_update_table_sts(
THD *thd,
const char *name,
@@ -3345,6 +3386,14 @@ error:
DBUG_RETURN(error_num);
}
+/**
+ Reads table status of a table from the system sts table.
+
+ @param thd Connection
+ @param name The name of the table for which to read status of
+ @param name_length The length of `name`
+ @param stat The struct to read the status into
+*/
int spider_sys_get_table_sts(
THD *thd,
const char *name,
diff --git a/storage/spider/spd_sys_table.h b/storage/spider/spd_sys_table.h
index 0ad98893322..6cb6c3957a7 100644
--- a/storage/spider/spd_sys_table.h
+++ b/storage/spider/spd_sys_table.h
@@ -439,13 +439,6 @@ int spider_get_sys_tables_monitoring_binlog_pos_at_failing(
int spider_get_sys_tables_link_status(
TABLE *table,
- SPIDER_SHARE *share,
- int link_idx,
- MEM_ROOT *mem_root
-);
-
-int spider_get_sys_tables_link_status(
- TABLE *table,
long *link_status,
MEM_ROOT *mem_root
);
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index f8ebb9618e0..327d4a30a0b 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -122,6 +122,7 @@ static pthread_mutex_t *spd_LOCK_server_started;
static pthread_cond_t *spd_COND_server_started;
extern long spider_conn_mutex_id;
handlerton *spider_hton_ptr;
+/** All `SPIDER_DBTON`s */
SPIDER_DBTON spider_dbton[SPIDER_DBTON_SIZE];
extern SPIDER_DBTON spider_dbton_mysql;
extern SPIDER_DBTON spider_dbton_mariadb;
@@ -267,6 +268,20 @@ ha_create_table_option spider_table_option_list[]= {
HA_TOPTION_STRING("REMOTE_DATABASE", remote_database),
HA_TOPTION_STRING("REMOTE_TABLE", remote_table), HA_TOPTION_END};
+/**
+ Determines how to populate sts (stat) / crd (cardinality) of a
+ spider share
+*/
+enum ha_sts_crd_get_type
+{
+ HA_GET_COPY = 0, /* Get by copying from wide_share */
+ HA_GET_FETCH = 1, /* Get by executing a sql query */
+ HA_GET_AFTER_LOCK = 2, /* Get by executing a sql query after
+ locking wide_share->sts_mutex. */
+ HA_GET_AFTER_TRYLOCK = 3 /* Get by executing a sql query after
+ trylocking wide_share->sts_mutex. */
+};
+
extern HASH spider_open_connections;
extern HASH spider_ipport_conns;
extern uint spider_open_connections_id;
@@ -295,6 +310,7 @@ const char *spider_open_tables_func_name;
const char *spider_open_tables_file_name;
ulong spider_open_tables_line_no;
pthread_mutex_t spider_tbl_mutex;
+/** All the `SPIDER_INIT_ERROR_TABLE`s */
HASH spider_init_error_tables;
uint spider_init_error_tables_id;
const char *spider_init_error_tables_func_name;
@@ -342,6 +358,11 @@ extern ulonglong spider_free_mem_count[SPIDER_MEM_CALC_LIST_NUM];
static char spider_wild_many = '%', spider_wild_one = '_',
spider_wild_prefix='\\';
+/**
+ `spider_unique_id` is used for identifying a spider table. It is set
+ to be a concatenation of the MAC address and the PID, give or take
+ some separators
+*/
static char spider_unique_id_buf[1 + 12 + 1 + (16 * 2) + 1 + 1];
LEX_CSTRING spider_unique_id;
@@ -4094,7 +4115,7 @@ void spider_print_keys(
int spider_create_conn_keys(
SPIDER_SHARE *share
) {
- int roop_count, roop_count2;
+ int roop_count;
char *tmp_name, port_str[6];
uint length_base = sizeof(uint) * share->all_link_count;
uint *conn_keys_lengths;
@@ -4112,70 +4133,79 @@ int spider_create_conn_keys(
sql_dbton_ids = (uint *) ptr;
share->conn_keys_charlen = 0;
- for (roop_count = 0; roop_count < (int) share->all_link_count; roop_count++)
+ for (int all_link_idx = 0; all_link_idx < (int) share->all_link_count; all_link_idx++)
{
bool get_sql_id = FALSE;
- for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++)
- {
- DBUG_PRINT("info",("spider share->tgt_wrappers[%d]=%s", roop_count,
- share->tgt_wrappers[roop_count]));
- DBUG_PRINT("info",("spider spider_dbton[%d].wrapper=%s", roop_count2,
- spider_dbton[roop_count2].wrapper ?
- spider_dbton[roop_count2].wrapper : "NULL"));
+ /**
+ Find all `SPIDER_DBTON`s with the same wrapper as the target
+ server and set the bitmap. Stop at the first `SPIDER_DBTON` whose
+ db_access_type is sql
+
+ fixme: the logic may be more complicated than the intended
+ one. For one thing, ALL `SPIDER_DBTON`s have sql access
+ type. Consider removing everything to do with the db access
+ type.
+ */
+ for (int dbton_idx = 0; dbton_idx < SPIDER_DBTON_SIZE; dbton_idx++)
+ {
+ DBUG_PRINT("info",("spider share->tgt_wrappers[%d]=%s", all_link_idx,
+ share->tgt_wrappers[all_link_idx]));
+ DBUG_PRINT("info",("spider spider_dbton[%d].wrapper=%s", dbton_idx,
+ spider_dbton[dbton_idx].wrapper ?
+ spider_dbton[dbton_idx].wrapper : "NULL"));
if (
- spider_dbton[roop_count2].wrapper &&
- !strcmp(share->tgt_wrappers[roop_count],
- spider_dbton[roop_count2].wrapper)
+ spider_dbton[dbton_idx].wrapper &&
+ !strcmp(share->tgt_wrappers[all_link_idx],
+ spider_dbton[dbton_idx].wrapper)
) {
- spider_set_bit(share->dbton_bitmap, roop_count2);
+ spider_set_bit(share->dbton_bitmap, dbton_idx);
if (
!get_sql_id &&
- spider_dbton[roop_count2].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL
+ spider_dbton[dbton_idx].db_access_type == SPIDER_DB_ACCESS_TYPE_SQL
) {
- sql_dbton_ids[roop_count] = roop_count2;
+ sql_dbton_ids[all_link_idx] = dbton_idx;
get_sql_id = TRUE;
break;
}
}
}
if (!get_sql_id)
- sql_dbton_ids[roop_count] = SPIDER_DBTON_SIZE;
+ sql_dbton_ids[all_link_idx] = SPIDER_DBTON_SIZE;
bool tables_on_different_db_are_joinable;
if (get_sql_id)
{
tables_on_different_db_are_joinable =
- spider_dbton[sql_dbton_ids[roop_count]].db_util->
+ spider_dbton[sql_dbton_ids[all_link_idx]].db_util->
tables_on_different_db_are_joinable();
} else {
tables_on_different_db_are_joinable = TRUE;
}
- conn_keys_lengths[roop_count]
+ conn_keys_lengths[all_link_idx]
= 1
- + share->tgt_wrappers_lengths[roop_count] + 1
- + share->tgt_hosts_lengths[roop_count] + 1
+ + share->tgt_wrappers_lengths[all_link_idx] + 1
+ + share->tgt_hosts_lengths[all_link_idx] + 1
+ 5 + 1
- + share->tgt_sockets_lengths[roop_count] + 1
+ + share->tgt_sockets_lengths[all_link_idx] + 1
+ (tables_on_different_db_are_joinable ?
- 0 : share->tgt_dbs_lengths[roop_count] + 1)
- + share->tgt_usernames_lengths[roop_count] + 1
- + share->tgt_passwords_lengths[roop_count] + 1
- + share->tgt_ssl_cas_lengths[roop_count] + 1
- + share->tgt_ssl_capaths_lengths[roop_count] + 1
- + share->tgt_ssl_certs_lengths[roop_count] + 1
- + share->tgt_ssl_ciphers_lengths[roop_count] + 1
- + share->tgt_ssl_keys_lengths[roop_count] + 1
+ 0 : share->tgt_dbs_lengths[all_link_idx] + 1)
+ + share->tgt_usernames_lengths[all_link_idx] + 1
+ + share->tgt_passwords_lengths[all_link_idx] + 1
+ + share->tgt_ssl_cas_lengths[all_link_idx] + 1
+ + share->tgt_ssl_capaths_lengths[all_link_idx] + 1
+ + share->tgt_ssl_certs_lengths[all_link_idx] + 1
+ + share->tgt_ssl_ciphers_lengths[all_link_idx] + 1
+ + share->tgt_ssl_keys_lengths[all_link_idx] + 1
+ 1 + 1
- + share->tgt_default_files_lengths[roop_count] + 1
- + share->tgt_default_groups_lengths[roop_count] + 1
- + share->tgt_dsns_lengths[roop_count] + 1
- + share->tgt_filedsns_lengths[roop_count] + 1
- + share->tgt_drivers_lengths[roop_count];
- share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2;
+ + share->tgt_default_files_lengths[all_link_idx] + 1
+ + share->tgt_default_groups_lengths[all_link_idx] + 1
+ + share->tgt_dsns_lengths[all_link_idx] + 1
+ + share->tgt_filedsns_lengths[all_link_idx] + 1
+ + share->tgt_drivers_lengths[all_link_idx];
+ share->conn_keys_charlen += conn_keys_lengths[all_link_idx] + 2;
}
if (!(share->conn_keys = (char **)
- spider_bulk_alloc_mem(spider_current_trx, 45,
- __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
+ spider_bulk_malloc(spider_current_trx, 45, MYF(MY_WME | MY_ZEROFILL),
&share->conn_keys, sizeof(char *) * share->all_link_count,
&share->conn_keys_lengths, length_base,
&share->conn_keys_hash_value,
@@ -4331,15 +4361,15 @@ int spider_create_conn_keys(
&spider_open_connections, (uchar*) share->conn_keys[roop_count],
share->conn_keys_lengths[roop_count]);
}
- for (roop_count2 = 0; roop_count2 < SPIDER_DBTON_SIZE; roop_count2++)
+ for (int dbton_idx = 0; dbton_idx < SPIDER_DBTON_SIZE; dbton_idx++)
{
- if (spider_bit_is_set(share->dbton_bitmap, roop_count2))
+ if (spider_bit_is_set(share->dbton_bitmap, dbton_idx))
{
- share->use_sql_dbton_ids[share->use_dbton_count] = roop_count2;
- share->sql_dbton_id_to_seq[roop_count2] = share->use_dbton_count;
- share->use_sql_dbton_count++;
- share->use_dbton_ids[share->use_dbton_count] = roop_count2;
- share->dbton_id_to_seq[roop_count2] = share->use_dbton_count;
+ share->use_sql_dbton_ids[share->use_dbton_count] = dbton_idx;
+ share->sql_dbton_id_to_seq[dbton_idx] = share->use_dbton_count;
+ share->use_sql_dbton_count++;
+ share->use_dbton_ids[share->use_dbton_count] = dbton_idx;
+ share->dbton_id_to_seq[dbton_idx] = share->use_dbton_count;
share->use_dbton_count++;
}
}
@@ -4539,1002 +4569,619 @@ error_alloc_share:
DBUG_RETURN(NULL);
}
-SPIDER_SHARE *spider_get_share(
- const char *table_name,
- TABLE *table,
- THD *thd,
- ha_spider *spider,
- int *error_num
-) {
- SPIDER_SHARE *share;
- TABLE_SHARE *table_share = table->s;
- SPIDER_RESULT_LIST *result_list = &spider->result_list;
- uint length, tmp_conn_link_idx = 0, buf_sz;
- char *tmp_name;
- int roop_count;
- double sts_interval;
- int sts_mode;
- int sts_sync;
- int auto_increment_mode;
- double crd_interval;
- int crd_mode;
- int crd_sync;
- char first_byte;
- int semi_table_lock_conn;
- int search_link_idx;
- uint sql_command = thd_sql_command(thd);
- SPIDER_Open_tables_backup open_tables_backup;
- MEM_ROOT mem_root;
- TABLE *table_tables = NULL;
- bool init_mem_root = FALSE;
- bool same_server_link;
- int load_sts_at_startup;
- int load_crd_at_startup;
- user_var_entry *loop_check;
- char *loop_check_buf;
- TABLE_SHARE *top_share;
- LEX_CSTRING lex_str;
- DBUG_ENTER("spider_get_share");
- top_share = spider->wide_handler->top_share;
- length = (uint) strlen(table_name);
- my_hash_value_type hash_value = my_calc_hash(&spider_open_tables,
- (uchar*) table_name, length);
- if (top_share)
- {
- lex_str.length = top_share->path.length + SPIDER_SQL_LOP_CHK_PRM_PRF_LEN;
- buf_sz = spider_unique_id.length > SPIDER_SQL_LOP_CHK_PRM_PRF_LEN ?
- top_share->path.length + spider_unique_id.length + 2 :
- lex_str.length + 2;
- loop_check_buf = (char *) my_alloca(buf_sz);
- if (unlikely(!loop_check_buf))
- {
- *error_num = HA_ERR_OUT_OF_MEM;
- DBUG_RETURN(NULL);
- }
- lex_str.str = loop_check_buf + buf_sz - lex_str.length - 2;
- memcpy((void *) lex_str.str,
- SPIDER_SQL_LOP_CHK_PRM_PRF_STR, SPIDER_SQL_LOP_CHK_PRM_PRF_LEN);
- memcpy((void *) (lex_str.str + SPIDER_SQL_LOP_CHK_PRM_PRF_LEN),
- top_share->path.str, top_share->path.length);
- ((char *) lex_str.str)[lex_str.length] = '\0';
- DBUG_PRINT("info",("spider loop check param name=%s", lex_str.str));
- loop_check = get_variable(&thd->user_vars, &lex_str, FALSE);
- if (loop_check && loop_check->type == STRING_RESULT)
- {
- lex_str.length = top_share->path.length + spider_unique_id.length + 1;
- lex_str.str = loop_check_buf + buf_sz - top_share->path.length -
- spider_unique_id.length - 2;
- memcpy((void *) lex_str.str, spider_unique_id.str,
- spider_unique_id.length);
- ((char *) lex_str.str)[lex_str.length - 1] = '-';
- ((char *) lex_str.str)[lex_str.length] = '\0';
- DBUG_PRINT("info",("spider loop check key=%s", lex_str.str));
- DBUG_PRINT("info",("spider loop check param value=%s",
- loop_check->value));
- if (unlikely(strstr(loop_check->value, lex_str.str)))
- {
- *error_num = ER_SPIDER_INFINITE_LOOP_NUM;
- my_printf_error(*error_num, ER_SPIDER_INFINITE_LOOP_STR, MYF(0),
- top_share->db.str, top_share->table_name.str);
- my_afree(loop_check_buf);
- DBUG_RETURN(NULL);
- }
+/**
+ Checks for spider table self-reference
+
+ Get the user variable value (source) and compare it with the user
+ variable name (target). If the target is a substring of the source,
+ then there is a self-reference
+
+ @param thd Connection
+ @param share The table share
+ @retval 0 for success, or else the error number
+*/
+int spider_check_for_self_reference(THD *thd, const TABLE_SHARE *share)
+{
+ String target(0);
+ LEX_CSTRING key;
+ DBUG_ENTER("spider_check_for_self_reference");
+
+ target.append(STRING_WITH_LEN(SPIDER_SQL_LOP_CHK_PRM_PRF_STR));
+ target.append(share->path);
+ DBUG_PRINT("info",("spider loop check param name=%s", target.c_ptr()));
+ key = target.to_lex_cstring();
+ const user_var_entry *loop_check= get_variable(&thd->user_vars, &key, FALSE);
+ if (loop_check && loop_check->type == STRING_RESULT)
+ {
+ String expected(0);
+ expected.append(spider_unique_id);
+ expected.append(share->path);
+ expected.append(STRING_WITH_LEN("-"));
+ DBUG_PRINT("info",("spider loop check expected=%s", expected.c_ptr()));
+ DBUG_PRINT("info",("spider loop check param value=%s",
+ loop_check->value));
+ if (unlikely(strstr(loop_check->value, expected.c_ptr())))
+ {
+ const int error_num = ER_SPIDER_INFINITE_LOOP_NUM;
+ my_printf_error(error_num, ER_SPIDER_INFINITE_LOOP_STR, MYF(0),
+ share->db.str, share->table_name.str);
+ DBUG_RETURN(error_num);
}
- my_afree(loop_check_buf);
}
- pthread_mutex_lock(&spider_tbl_mutex);
- if (!(share = (SPIDER_SHARE*) my_hash_search_using_hash_value(
- &spider_open_tables, hash_value, (uchar*) table_name, length)))
- {
- if (!(share = spider_create_share(
- table_name, table_share,
- table->part_info,
- hash_value,
- error_num
- ))) {
- goto error_alloc_share;
- }
+ DBUG_RETURN(0);
+}
- uint old_elements = spider_open_tables.array.max_element;
- if (my_hash_insert(&spider_open_tables, (uchar*) share))
+/** Populate the init_errors and init of share and/or free it */
+void spider_share_init_error_free(
+ SPIDER_SHARE *share,
+ const bool init,
+ const bool free_share
+)
+{
+ share->init_error= TRUE;
+ share->init_error_time= (time_t) time((time_t *) 0);
+ share->init= TRUE;
+ if (free_share)
+ spider_free_share(share);
+}
+
+void spider_lock_udf_table_mon_mutexes(SPIDER_SHARE *share)
+{
+ pthread_mutex_lock(&share->mutex);
+ for (int roop_count = 0;
+ roop_count < (int) spider_udf_table_mon_mutex_count;
+ roop_count++)
{
- *error_num = HA_ERR_OUT_OF_MEM;
- goto error_hash_insert;
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[roop_count]);
}
- if (spider_open_tables.array.max_element > old_elements)
+}
+
+void spider_unlock_udf_table_mon_mutexes(SPIDER_SHARE *share)
+{
+ for (int roop_count = 0;
+ roop_count < (int) spider_udf_table_mon_mutex_count;
+ roop_count++)
{
- spider_alloc_calc_mem(spider_current_trx,
- spider_open_tables,
- (spider_open_tables.array.max_element - old_elements) *
- spider_open_tables.array.size_of_element);
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
}
+ pthread_mutex_unlock(&share->mutex);
+}
- spider->share = share;
- spider->conn_link_idx = &tmp_conn_link_idx;
+/**
+ Initialises the link_statuses of a spider share
+
+ Open the spider_tables system table, read the link_statuses and
+ update the spider share, and close the table. Frees share if
+ failure
+
+ @param thd Connection
+ @param share The spider share to populate the link_statuses of
+ @param table_share fixme
+ @param sql_command The sql command of the thread
+ @param error_num The error number
+ @retval true Failure
+ false Success
+*/
+bool spider_share_init_link_statuses(
+ THD *thd,
+ SPIDER_SHARE *share,
+ TABLE_SHARE *table_share,
+ const int sql_command,
+ const bool init_share,
+ int *error_num
+)
+{
+ MEM_ROOT mem_root;
+ bool init_mem_root= FALSE;
+ TABLE *table_tables;
+ SPIDER_Open_tables_backup open_tables_backup;
+ DBUG_ENTER("spider_share_init_link_statuses");
+ /*
+ The link statuses need to be refreshed from the spider_tables table
+ if the operation:
+ - Is not a DROP TABLE on a permanent table; or
+ - Is an ALTER TABLE.
- share->use_count++;
- pthread_mutex_unlock(&spider_tbl_mutex);
+ Note that SHOW CREATE TABLE is not excluded, because the commands
+ that follow it require up-to-date link statuses.
+ */
+ if ((table_share->tmp_table == NO_TMP_TABLE &&
+ sql_command != SQLCOM_DROP_TABLE) ||
+ /* for alter change link status */
+ sql_command == SQLCOM_ALTER_TABLE)
+ {
+ SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
+ init_mem_root = TRUE;
- if (!share->link_status_init)
+ if (!(table_tables =
+ spider_open_sys_table(thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE,
+ &open_tables_backup, error_num)))
{
- pthread_mutex_lock(&share->mutex);
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_lock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- if (!share->link_status_init)
+ spider_unlock_udf_table_mon_mutexes(share);
+ spider_share_init_error_free(share, true, true);
+ free_root(&mem_root, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+ if ((*error_num= spider_get_link_statuses(table_tables, share,
+ &mem_root)))
+ {
+ if (*error_num != HA_ERR_KEY_NOT_FOUND &&
+ *error_num != HA_ERR_END_OF_FILE)
{
- /*
- The link statuses need to be refreshed from the spider_tables table
- if the operation:
- - Is not a DROP TABLE on a permanent table; or
- - Is an ALTER TABLE.
-
- Note that SHOW CREATE TABLE is not excluded, because the commands
- that follow it require up-to-date link statuses.
- */
- if ((table_share->tmp_table == NO_TMP_TABLE &&
- sql_command != SQLCOM_DROP_TABLE) ||
- /* for alter change link status */
- sql_command == SQLCOM_ALTER_TABLE)
- {
- SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
- init_mem_root = TRUE;
-
- if (
- !(table_tables = spider_open_sys_table(
- thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
- error_num))
- ) {
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- pthread_mutex_unlock(&share->mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_open_sys_table;
- }
- *error_num = spider_get_link_statuses(table_tables, share,
- &mem_root);
- if (*error_num)
- {
- if (
- *error_num != HA_ERR_KEY_NOT_FOUND &&
- *error_num != HA_ERR_END_OF_FILE
- ) {
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- pthread_mutex_unlock(&share->mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- spider_sys_close_table(thd, &open_tables_backup);
- table_tables = NULL;
- goto error_open_sys_table;
- }
- } else {
- memcpy(share->alter_table.tmp_link_statuses, share->link_statuses,
- sizeof(long) * share->all_link_count);
- share->link_status_init = TRUE;
- }
- spider_sys_close_table(thd, &open_tables_backup);
- table_tables = NULL;
- }
- share->have_recovery_link = spider_conn_check_recovery_link(share);
- if (init_mem_root)
- {
- free_root(&mem_root, MYF(0));
- init_mem_root = FALSE;
- }
- }
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ spider_unlock_udf_table_mon_mutexes(share);
+ spider_share_init_error_free(share, init_share, true);
+ spider_sys_close_table(thd, &open_tables_backup);
+ free_root(&mem_root, MYF(0));
+ DBUG_RETURN(TRUE);
}
- pthread_mutex_unlock(&share->mutex);
- }
-
- semi_table_lock_conn = spider_param_semi_table_lock_connection(thd,
- share->semi_table_lock_conn);
- if (semi_table_lock_conn)
- first_byte = '0' +
- spider_param_semi_table_lock(thd, share->semi_table_lock);
- else
- first_byte = '0';
-
- if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num)))
+ } else
{
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_but_no_delete;
+ memcpy(share->alter_table.tmp_link_statuses, share->link_statuses,
+ sizeof(long) * share->all_link_count);
+ share->link_status_init = TRUE;
}
- spider->set_error_mode();
+ spider_sys_close_table(thd, &open_tables_backup);
+ }
+ share->have_recovery_link = spider_conn_check_recovery_link(share);
+
+ if (init_mem_root)
+ free_root(&mem_root, MYF(0));
+ DBUG_RETURN(FALSE);
+}
- if (!share->sts_spider_init)
+/** Creates an `ha_spider` for the sts thread of the spider share. */
+int spider_share_init_sts(
+ const char* table_name,
+ ha_spider *spider,
+ SPIDER_SHARE *share,
+ const bool init_share
+)
+{
+ DBUG_ENTER("spider_share_init_sts");
+ if (int error_num = spider_create_spider_object_for_share(
+ spider->wide_handler->trx, share, &share->sts_spider))
{
- pthread_mutex_lock(&share->mutex);
- if (!share->sts_spider_init)
- {
- if ((*error_num = spider_create_spider_object_for_share(
- spider->wide_handler->trx, share, &share->sts_spider)))
- {
- pthread_mutex_unlock(&share->mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_sts_spider_init;
- }
- share->sts_thread = &spider_table_sts_threads[
- my_calc_hash(&spider_open_tables, (uchar*) table_name, length) %
- spider_param_table_sts_thread_count()];
- share->sts_spider_init = TRUE;
- }
pthread_mutex_unlock(&share->mutex);
+ spider_share_init_error_free(share, init_share, true);
+ DBUG_RETURN(error_num);
}
+ share->sts_thread =
+ &spider_table_sts_threads[my_calc_hash(&spider_open_tables,
+ (uchar *) table_name,
+ (uint) strlen(table_name)) %
+ spider_param_table_sts_thread_count()];
+ share->sts_spider_init = TRUE;
+ DBUG_RETURN(0);
+}
- if (!share->crd_spider_init)
+/** Creates an `ha_spider` for the crd thread of the spider share */
+int spider_share_init_crd(
+ const char* table_name,
+ ha_spider *spider,
+ SPIDER_SHARE *share,
+ const bool init_share
+)
+{
+ DBUG_ENTER("spider_share_init_crd");
+ if (int error_num = spider_create_spider_object_for_share(
+ spider->wide_handler->trx, share, &share->crd_spider))
{
- pthread_mutex_lock(&share->mutex);
- if (!share->crd_spider_init)
- {
- if ((*error_num = spider_create_spider_object_for_share(
- spider->wide_handler->trx, share, &share->crd_spider)))
- {
- pthread_mutex_unlock(&share->mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_crd_spider_init;
- }
- share->crd_thread = &spider_table_crd_threads[
- my_calc_hash(&spider_open_tables, (uchar*) table_name, length) %
- spider_param_table_crd_thread_count()];
- share->crd_spider_init = TRUE;
- }
pthread_mutex_unlock(&share->mutex);
+ spider_share_init_error_free(share, init_share, true);
+ DBUG_RETURN(error_num);
}
+ share->crd_thread =
+ &spider_table_crd_threads[my_calc_hash(&spider_open_tables,
+ (uchar *) table_name,
+ (uint) strlen(table_name)) %
+ spider_param_table_crd_thread_count()];
+ share->crd_spider_init = TRUE;
+ DBUG_RETURN(0);
+}
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE &&
- (*error_num = spider_create_mon_threads(spider->wide_handler->trx,
- share))
- ) {
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_but_no_delete;
- }
-
- if (!(spider->conn_keys = (char **)
- spider_bulk_alloc_mem(spider_current_trx, 47,
- __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
- &spider->conn_keys, sizeof(char *) * share->link_count,
- &tmp_name, sizeof(char) * share->conn_keys_charlen,
- &spider->conns, sizeof(SPIDER_CONN *) * share->link_count,
- &spider->conn_link_idx, sizeof(uint) * share->link_count,
- &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size,
- &spider->connection_ids, sizeof(ulonglong) * share->link_count,
- &spider->db_request_id, sizeof(ulonglong) * share->link_count,
- &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size,
- &spider->need_mons, sizeof(int) * share->link_count,
- &spider->quick_targets, sizeof(void *) * share->link_count,
- &result_list->upd_tmp_tbls, sizeof(TABLE *) * share->link_count,
- &result_list->upd_tmp_tbl_prms,
- sizeof(TMP_TABLE_PARAM) * share->link_count,
- &result_list->tmp_table_join_first,
- sizeof(uchar) * share->link_bitmap_size,
- &result_list->tmp_table_created,
- sizeof(uchar) * share->link_bitmap_size,
- &result_list->casual_read, sizeof(int) * share->link_count,
- &spider->dbton_handler,
- sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE,
- NullS))
- ) {
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- spider_free_share(share);
- goto error_but_no_delete;
- }
- memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen);
+void *spider_share_malloc_for_spider(
+ ha_spider *spider,
+ SPIDER_SHARE *share,
+ const uint id,
+ char** tmp_name,
+ SPIDER_RESULT_LIST* result_list
+)
+{
+ return spider_bulk_malloc(
+ spider_current_trx, id, MYF(MY_WME | MY_ZEROFILL),
+ &spider->conn_keys, sizeof(char *) * share->link_count,
+ tmp_name, sizeof(char) * share->conn_keys_charlen,
+ &spider->conns, sizeof(SPIDER_CONN *) * share->link_count,
+ &spider->conn_link_idx, sizeof(uint) * share->link_count,
+ &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size,
+ &spider->connection_ids, sizeof(ulonglong) * share->link_count,
+ &spider->db_request_id, sizeof(ulonglong) * share->link_count,
+ &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size,
+ &spider->need_mons, sizeof(int) * share->link_count,
+ &spider->quick_targets, sizeof(void *) * share->link_count,
+ &result_list->upd_tmp_tbls, sizeof(TABLE *) * share->link_count,
+ &result_list->upd_tmp_tbl_prms,
+ sizeof(TMP_TABLE_PARAM) * share->link_count,
+ &result_list->tmp_table_join_first,
+ sizeof(uchar) * share->link_bitmap_size,
+ &result_list->tmp_table_created,
+ sizeof(uchar) * share->link_bitmap_size,
+ &result_list->casual_read, sizeof(int) * share->link_count,
+ &spider->dbton_handler,
+ sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE,
+ NullS);
+}
- spider->conn_keys_first_ptr = tmp_name;
- for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
+/**
+ Initialise dbton_handlers of a spider.
+*/
+int spider_share_init_spider_dbton_handlers(ha_spider *spider, SPIDER_SHARE *share)
+{
+ int roop_count, error_num= 0;
+ for (roop_count = 0; roop_count < (int) share->use_dbton_count;
+ roop_count++)
+ {
+ uint dbton_id = share->use_dbton_ids[roop_count];
+ if (!(spider->dbton_handler[dbton_id]=
+ spider_dbton[dbton_id].create_db_handler(spider,
+ share->dbton_share[dbton_id])))
{
- spider->conn_keys[roop_count] = tmp_name;
- *tmp_name = first_byte;
- tmp_name += share->conn_keys_lengths[roop_count] + 1;
- result_list->upd_tmp_tbl_prms[roop_count].init();
- result_list->upd_tmp_tbl_prms[roop_count].field_count = 1;
+ error_num = HA_ERR_OUT_OF_MEM;
+ break;
}
- spider_trx_set_link_idx_for_all(spider);
-
- for (roop_count = 0; roop_count < (int) share->use_dbton_count;
- roop_count++)
+ if ((error_num = spider->dbton_handler[dbton_id]->init()))
+ break;
+ }
+ /* Failure: rollback */
+ if (roop_count < (int) share->use_dbton_count)
+ {
+ for (; roop_count >= 0; roop_count--)
{
uint dbton_id = share->use_dbton_ids[roop_count];
- if (!(spider->dbton_handler[dbton_id] =
- spider_dbton[dbton_id].create_db_handler(spider,
- share->dbton_share[dbton_id])))
+ if (spider->dbton_handler[dbton_id])
{
- *error_num = HA_ERR_OUT_OF_MEM;
- break;
- }
- if ((*error_num = spider->dbton_handler[dbton_id]->init()))
- {
- break;
+ delete spider->dbton_handler[dbton_id];
+ spider->dbton_handler[dbton_id]= NULL;
}
}
- if (roop_count < (int) share->use_dbton_count)
- {
- for (; roop_count >= 0; roop_count--)
+ }
+ return error_num;
+}
+
+/** Gets or creates connections to all active servers */
+bool spider_share_get_conns(ha_spider *spider, SPIDER_SHARE *share,
+ int *error_num)
+{
+ DBUG_ENTER("spider_share_get_conns");
+ for (int roop_count = spider_conn_link_idx_next(
+ share->link_statuses, spider->conn_link_idx, -1,
+ share->link_count, SPIDER_LINK_STATUS_RECOVERY);
+ roop_count < (int) share->link_count;
+ roop_count = spider_conn_link_idx_next(
+ share->link_statuses, spider->conn_link_idx, roop_count,
+ share->link_count, SPIDER_LINK_STATUS_RECOVERY))
+ {
+ if (!(spider->conns[roop_count] =
+ spider_get_conn(share, roop_count, spider->conn_keys[roop_count],
+ spider->wide_handler->trx, spider, FALSE, TRUE,
+ error_num)))
+ {
+ if (share->monitoring_kind[roop_count] && spider->need_mons[roop_count])
{
- uint dbton_id = share->use_dbton_ids[roop_count];
- if (spider->dbton_handler[dbton_id])
- {
- delete spider->dbton_handler[dbton_id];
- spider->dbton_handler[dbton_id] = NULL;
- }
+ *error_num = spider_ping_table_mon_from_table(
+ spider->wide_handler->trx,
+ spider->wide_handler->trx->thd,
+ share,
+ roop_count,
+ (uint32) share->monitoring_sid[roop_count],
+ share->table_name,
+ share->table_name_length,
+ spider->conn_link_idx[roop_count],
+ NULL,
+ 0,
+ share->monitoring_kind[roop_count],
+ share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
+ FALSE
+ );
}
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_conn_keys;
+ DBUG_RETURN(TRUE);
}
+ spider->conns[roop_count]->error_mode &= spider->error_mode;
+ }
+ DBUG_RETURN(FALSE);
+}
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE
- ) {
- for (
- roop_count = spider_conn_link_idx_next(share->link_statuses,
- spider->conn_link_idx, -1, share->link_count,
- SPIDER_LINK_STATUS_RECOVERY);
- roop_count < (int) share->link_count;
- roop_count = spider_conn_link_idx_next(share->link_statuses,
- spider->conn_link_idx, roop_count, share->link_count,
- SPIDER_LINK_STATUS_RECOVERY)
- ) {
- if (
- !(spider->conns[roop_count] =
- spider_get_conn(share, roop_count, spider->conn_keys[roop_count],
- spider->wide_handler->trx, spider, FALSE, TRUE,
- error_num))
- ) {
- if (
- share->monitoring_kind[roop_count] &&
- spider->need_mons[roop_count]
- ) {
- *error_num = spider_ping_table_mon_from_table(
- spider->wide_handler->trx,
- spider->wide_handler->trx->thd,
- share,
- roop_count,
- (uint32) share->monitoring_sid[roop_count],
- share->table_name,
- share->table_name_length,
- spider->conn_link_idx[roop_count],
- NULL,
- 0,
- share->monitoring_kind[roop_count],
- share->monitoring_limit[roop_count],
- share->monitoring_flag[roop_count],
- FALSE
- );
- }
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- }
- spider->conns[roop_count]->error_mode &= spider->error_mode;
- }
- }
- search_link_idx = spider_conn_first_link_idx(thd,
- share->link_statuses, share->access_balances, spider->conn_link_idx,
- share->link_count, SPIDER_LINK_STATUS_OK);
- if (search_link_idx == -1)
+/**
+ Handles a failed search for usable servers
+
+ @param share The spider share to update its init error
+ @param table_share The table share
+ @param search_result The search result, either -1 (no usable server) or
+ -2 (out of memory)
+ @return Error code associated with the failure
+*/
+int spider_share_handle_search_link_failure(
+ SPIDER_SHARE* share,
+ TABLE_SHARE* table_share,
+ const int search_result,
+ const bool init_share
+)
+{
+ DBUG_ENTER("spider_share_handle_search_link_failure");
+ if (likely(search_result == -1)) /* No available servers. */
+ {
+ char *db = (char *) my_alloca(
+ table_share->db.length + 1 + table_share->table_name.length + 1);
+ if (unlikely(!db))
{
- char *db = (char *) my_alloca(
- table_share->db.length + 1 + table_share->table_name.length + 1);
- if (!db)
- {
- *error_num = HA_ERR_OUT_OF_MEM;
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- }
- char *table_name = db + table_share->db.length + 1;
- memcpy(db, table_share->db.str, table_share->db.length);
- db[table_share->db.length] = '\0';
- memcpy(table_name, table_share->table_name.str,
- table_share->table_name.length);
- table_name[table_share->table_name.length] = '\0';
- my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM,
- ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name);
- my_afree(db);
- *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM;
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- } else if (search_link_idx == -2)
+ spider_share_init_error_free(share, init_share, false);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+ char *table_name = db + table_share->db.length + 1;
+ memcpy(db, table_share->db.str, table_share->db.length);
+ db[table_share->db.length] = '\0';
+ memcpy(table_name, table_share->table_name.str,
+ table_share->table_name.length);
+ table_name[table_share->table_name.length] = '\0';
+ my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM,
+ ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name);
+ my_afree(db);
+ spider_share_init_error_free(share, init_share, false);
+ DBUG_RETURN(ER_SPIDER_ALL_LINKS_FAILED_NUM);
+ }
+ spider_share_init_error_free(share, init_share, false);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+}
+
+/** Gets sts and crd for spider_init_share() */
+bool spider_share_get_sts_crd(
+ THD *thd,
+ ha_spider *spider,
+ SPIDER_SHARE *share,
+ TABLE *table,
+ const bool init_share,
+ /* fixme: do we need this? */
+ const bool has_lock,
+ int *error_num
+)
+{
+ const bool same_server_link = spider_param_same_server_link(thd);
+ const int load_sts_at_startup =
+ spider_param_load_sts_at_startup(share->load_sts_at_startup);
+ const int load_crd_at_startup =
+ spider_param_load_crd_at_startup(share->load_crd_at_startup);
+ DBUG_ENTER("spider_share_get_sts_crd");
+ if (!spider->error_mode &&
+ (!same_server_link || load_sts_at_startup || load_crd_at_startup))
+ {
+ const double sts_interval = spider_param_sts_interval(thd, share->sts_interval);
+ const int sts_mode = spider_param_sts_mode(thd, share->sts_mode);
+ const int auto_increment_mode = spider_param_auto_increment_mode(
+ thd, share->auto_increment_mode);
+ const int sts_sync = auto_increment_mode == 1 ? 0 :
+ spider_param_sts_sync(thd, share->sts_sync);
+ const double crd_interval = spider_param_crd_interval(thd, share->crd_interval);
+ int crd_mode = spider_param_crd_mode(thd, share->crd_mode);
+ /* TODO(MDEV-27996): Delete spider_crd_mode and spider_sts_mode */
+ if (crd_mode == 3)
+ crd_mode = 1;
+ const int crd_sync = spider_param_crd_sync(thd, share->crd_sync);
+
+ const time_t tmp_time = (time_t) time((time_t*) 0);
+ if (!has_lock)
{
- *error_num = HA_ERR_OUT_OF_MEM;
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- }
- spider->search_link_idx = search_link_idx;
-
- same_server_link = spider_param_same_server_link(thd);
- load_sts_at_startup =
- spider_param_load_sts_at_startup(share->load_sts_at_startup);
- load_crd_at_startup =
- spider_param_load_crd_at_startup(share->load_crd_at_startup);
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE &&
- !spider->error_mode &&
- (
- !same_server_link ||
- load_sts_at_startup ||
- load_crd_at_startup
- )
- ) {
- SPIDER_INIT_ERROR_TABLE *spider_init_error_table;
- sts_interval = spider_param_sts_interval(thd, share->sts_interval);
- sts_mode = spider_param_sts_mode(thd, share->sts_mode);
- sts_sync = spider_param_sts_sync(thd, share->sts_sync);
- auto_increment_mode = spider_param_auto_increment_mode(thd,
- share->auto_increment_mode);
- if (auto_increment_mode == 1)
- sts_sync = 0;
- crd_interval = spider_param_crd_interval(thd, share->crd_interval);
- crd_mode = spider_param_crd_mode(thd, share->crd_mode);
- if (crd_mode == 3)
- crd_mode = 1;
- crd_sync = spider_param_crd_sync(thd, share->crd_sync);
- time_t tmp_time = (time_t) time((time_t*) 0);
pthread_mutex_lock(&share->sts_mutex);
pthread_mutex_lock(&share->crd_mutex);
- if ((spider_init_error_table =
- spider_get_init_error_table(spider->wide_handler->trx, share, FALSE)))
- {
- DBUG_PRINT("info",("spider diff1=%f",
- difftime(tmp_time, spider_init_error_table->init_error_time)));
- if (difftime(tmp_time,
- spider_init_error_table->init_error_time) <
- spider_param_table_init_error_interval())
- {
- *error_num = spider_init_error_table->init_error;
- if (spider_init_error_table->init_error_with_message)
- my_message(spider_init_error_table->init_error,
- spider_init_error_table->init_error_msg, MYF(0));
- share->init_error = TRUE;
- share->init = TRUE;
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- goto error_after_alloc_dbton_handler;
- }
- }
-
- if (
- (
- !same_server_link ||
- load_sts_at_startup
- ) &&
- (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time,
- spider, sts_interval, sts_mode,
- sts_sync,
- 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO))
- ) {
- if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM)
- {
- thd->clear_error();
- } else {
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- }
- }
- if (
- (
- !same_server_link ||
- load_crd_at_startup
- ) &&
- (*error_num = spider_get_crd(share, spider->search_link_idx, tmp_time,
- spider, table, crd_interval, crd_mode,
- crd_sync,
- 1))
- ) {
- if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM)
- {
- thd->clear_error();
- } else {
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- share->init_error = TRUE;
- share->init_error_time = (time_t) time((time_t*) 0);
- share->init = TRUE;
- goto error_after_alloc_dbton_handler;
- }
- }
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
}
-
- share->init = TRUE;
- } else {
- share->use_count++;
- pthread_mutex_unlock(&spider_tbl_mutex);
-
- int sleep_cnt = 0;
- while (!share->init)
+ /* If not enough time has passed since the last init error, abort */
+ if (const SPIDER_INIT_ERROR_TABLE *spider_init_error_table =
+ spider_get_init_error_table(spider->wide_handler->trx, share, FALSE))
{
- // avoid for dead loop
- if (sleep_cnt++ > 1000)
+ DBUG_PRINT("info",("spider diff1=%f",
+ difftime(tmp_time, spider_init_error_table->init_error_time)));
+ if (difftime(tmp_time,
+ spider_init_error_table->init_error_time) <
+ spider_param_table_init_error_interval())
{
- fprintf(stderr, " [WARN SPIDER RESULT] "
- "Wait share->init too long, table_name %s %s %ld\n",
- share->table_name, share->tgt_hosts[0], share->tgt_ports[0]);
- *error_num = ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM;
- my_printf_error(ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM,
- ER_SPIDER_TABLE_OPEN_TIMEOUT_STR, MYF(0),
- table_share->db.str, table_share->table_name.str);
- spider_free_share(share);
- goto error_but_no_delete;
+ *error_num = spider_init_error_table->init_error;
+ if (spider_init_error_table->init_error_with_message)
+ my_message(spider_init_error_table->init_error,
+ spider_init_error_table->init_error_msg, MYF(0));
+ spider_share_init_error_free(share, init_share, false);
+ pthread_mutex_unlock(&share->crd_mutex);
+ pthread_mutex_unlock(&share->sts_mutex);
+ DBUG_RETURN(TRUE);
}
- my_sleep(10000); // wait 10 ms
}
- if (!share->link_status_init)
+ if ((!same_server_link || load_sts_at_startup) &&
+ (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time,
+ spider, sts_interval, sts_mode, sts_sync,
+ 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO))
+ )
{
- pthread_mutex_lock(&share->mutex);
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_lock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- if (!share->link_status_init)
+ if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM &&
+ *error_num != ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM)
+ thd->clear_error();
+ else
{
- DBUG_ASSERT(!table_tables);
- /*
- The link statuses need to be refreshed from the spider_tables table
- if the operation:
- - Is not a DROP TABLE on a permanent table; or
- - Is an ALTER TABLE.
-
- Note that SHOW CREATE TABLE is not excluded, because the commands
- that follow it require up-to-date link statuses.
- */
- if ((table_share->tmp_table == NO_TMP_TABLE &&
- sql_command != SQLCOM_DROP_TABLE) ||
- /* for alter change link status */
- sql_command == SQLCOM_ALTER_TABLE)
- {
- SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
- init_mem_root = TRUE;
-
- if (
- !(table_tables = spider_open_sys_table(
- thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
- error_num))
- ) {
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- goto error_open_sys_table;
- }
- *error_num = spider_get_link_statuses(table_tables, share,
- &mem_root);
- if (*error_num)
- {
- if (
- *error_num != HA_ERR_KEY_NOT_FOUND &&
- *error_num != HA_ERR_END_OF_FILE
- ) {
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
- }
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- spider_sys_close_table(thd, &open_tables_backup);
- table_tables = NULL;
- goto error_open_sys_table;
- }
- } else {
- memcpy(share->alter_table.tmp_link_statuses, share->link_statuses,
- sizeof(long) * share->all_link_count);
- share->link_status_init = TRUE;
- }
- spider_sys_close_table(thd, &open_tables_backup);
- table_tables = NULL;
- }
- share->have_recovery_link = spider_conn_check_recovery_link(share);
- if (init_mem_root)
- {
- free_root(&mem_root, MYF(0));
- init_mem_root = FALSE;
- }
- }
- for (roop_count = 0;
- roop_count < (int) spider_udf_table_mon_mutex_count;
- roop_count++
- ) {
- if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
- pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ pthread_mutex_unlock(&share->crd_mutex);
+ pthread_mutex_unlock(&share->sts_mutex);
+ spider_share_init_error_free(share, init_share, false);
+ DBUG_RETURN(TRUE);
}
- pthread_mutex_unlock(&share->mutex);
}
- semi_table_lock_conn = spider_param_semi_table_lock_connection(thd,
- share->semi_table_lock_conn);
- if (semi_table_lock_conn)
- first_byte = '0' +
- spider_param_semi_table_lock(thd, share->semi_table_lock);
- else
- first_byte = '0';
-
- spider->share = share;
- if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num)))
- {
- spider_free_share(share);
- goto error_but_no_delete;
- }
- spider->set_error_mode();
-
- if (!share->sts_spider_init)
+ if ((!same_server_link || load_crd_at_startup) &&
+ (*error_num = spider_get_crd(share, spider->search_link_idx, tmp_time,
+ spider, table, crd_interval, crd_mode,
+ crd_sync,
+ 1)))
{
- pthread_mutex_lock(&share->mutex);
- if (!share->sts_spider_init)
+ if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM &&
+ *error_num != ER_SPIDER_TABLE_OPEN_LOCK_WAIT_TIMEOUT_NUM)
+ thd->clear_error();
+ else
{
- if ((*error_num = spider_create_spider_object_for_share(
- spider->wide_handler->trx, share, &share->sts_spider)))
- {
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- goto error_sts_spider_init;
- }
- share->sts_thread = &spider_table_sts_threads[
- my_calc_hash(&spider_open_tables, (uchar*) table_name, length) %
- spider_param_table_sts_thread_count()];
- share->sts_spider_init = TRUE;
+ pthread_mutex_unlock(&share->crd_mutex);
+ pthread_mutex_unlock(&share->sts_mutex);
+ spider_share_init_error_free(share, init_share, false);
+ DBUG_RETURN(TRUE);
}
- pthread_mutex_unlock(&share->mutex);
}
-
- if (!share->crd_spider_init)
+ if (!has_lock)
{
- pthread_mutex_lock(&share->mutex);
- if (!share->crd_spider_init)
- {
- if ((*error_num = spider_create_spider_object_for_share(
- spider->wide_handler->trx, share, &share->crd_spider)))
- {
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- goto error_crd_spider_init;
- }
- share->crd_thread = &spider_table_crd_threads[
- my_calc_hash(&spider_open_tables, (uchar*) table_name, length) %
- spider_param_table_crd_thread_count()];
- share->crd_spider_init = TRUE;
- }
- pthread_mutex_unlock(&share->mutex);
+ pthread_mutex_unlock(&share->crd_mutex);
+ pthread_mutex_unlock(&share->sts_mutex);
}
+ }
+ DBUG_RETURN(FALSE);
+}
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE &&
+/** Initialises a `SPIDER_SHARE` */
+bool spider_init_share(
+ const char *table_name,
+ TABLE *table,
+ THD *thd,
+ ha_spider *spider,
+ int *error_num,
+ SPIDER_SHARE *share,
+ TABLE_SHARE *table_share,
+ const bool new_share
+)
+{
+ char first_byte;
+ char *tmp_name;
+ SPIDER_RESULT_LIST *result_list = &spider->result_list;
+ int search_link_idx;
+ const uint sql_command = thd_sql_command(thd);
+ const bool continue_with_sql_command =
+ sql_command != SQLCOM_DROP_TABLE &&
+ sql_command != SQLCOM_ALTER_TABLE &&
+ sql_command != SQLCOM_SHOW_CREATE;
+ DBUG_ENTER("spider_init_share");
+ if (!share->link_status_init)
+ {
+ spider_lock_udf_table_mon_mutexes(share);
+ if (!share->link_status_init &&
+ spider_share_init_link_statuses(thd, share, table_share,
+ sql_command, new_share, error_num))
+ DBUG_RETURN(TRUE);
+ spider_unlock_udf_table_mon_mutexes(share);
+ }
+
+ const int semi_table_lock_conn =
+ spider_param_semi_table_lock_connection(thd, share->semi_table_lock_conn);
+ if (semi_table_lock_conn)
+ first_byte = '0' +
+ spider_param_semi_table_lock(thd, share->semi_table_lock);
+ else
+ first_byte = '0';
+
+ if (!(spider->wide_handler->trx = spider_get_trx(thd, TRUE, error_num)))
+ {
+ spider_share_init_error_free(share, new_share, true);
+ DBUG_RETURN(TRUE);
+ }
+ spider->set_error_mode();
+
+ /* There's no other place doing anything that
+ `spider_share_init_sts()` does or updating
+ `st_spider_share::sts_spider_init`, therefore there's no need to
+ lock/unlock. Same goes for crd */
+ if (!share->sts_spider_init &&
+ (*error_num= spider_share_init_sts(table_name, spider, share, new_share)))
+ DBUG_RETURN(TRUE);
+
+ if (!share->crd_spider_init &&
+ (*error_num= spider_share_init_crd(table_name, spider, share, new_share)))
+ DBUG_RETURN(TRUE);
+
+ if (continue_with_sql_command &&
(*error_num = spider_create_mon_threads(spider->wide_handler->trx,
- share))
- ) {
- spider_free_share(share);
- goto error_but_no_delete;
- }
-
- if (!(spider->conn_keys = (char **)
- spider_bulk_alloc_mem(spider_current_trx, 49,
- __func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
- &spider->conn_keys, sizeof(char *) * share->link_count,
- &tmp_name, sizeof(char) * share->conn_keys_charlen,
- &spider->conns, sizeof(SPIDER_CONN *) * share->link_count,
- &spider->conn_link_idx, sizeof(uint) * share->link_count,
- &spider->conn_can_fo, sizeof(uchar) * share->link_bitmap_size,
- &spider->connection_ids, sizeof(ulonglong) * share->link_count,
- &spider->db_request_id, sizeof(ulonglong) * share->link_count,
- &spider->db_request_phase, sizeof(uchar) * share->link_bitmap_size,
- &spider->need_mons, sizeof(int) * share->link_count,
- &spider->quick_targets, sizeof(void *) * share->link_count,
- &result_list->upd_tmp_tbls, sizeof(TABLE *) * share->link_count,
- &result_list->upd_tmp_tbl_prms,
- sizeof(TMP_TABLE_PARAM) * share->link_count,
- &result_list->tmp_table_join_first,
- sizeof(uchar) * share->link_bitmap_size,
- &result_list->tmp_table_created,
- sizeof(uchar) * share->link_bitmap_size,
- &result_list->casual_read, sizeof(int) * share->link_count,
- &spider->dbton_handler,
- sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE,
- NullS))
- ) {
- spider_free_share(share);
- goto error_but_no_delete;
- }
- memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen);
+ share)))
+ {
+ spider_share_init_error_free(share, new_share, true);
+ DBUG_RETURN(TRUE);
+ }
- spider->conn_keys_first_ptr = tmp_name;
- for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
- {
- spider->conn_keys[roop_count] = tmp_name;
- *tmp_name = first_byte;
- tmp_name += share->conn_keys_lengths[roop_count] + 1;
- result_list->upd_tmp_tbl_prms[roop_count].init();
- result_list->upd_tmp_tbl_prms[roop_count].field_count = 1;
- }
- spider_trx_set_link_idx_for_all(spider);
+ if (!(spider_share_malloc_for_spider(spider, share, 47, &tmp_name,
+ result_list)))
+ {
+ spider_share_init_error_free(share, new_share, true);
+ DBUG_RETURN(TRUE);
+ }
+ memcpy(tmp_name, share->conn_keys[0], share->conn_keys_charlen);
- for (roop_count = 0; roop_count < (int) share->use_dbton_count;
- roop_count++)
- {
- uint dbton_id = share->use_dbton_ids[roop_count];
- if (!(spider->dbton_handler[dbton_id] =
- spider_dbton[dbton_id].create_db_handler(spider,
- share->dbton_share[dbton_id])))
- {
- *error_num = HA_ERR_OUT_OF_MEM;
- break;
- }
- if ((*error_num = spider->dbton_handler[dbton_id]->init()))
- {
- break;
- }
- }
- if (roop_count < (int) share->use_dbton_count)
- {
- for (; roop_count >= 0; roop_count--)
- {
- uint dbton_id = share->use_dbton_ids[roop_count];
- if (spider->dbton_handler[dbton_id])
- {
- delete spider->dbton_handler[dbton_id];
- spider->dbton_handler[dbton_id] = NULL;
- }
- }
- goto error_after_alloc_conn_keys;
- }
+ spider->conn_keys_first_ptr = tmp_name;
+ for (int link_idx = 0; link_idx < (int) share->link_count; link_idx++)
+ {
+ spider->conn_keys[link_idx] = tmp_name;
+ *tmp_name = first_byte;
+ tmp_name += share->conn_keys_lengths[link_idx] + 1;
+ result_list->upd_tmp_tbl_prms[link_idx].init();
+ result_list->upd_tmp_tbl_prms[link_idx].field_count = 1;
+ }
+ spider_trx_set_link_idx_for_all(spider);
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE
- ) {
- for (
- roop_count = spider_conn_link_idx_next(share->link_statuses,
- spider->conn_link_idx, -1, share->link_count,
- SPIDER_LINK_STATUS_RECOVERY);
- roop_count < (int) share->link_count;
- roop_count = spider_conn_link_idx_next(share->link_statuses,
- spider->conn_link_idx, roop_count, share->link_count,
- SPIDER_LINK_STATUS_RECOVERY)
- ) {
- if (
- !(spider->conns[roop_count] =
- spider_get_conn(share, roop_count, spider->conn_keys[roop_count],
- spider->wide_handler->trx, spider, FALSE, TRUE,
- error_num))
- ) {
- if (
- share->monitoring_kind[roop_count] &&
- spider->need_mons[roop_count]
- ) {
- *error_num = spider_ping_table_mon_from_table(
- spider->wide_handler->trx,
- spider->wide_handler->trx->thd,
- share,
- roop_count,
- (uint32) share->monitoring_sid[roop_count],
- share->table_name,
- share->table_name_length,
- spider->conn_link_idx[roop_count],
- NULL,
- 0,
- share->monitoring_kind[roop_count],
- share->monitoring_limit[roop_count],
- share->monitoring_flag[roop_count],
- FALSE
- );
- }
- goto error_after_alloc_dbton_handler;
- }
- spider->conns[roop_count]->error_mode &= spider->error_mode;
- }
- }
- search_link_idx = spider_conn_first_link_idx(thd,
- share->link_statuses, share->access_balances, spider->conn_link_idx,
- share->link_count, SPIDER_LINK_STATUS_OK);
- if (search_link_idx == -1)
+ if ((*error_num= spider_share_init_spider_dbton_handlers(spider, share)))
+ {
+ spider_share_init_error_free(share, new_share, false);
+ goto error_after_alloc_conn_keys;
+ }
+
+ if (continue_with_sql_command &&
+ spider_share_get_conns(spider, share, error_num))
+ {
+ spider_share_init_error_free(share, new_share, false);
+ goto error_after_alloc_dbton_handler;
+ }
+
+ search_link_idx =
+ spider_conn_first_link_idx(thd, share->link_statuses,
+ share->access_balances,
+ spider->conn_link_idx, share->link_count,
+ SPIDER_LINK_STATUS_OK);
+ if (search_link_idx < 0)
+ {
+ *error_num= spider_share_handle_search_link_failure(
+ share, table_share, search_link_idx, new_share);
+ goto error_after_alloc_dbton_handler;
+ }
+ spider->search_link_idx= search_link_idx;
+
+ if (continue_with_sql_command)
+ {
+ if (new_share)
{
- char *db = (char *) my_alloca(
- table_share->db.length + 1 + table_share->table_name.length + 1);
- if (!db)
- {
- *error_num = HA_ERR_OUT_OF_MEM;
+ if (spider_share_get_sts_crd(thd, spider, share, table, true, false,
+ error_num))
goto error_after_alloc_dbton_handler;
- }
- char *table_name = db + table_share->db.length + 1;
- memcpy(db, table_share->db.str, table_share->db.length);
- db[table_share->db.length] = '\0';
- memcpy(table_name, table_share->table_name.str,
- table_share->table_name.length);
- table_name[table_share->table_name.length] = '\0';
- my_printf_error(ER_SPIDER_ALL_LINKS_FAILED_NUM,
- ER_SPIDER_ALL_LINKS_FAILED_STR, MYF(0), db, table_name);
- my_afree(db);
- *error_num = ER_SPIDER_ALL_LINKS_FAILED_NUM;
- goto error_after_alloc_dbton_handler;
- } else if (search_link_idx == -2)
- {
- *error_num = HA_ERR_OUT_OF_MEM;
- goto error_after_alloc_dbton_handler;
- }
- spider->search_link_idx = search_link_idx;
-
- if (share->init_error)
+ } else if (share->init_error)
{
+ /* fixme: can we move the locking and unlocking into
+ spider_share_get_sts_crd()? */
pthread_mutex_lock(&share->sts_mutex);
pthread_mutex_lock(&share->crd_mutex);
if (share->init_error)
{
- same_server_link = spider_param_same_server_link(thd);
- load_sts_at_startup =
- spider_param_load_sts_at_startup(share->load_sts_at_startup);
- load_crd_at_startup =
- spider_param_load_crd_at_startup(share->load_crd_at_startup);
- if (
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE &&
- !spider->error_mode &&
- (
- !same_server_link ||
- load_sts_at_startup ||
- load_crd_at_startup
- )
- ) {
- SPIDER_INIT_ERROR_TABLE *spider_init_error_table;
- sts_interval = spider_param_sts_interval(thd, share->sts_interval);
- sts_mode = spider_param_sts_mode(thd, share->sts_mode);
- sts_sync = spider_param_sts_sync(thd, share->sts_sync);
- auto_increment_mode = spider_param_auto_increment_mode(thd,
- share->auto_increment_mode);
- if (auto_increment_mode == 1)
- sts_sync = 0;
- crd_interval = spider_param_crd_interval(thd, share->crd_interval);
- crd_mode = spider_param_crd_mode(thd, share->crd_mode);
- if (crd_mode == 3)
- crd_mode = 1;
- crd_sync = spider_param_crd_sync(thd, share->crd_sync);
- time_t tmp_time = (time_t) time((time_t*) 0);
- if ((spider_init_error_table =
- spider_get_init_error_table(spider->wide_handler->trx, share,
- FALSE)))
- {
- DBUG_PRINT("info",("spider diff2=%f",
- difftime(tmp_time, spider_init_error_table->init_error_time)));
- if (difftime(tmp_time,
- spider_init_error_table->init_error_time) <
- spider_param_table_init_error_interval())
- {
- *error_num = spider_init_error_table->init_error;
- if (spider_init_error_table->init_error_with_message)
- my_message(spider_init_error_table->init_error,
- spider_init_error_table->init_error_msg, MYF(0));
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- goto error_after_alloc_dbton_handler;
- }
- }
-
- if (
- (
- !same_server_link ||
- load_sts_at_startup
- ) &&
- (*error_num = spider_get_sts(share, spider->search_link_idx,
- tmp_time, spider, sts_interval, sts_mode,
- sts_sync,
- 1, HA_STATUS_VARIABLE | HA_STATUS_CONST | HA_STATUS_AUTO))
- ) {
- if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM)
- {
- thd->clear_error();
- } else {
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- goto error_after_alloc_dbton_handler;
- }
- }
- if (
- (
- !same_server_link ||
- load_crd_at_startup
- ) &&
- (*error_num = spider_get_crd(share, spider->search_link_idx,
- tmp_time, spider, table, crd_interval, crd_mode,
- crd_sync,
- 1))
- ) {
- if (*error_num != ER_SPIDER_SYS_TABLE_VERSION_NUM)
- {
- thd->clear_error();
- } else {
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- goto error_after_alloc_dbton_handler;
- }
- }
- }
- share->init_error = FALSE;
+ if (spider_share_get_sts_crd(thd, spider, share, table, FALSE, TRUE,
+ error_num))
+ goto error_after_alloc_dbton_handler;
+ share->init_error= FALSE;
}
pthread_mutex_unlock(&share->crd_mutex);
pthread_mutex_unlock(&share->sts_mutex);
}
}
-
- DBUG_PRINT("info",("spider share=%p", share));
- DBUG_RETURN(share);
+ DBUG_RETURN(FALSE);
error_after_alloc_dbton_handler:
- for (roop_count = 0; roop_count < (int) share->use_dbton_count; ++roop_count)
+ for (int roop_count = 0; roop_count < (int) share->use_dbton_count; ++roop_count)
{
uint dbton_id = share->use_dbton_ids[roop_count];
if (spider->dbton_handler[dbton_id])
@@ -5547,21 +5194,104 @@ error_after_alloc_conn_keys:
spider_free(spider_current_trx, spider->conn_keys, MYF(0));
spider->conn_keys = NULL;
spider_free_share(share);
- goto error_but_no_delete;
+ DBUG_RETURN(TRUE);
+}
+
+/**
+ Gets or creates a spider share, then initialises it
+*/
+SPIDER_SHARE *spider_get_share(
+ const char *table_name,
+ TABLE *table,
+ THD *thd,
+ ha_spider *spider,
+ int *error_num
+) {
+ SPIDER_SHARE *share;
+ TABLE_SHARE *table_share = table->s;
+ DBUG_ENTER("spider_get_share");
+
+ const TABLE_SHARE *top_share = spider->wide_handler->top_share;
+ if (top_share &&
+ (*error_num = spider_check_for_self_reference(thd, top_share)))
+ DBUG_RETURN(NULL);
+
+ const uint length = (uint) strlen(table_name);
+ const my_hash_value_type hash_value =
+ my_calc_hash(&spider_open_tables, (uchar*) table_name, length);
+ pthread_mutex_lock(&spider_tbl_mutex);
+ if (!(share = (SPIDER_SHARE*) my_hash_search_using_hash_value(
+ &spider_open_tables, hash_value, (uchar*) table_name, length)))
+ {
+ if (!(share = spider_create_share(table_name, table_share,
+ table->part_info, hash_value,
+ error_num)))
+ goto error_alloc_share;
+
+ uint old_elements = spider_open_tables.array.max_element;
+ if (my_hash_insert(&spider_open_tables, (uchar*) share))
+ {
+ *error_num = HA_ERR_OUT_OF_MEM;
+ goto error_hash_insert;
+ }
+ if (spider_open_tables.array.max_element > old_elements)
+ {
+ spider_alloc_calc_mem(spider_current_trx,
+ spider_open_tables,
+ (spider_open_tables.array.max_element - old_elements) *
+ spider_open_tables.array.size_of_element);
+ }
+
+ spider->share = share;
+ uint tmp_conn_link_idx= 0;
+ spider->conn_link_idx = &tmp_conn_link_idx;
+
+ share->use_count++;
+ pthread_mutex_unlock(&spider_tbl_mutex);
+
+ if (spider_init_share(table_name, table, thd, spider, error_num, share,
+ table_share, TRUE))
+ DBUG_RETURN(NULL);
+
+ share->init = TRUE;
+ } else
+ {
+ share->use_count++;
+ pthread_mutex_unlock(&spider_tbl_mutex);
+
+ int sleep_cnt = 0;
+ while (!share->init)
+ {
+ // avoid for dead loop
+ if (sleep_cnt++ > 1000)
+ {
+ fprintf(stderr, " [WARN SPIDER RESULT] "
+ "Wait share->init too long, table_name %s %s %ld\n",
+ share->table_name, share->tgt_hosts[0], share->tgt_ports[0]);
+ *error_num = ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM;
+ my_printf_error(ER_SPIDER_TABLE_OPEN_TIMEOUT_NUM,
+ ER_SPIDER_TABLE_OPEN_TIMEOUT_STR, MYF(0),
+ table_share->db.str, table_share->table_name.str);
+ spider_free_share(share);
+ DBUG_RETURN(NULL);
+ }
+ my_sleep(10000); // wait 10 ms
+ }
+
+ spider->share = share;
+
+ if (spider_init_share(table_name, table, thd, spider, error_num, share,
+ table_share, FALSE))
+ DBUG_RETURN(NULL);
+ }
+
+ DBUG_PRINT("info",("spider share=%p", share));
+ DBUG_RETURN(share);
error_hash_insert:
spider_free_share_resource_only(share);
error_alloc_share:
pthread_mutex_unlock(&spider_tbl_mutex);
-error_open_sys_table:
-error_crd_spider_init:
-error_sts_spider_init:
- if (init_mem_root)
- {
- free_root(&mem_root, MYF(0));
- init_mem_root = FALSE;
- }
-error_but_no_delete:
DBUG_RETURN(NULL);
}
@@ -5877,46 +5607,6 @@ int spider_free_wide_share(
DBUG_RETURN(0);
}
-void spider_copy_sts_to_wide_share(
- SPIDER_WIDE_SHARE *wide_share,
- SPIDER_SHARE *share
-) {
- DBUG_ENTER("spider_copy_sts_to_pt_share");
- wide_share->stat = share->stat;
- DBUG_VOID_RETURN;
-}
-
-void spider_copy_sts_to_share(
- SPIDER_SHARE *share,
- SPIDER_WIDE_SHARE *wide_share
-) {
- DBUG_ENTER("spider_copy_sts_to_share");
- share->stat = wide_share->stat;
- DBUG_VOID_RETURN;
-}
-
-void spider_copy_crd_to_wide_share(
- SPIDER_WIDE_SHARE *wide_share,
- SPIDER_SHARE *share,
- int fields
-) {
- DBUG_ENTER("spider_copy_crd_to_wide_share");
- memcpy(wide_share->cardinality, share->cardinality,
- sizeof(longlong) * fields);
- DBUG_VOID_RETURN;
-}
-
-void spider_copy_crd_to_share(
- SPIDER_SHARE *share,
- SPIDER_WIDE_SHARE *wide_share,
- int fields
-) {
- DBUG_ENTER("spider_copy_crd_to_share");
- memcpy(share->cardinality, wide_share->cardinality,
- sizeof(longlong) * fields);
- DBUG_VOID_RETURN;
-}
-
int spider_open_all_tables(
SPIDER_TRX *trx,
bool lock
@@ -6515,7 +6205,7 @@ int spider_db_init(
void *p
) {
int error_num = HA_ERR_OUT_OF_MEM, roop_count;
- uint dbton_id = 0;
+ uint dbton_id;
uchar addr[6];
handlerton *spider_hton = (handlerton *)p;
DBUG_ENTER("spider_db_init");
@@ -6795,6 +6485,8 @@ int spider_db_init(
}
}
+ /** Populates `spider_dbton` with available `SPIDER_DBTON`s */
+ dbton_id = 0;
spider_dbton_mysql.dbton_id = dbton_id;
spider_dbton_mysql.db_util->dbton_id = dbton_id;
spider_dbton[dbton_id] = spider_dbton_mysql;
@@ -6803,15 +6495,11 @@ int spider_db_init(
spider_dbton_mariadb.db_util->dbton_id = dbton_id;
spider_dbton[dbton_id] = spider_dbton_mariadb;
++dbton_id;
- for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; roop_count++)
+ for (roop_count = 0; roop_count < (int) dbton_id; roop_count++)
{
- if (spider_dbton[roop_count].init)
- {
- if ((error_num = spider_dbton[roop_count].init()))
- {
+ if (spider_dbton[roop_count].init &&
+ (error_num = spider_dbton[roop_count].init()))
goto error_init_dbton;
- }
- }
}
DBUG_RETURN(0);
@@ -6819,9 +6507,7 @@ error_init_dbton:
for (roop_count--; roop_count >= 0; roop_count--)
{
if (spider_dbton[roop_count].deinit)
- {
spider_dbton[roop_count].deinit();
- }
}
roop_count = spider_param_table_crd_thread_count() - 1;
error_init_table_crd_threads:
@@ -7067,6 +6753,33 @@ void spider_get_partition_info(
DBUG_VOID_RETURN;
}
+/** Determines the get type for spider_get_sts() */
+enum ha_sts_crd_get_type spider_get_sts_type(
+ SPIDER_SHARE *share,
+ double sts_interval,
+ int sts_sync
+) {
+ if (sts_sync == 0)
+ return HA_GET_FETCH;
+ if (!share->wide_share->sts_init)
+ {
+ pthread_mutex_lock(&share->wide_share->sts_mutex);
+ if (!share->wide_share->sts_init)
+ return HA_GET_AFTER_LOCK;
+ pthread_mutex_unlock(&share->wide_share->sts_mutex);
+ return HA_GET_COPY;
+ }
+ if (difftime(share->sts_get_time, share->wide_share->sts_get_time) <
+ sts_interval)
+ return HA_GET_COPY;
+ if (!pthread_mutex_trylock(&share->wide_share->sts_mutex))
+ return HA_GET_AFTER_TRYLOCK;
+ return HA_GET_COPY;
+}
+
+/**
+ Populates share->stat or share->wide_share->stat with table status.
+*/
int spider_get_sts(
SPIDER_SHARE *share,
int link_idx,
@@ -7078,85 +6791,51 @@ int spider_get_sts(
int sts_sync_level,
uint flag
) {
- int get_type;
int error_num = 0;
bool need_to_get = TRUE;
DBUG_ENTER("spider_get_sts");
- if (
- sts_sync == 0
- ) {
- /* get */
- get_type = 1;
- } else if (
- !share->wide_share->sts_init
- ) {
- pthread_mutex_lock(&share->wide_share->sts_mutex);
- if (!share->wide_share->sts_init)
- {
- /* get after mutex_lock */
- get_type = 2;
- } else {
- pthread_mutex_unlock(&share->wide_share->sts_mutex);
- /* copy */
- get_type = 0;
- }
- } else if (
- difftime(share->sts_get_time, share->wide_share->sts_get_time) <
- sts_interval
- ) {
- /* copy */
- get_type = 0;
- } else if (
- !pthread_mutex_trylock(&share->wide_share->sts_mutex)
- ) {
- /* get after mutex_trylock */
- get_type = 3;
- } else {
- /* copy */
- get_type = 0;
- }
- if (
- !share->sts_init &&
- share->table_share->tmp_table == NO_TMP_TABLE &&
- spider_param_load_sts_at_startup(share->load_sts_at_startup) &&
- (!share->init || share->init_error)
- ) {
+ enum ha_sts_crd_get_type get_type =
+ spider_get_sts_type(share, sts_interval, sts_sync);
+ if (!share->sts_init &&
+ share->table_share->tmp_table == NO_TMP_TABLE &&
+ spider_param_load_sts_at_startup(share->load_sts_at_startup) &&
+ (!share->init || share->init_error))
+ {
error_num = spider_sys_get_table_sts(
current_thd,
share->lgtm_tblhnd_share->table_name,
share->lgtm_tblhnd_share->table_name_length,
&share->stat
);
- if (
- !error_num ||
- (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
- )
+ if (!error_num ||
+ (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE))
need_to_get = FALSE;
}
if (need_to_get)
{
- if (get_type == 0)
- spider_copy_sts_to_share(share, share->wide_share);
- else {
+ if (get_type == HA_GET_COPY)
+ share->stat = share->wide_share->stat;
+ else
+ /* Executes a `show table status` query and store the results in
+ share->stat */
error_num = spider_db_show_table_status(spider, link_idx, sts_mode, flag);
- }
}
- if (get_type >= 2)
+ if (get_type >= HA_GET_AFTER_LOCK)
pthread_mutex_unlock(&share->wide_share->sts_mutex);
+
if (error_num)
{
SPIDER_PARTITION_HANDLER *partition_handler =
spider->partition_handler;
- if (
- !share->wide_share->sts_init &&
- sts_sync >= sts_sync_level &&
- get_type > 1 &&
- partition_handler &&
- partition_handler->handlers &&
- partition_handler->handlers[0] == spider
- ) {
+ if (!share->wide_share->sts_init &&
+ sts_sync >= sts_sync_level &&
+ get_type > HA_GET_FETCH &&
+ partition_handler &&
+ partition_handler->handlers &&
+ partition_handler->handlers[0] == spider)
+ {
int roop_count;
ha_spider *tmp_spider;
SPIDER_SHARE *tmp_share;
@@ -7165,24 +6844,23 @@ int spider_get_sts(
int tmp_sts_sync;
THD *thd = spider->wide_handler->trx->thd;
for (roop_count = 1;
- roop_count < (int) partition_handler->no_parts;
- roop_count++)
+ roop_count < (int) partition_handler->no_parts;
+ roop_count++)
{
- tmp_spider =
- (ha_spider *) partition_handler->handlers[roop_count];
+ tmp_spider = (ha_spider *) partition_handler->handlers[roop_count];
tmp_share = tmp_spider->share;
tmp_sts_interval = spider_param_sts_interval(thd, share->sts_interval);
tmp_sts_mode = spider_param_sts_mode(thd, share->sts_mode);
tmp_sts_sync = spider_param_sts_sync(thd, share->sts_sync);
- spider_get_sts(tmp_share, tmp_spider->search_link_idx,
- tmp_time, tmp_spider, tmp_sts_interval, tmp_sts_mode, tmp_sts_sync,
- 1, flag);
+ spider_get_sts(tmp_share, tmp_spider->search_link_idx, tmp_time,
+ tmp_spider, tmp_sts_interval, tmp_sts_mode,
+ tmp_sts_sync, 1, flag);
if (share->wide_share->sts_init)
{
error_num = 0;
thd->clear_error();
- get_type = 0;
- spider_copy_sts_to_share(share, share->wide_share);
+ get_type = HA_GET_COPY;
+ share->stat = share->wide_share->stat;
break;
}
}
@@ -7190,9 +6868,10 @@ int spider_get_sts(
if (error_num)
DBUG_RETURN(error_num);
}
- if (sts_sync >= sts_sync_level && get_type > 0)
+
+ if (sts_sync >= sts_sync_level && get_type > HA_GET_COPY)
{
- spider_copy_sts_to_wide_share(share->wide_share, share);
+ share->wide_share->stat = share->stat;
share->wide_share->sts_get_time = tmp_time;
share->wide_share->sts_init = TRUE;
}
@@ -7201,6 +6880,34 @@ int spider_get_sts(
DBUG_RETURN(0);
}
+/** Determines the get type for spider_get_crd() */
+enum ha_sts_crd_get_type spider_get_crd_type(
+ SPIDER_SHARE *share,
+ double crd_interval,
+ int crd_sync
+) {
+ if (crd_sync == 0)
+ return HA_GET_FETCH;
+ if (!share->wide_share->crd_init)
+ {
+ pthread_mutex_lock(&share->wide_share->crd_mutex);
+ if (!share->wide_share->crd_init)
+ return HA_GET_AFTER_LOCK;
+ pthread_mutex_unlock(&share->wide_share->crd_mutex);
+ return HA_GET_COPY;
+ }
+ if (difftime(share->crd_get_time, share->wide_share->crd_get_time) <
+ crd_interval)
+ return HA_GET_COPY;
+ if (!pthread_mutex_trylock(&share->wide_share->crd_mutex))
+ return HA_GET_AFTER_TRYLOCK;
+ return HA_GET_COPY;
+}
+
+/**
+ Populates share->cardinality or share->wide_share->cardinality with
+ table index
+*/
int spider_get_crd(
SPIDER_SHARE *share,
int link_idx,
@@ -7212,49 +6919,16 @@ int spider_get_crd(
int crd_sync,
int crd_sync_level
) {
- int get_type;
int error_num = 0;
bool need_to_get = TRUE;
DBUG_ENTER("spider_get_crd");
- if (
- crd_sync == 0
- ) {
- /* get */
- get_type = 1;
- } else if (
- !share->wide_share->crd_init
- ) {
- pthread_mutex_lock(&share->wide_share->crd_mutex);
- if (!share->wide_share->crd_init)
- {
- /* get after mutex_lock */
- get_type = 2;
- } else {
- pthread_mutex_unlock(&share->wide_share->crd_mutex);
- /* copy */
- get_type = 0;
- }
- } else if (
- difftime(share->crd_get_time, share->wide_share->crd_get_time) <
- crd_interval
- ) {
- /* copy */
- get_type = 0;
- } else if (
- !pthread_mutex_trylock(&share->wide_share->crd_mutex)
- ) {
- /* get after mutex_trylock */
- get_type = 3;
- } else {
- /* copy */
- get_type = 0;
- }
- if (
- !share->crd_init &&
- share->table_share->tmp_table == NO_TMP_TABLE &&
- spider_param_load_sts_at_startup(share->load_crd_at_startup)
- ) {
+ enum ha_sts_crd_get_type get_type =
+ spider_get_crd_type(share, crd_interval, crd_sync);
+ if (!share->crd_init &&
+ share->table_share->tmp_table == NO_TMP_TABLE &&
+ spider_param_load_sts_at_startup(share->load_crd_at_startup))
+ {
error_num = spider_sys_get_table_crd(
current_thd,
share->lgtm_tblhnd_share->table_name,
@@ -7262,36 +6936,31 @@ int spider_get_crd(
share->cardinality,
table->s->fields
);
- if (
- !error_num ||
- (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE)
- )
+ if (!error_num ||
+ (error_num != HA_ERR_KEY_NOT_FOUND && error_num != HA_ERR_END_OF_FILE))
need_to_get = FALSE;
}
if (need_to_get)
{
- if (get_type == 0)
- spider_copy_crd_to_share(share, share->wide_share,
- table->s->fields);
- else {
+ if (get_type == HA_GET_COPY)
+ memcpy(share->cardinality, share->wide_share->cardinality,
+ sizeof(longlong) * table->s->fields);
+ else
error_num = spider_db_show_index(spider, link_idx, table, crd_mode);
- }
}
- if (get_type >= 2)
+ if (get_type >= HA_GET_AFTER_LOCK)
pthread_mutex_unlock(&share->wide_share->crd_mutex);
if (error_num)
{
- SPIDER_PARTITION_HANDLER *partition_handler =
- spider->partition_handler;
- if (
- !share->wide_share->crd_init &&
- crd_sync >= crd_sync_level &&
- get_type > 1 &&
- partition_handler &&
- partition_handler->handlers &&
- partition_handler->handlers[0] == spider
- ) {
+ SPIDER_PARTITION_HANDLER *partition_handler = spider->partition_handler;
+ if (!share->wide_share->crd_init &&
+ crd_sync >= crd_sync_level &&
+ get_type > HA_GET_FETCH &&
+ partition_handler &&
+ partition_handler->handlers &&
+ partition_handler->handlers[0] == spider)
+ {
int roop_count;
ha_spider *tmp_spider;
SPIDER_SHARE *tmp_share;
@@ -7300,25 +6969,24 @@ int spider_get_crd(
int tmp_crd_sync;
THD *thd = spider->wide_handler->trx->thd;
for (roop_count = 1;
- roop_count < (int) partition_handler->no_parts;
- roop_count++)
+ roop_count < (int) partition_handler->no_parts;
+ roop_count++)
{
- tmp_spider =
- (ha_spider *) partition_handler->handlers[roop_count];
+ tmp_spider = (ha_spider *) partition_handler->handlers[roop_count];
tmp_share = tmp_spider->share;
tmp_crd_interval = spider_param_crd_interval(thd, share->crd_interval);
tmp_crd_mode = spider_param_crd_mode(thd, share->crd_mode);
tmp_crd_sync = spider_param_crd_sync(thd, share->crd_sync);
- spider_get_crd(tmp_share, tmp_spider->search_link_idx,
- tmp_time, tmp_spider, table, tmp_crd_interval, tmp_crd_mode,
- tmp_crd_sync, 1);
+ spider_get_crd(tmp_share, tmp_spider->search_link_idx, tmp_time,
+ tmp_spider, table, tmp_crd_interval, tmp_crd_mode,
+ tmp_crd_sync, 1);
if (share->wide_share->crd_init)
{
error_num = 0;
thd->clear_error();
- get_type = 0;
- spider_copy_crd_to_share(share, share->wide_share,
- table->s->fields);
+ get_type = HA_GET_COPY;
+ memcpy(share->cardinality, share->wide_share->cardinality,
+ sizeof(longlong) * table->s->fields);
break;
}
}
@@ -7326,10 +6994,10 @@ int spider_get_crd(
if (error_num)
DBUG_RETURN(error_num);
}
- if (crd_sync >= crd_sync_level && get_type > 0)
+ if (crd_sync >= crd_sync_level && get_type > HA_GET_COPY)
{
- spider_copy_crd_to_wide_share(share->wide_share, share,
- table->s->fields);
+ memcpy(share->wide_share->cardinality, share->cardinality,
+ sizeof(longlong) * table->s->fields);
share->wide_share->crd_get_time = tmp_time;
share->wide_share->crd_init = TRUE;
}
@@ -7374,6 +7042,18 @@ void spider_set_result_list_param(
DBUG_VOID_RETURN;
}
+/**
+ Gets or creates a `SPIDER_INIT_ERROR_TABLE` with the table name from
+ a given `SPIDER_SHARE`
+
+ When creating, also add the newly created object to
+ `spider_init_error_tables`
+
+ @param trx Transaction
+ @param share The spider share providing the table name
+ @param create Whether to create a new `SPIDER_INIT_ERROR_TABLE` if one wi th the required table name does not exist yet
+ @return A `SPIDER_INIT_ERROR_TABLE` or NULL if failure
+*/
SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table(
SPIDER_TRX *trx,
SPIDER_SHARE *share,
@@ -7393,11 +7073,10 @@ SPIDER_INIT_ERROR_TABLE *spider_get_init_error_table(
pthread_mutex_unlock(&spider_init_error_tbl_mutex);
DBUG_RETURN(NULL);
}
- if (!(spider_init_error_table = (SPIDER_INIT_ERROR_TABLE *)
- spider_bulk_malloc(spider_current_trx, 54, MYF(MY_WME | MY_ZEROFILL),
+ if (!spider_bulk_malloc(spider_current_trx, 54, MYF(MY_WME | MY_ZEROFILL),
&spider_init_error_table, (uint) (sizeof(*spider_init_error_table)),
&tmp_name, (uint) (share->table_name_length + 1),
- NullS))
+ NullS)
) {
pthread_mutex_unlock(&spider_init_error_tbl_mutex);
DBUG_RETURN(NULL);
@@ -8404,6 +8083,7 @@ ulong spider_calc_for_sort(
DBUG_RETURN(sort);
}
+/** Generates a random number between 0 and 1 */
double spider_rand(
uint32 rand_source
) {
@@ -9085,6 +8765,8 @@ void *spider_table_bg_sts_action(
thd->mysys_var->current_cond = &thread->cond;
thd->mysys_var->current_mutex = &thread->mutex;
}
+ bool spd_wsrep_on = thd->variables.wsrep_on;
+ thd->variables.wsrep_on = false;
while (spider_init_queries[i].length && !thd->killed && !thread->killed &&
thread->init_command)
{
@@ -9098,6 +8780,7 @@ void *spider_table_bg_sts_action(
}
++i;
}
+ thd->variables.wsrep_on = spd_wsrep_on;
thd->mysys_var->current_cond = &thread->cond;
thd->mysys_var->current_mutex = &thread->mutex;
thd->client_capabilities -= CLIENT_MULTI_RESULTS;
diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h
index 9b6eecb9d56..b5c265aff9d 100644
--- a/storage/spider/spd_table.h
+++ b/storage/spider/spd_table.h
@@ -493,28 +493,6 @@ int spider_free_wide_share(
SPIDER_WIDE_SHARE *wide_share
);
-void spider_copy_sts_to_wide_share(
- SPIDER_WIDE_SHARE *wide_share,
- SPIDER_SHARE *share
-);
-
-void spider_copy_sts_to_share(
- SPIDER_SHARE *share,
- SPIDER_WIDE_SHARE *wide_share
-);
-
-void spider_copy_crd_to_wide_share(
- SPIDER_WIDE_SHARE *wide_share,
- SPIDER_SHARE *share,
- int fields
-);
-
-void spider_copy_crd_to_share(
- SPIDER_SHARE *share,
- SPIDER_WIDE_SHARE *wide_share,
- int fields
-);
-
int spider_open_all_tables(
SPIDER_TRX *trx,
bool lock
diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc
index a6c5ea8f85a..3361f485d58 100644
--- a/storage/spider/spd_trx.cc
+++ b/storage/spider/spd_trx.cc
@@ -3872,46 +3872,59 @@ void spider_reuse_trx_ha(
DBUG_VOID_RETURN;
}
+/**
+ Sets link indices for load balancing read connections
+
+ Assuming `spider->share->link_count` is the number of active servers
+ to use, this function updates `spider->conn_link_idx` with the first
+ server in the same "modulus group" whose link status is not
+ `SPIDER_LINK_STATUS_NG`, or if one cannot be found, use the
+ `link_idx`th server
+*/
void spider_trx_set_link_idx_for_all(
ha_spider *spider
) {
- int roop_count, roop_count2;
SPIDER_SHARE *share = spider->share;
long *link_statuses = share->link_statuses;
uint *conn_link_idx = spider->conn_link_idx;
- int link_count = share->link_count;
- int all_link_count = share->all_link_count;
+ uint link_count = share->link_count;
+ uint all_link_count = share->all_link_count;
uchar *conn_can_fo = spider->conn_can_fo;
DBUG_ENTER("spider_trx_set_link_idx_for_all");
DBUG_PRINT("info",("spider set link_count=%d", link_count));
DBUG_PRINT("info",("spider set all_link_count=%d", all_link_count));
memset(conn_can_fo, 0, sizeof(uchar) * share->link_bitmap_size);
- for (roop_count = 0; roop_count < link_count; roop_count++)
- {
- for (roop_count2 = roop_count; roop_count2 < all_link_count;
- roop_count2 += link_count)
+ /* We change the name from roop_count and roop_count2 to link_idx
+ and all_link_idx because the latter are generally used in the
+ same context. */
+ for (uint link_idx = 0; link_idx < link_count; link_idx++)
+ {
+ uint all_link_idx;
+ for (all_link_idx = link_idx; all_link_idx < all_link_count;
+ all_link_idx += link_count)
{
- if (link_statuses[roop_count2] <= SPIDER_LINK_STATUS_RECOVERY)
+ if (link_statuses[all_link_idx] <= SPIDER_LINK_STATUS_RECOVERY)
break;
}
- if (roop_count2 < all_link_count)
+ if (all_link_idx < all_link_count)
{
- conn_link_idx[roop_count] = roop_count2;
- if (roop_count2 + link_count < all_link_count)
- spider_set_bit(conn_can_fo, roop_count);
+ conn_link_idx[link_idx] = all_link_idx;
+ if (all_link_idx + link_count < all_link_count)
+ spider_set_bit(conn_can_fo, link_idx);
DBUG_PRINT("info",("spider set conn_link_idx[%d]=%d",
- roop_count, roop_count2));
- } else {
- conn_link_idx[roop_count] = roop_count;
+ link_idx, all_link_idx));
+ } else
+ {
+ conn_link_idx[link_idx] = link_idx;
DBUG_PRINT("info",("spider set2 conn_link_idx[%d]=%d",
- roop_count, roop_count));
+ link_idx, link_idx));
}
- spider->conn_keys[roop_count] =
+ spider->conn_keys[link_idx] =
ADD_TO_PTR(spider->conn_keys_first_ptr,
- PTR_BYTE_DIFF(share->conn_keys[conn_link_idx[roop_count]],
+ PTR_BYTE_DIFF(share->conn_keys[conn_link_idx[link_idx]],
share->conn_keys[0]), char*);
DBUG_PRINT("info",("spider conn_keys[%d]=%s",
- roop_count, spider->conn_keys[roop_count]));
+ link_idx, spider->conn_keys[link_idx]));
}
DBUG_VOID_RETURN;
}