[Commits] 707f99c8fa2: Merge branch 'fb-mysql-8.0.17' of github.com:facebook/mysql-5.6 into fb-mysql-8.0.17-range-locking-jan21
revision-id: 707f99c8fa29ff58a7dd96eb5b74d2ea181d8fa5 (fb-prod8-202009-57-g707f99c8fa2) parent(s): f370d1f9563c28a1d5bd7cb2d8a8b48177195b03 540b5f6266f4f2d935299cae4476e9e9c506c6b3 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-02-01 13:22:16 +0300 message: Merge branch 'fb-mysql-8.0.17' of github.com:facebook/mysql-5.6 into fb-mysql-8.0.17-range-locking-jan21 CMakeLists.txt | 4 +- config.h.cmake | 1 + configure.cmake | 6 +- include/CMakeLists.txt | 153 + include/my_base.h | 6 +- include/my_md5.h | 23 + include/my_md5_size.h | 5 +- include/my_sys.h | 6 + include/mysql.h | 2 + include/mysql.h.pp | 2 + .../mysql/components/services/psi_statement_bits.h | 24 + .../components/services/psi_statement_service.h | 8 + .../mysql/components/services/psi_thread_bits.h | 20 + .../mysql/components/services/psi_thread_service.h | 6 + include/mysql/psi/psi_abi_statement_v1.h.pp | 9 + include/mysql/psi/psi_abi_thread_v1.h.pp | 6 + include/mysql/psi/psi_statement.h | 4 + include/mysql/psi/psi_thread.h | 6 + include/mysql/service_thd_wait.h | 5 +- include/pfs_statement_provider.h | 6 + include/pfs_thread_provider.h | 6 + include/sql_common.h | 27 + include/violite.h | 7 +- libmysql/CMakeLists.txt | 3 +- mysql-test/include/as_root.inc | 3 + mysql-test/include/rpl_init_raft.inc | 4 +- mysql-test/include/show_raft_logs.inc | 5 + mysql-test/mysql-test-run.pl | 37 +- mysql-test/r/admission_control.result | 25 +- ...dmission_control_multi_query_wait_events.result | 8 + mysql-test/r/admission_control_queue.result | 22 + mysql-test/r/admission_control_yield.result | 101 + mysql-test/r/admission_control_yield_debug.result | 30 + mysql-test/r/dd_is_compatibility_cs.result | 1 + .../r/disconnect_on_shutdown_semisync.result | 33 + mysql-test/r/information_schema_cs.result | 14 +- mysql-test/r/information_schema_db.result | 1 + mysql-test/r/kill.result | 8 +- mysql-test/r/max_db_connections.result | 306 ++ mysql-test/r/max_db_connections_stress.result | 46 + mysql-test/r/max_filesort_size.result | 63 +- mysql-test/r/max_tmp_disk_usage_stress.result | 26 + mysql-test/r/max_tmp_table_size.result | 175 + mysql-test/r/mysqld--help-notwin.result | 97 +- mysql-test/r/mysqlshow_cs.result | 2 + mysql-test/r/sql_findings_basic.result | 89 + .../r/sql_maximum_duplicate_executions.result | 190 + mysql-test/r/thread_priorities_basic.result | 108 + mysql-test/r/update.result | 2 +- mysql-test/r/variables.result | 1 + .../column_statistics/r/group_by_order_by.result | 54 + mysql-test/suite/column_statistics/r/joins.result | 110 + .../column_statistics/r/nested_statements.result | 62 + .../suite/column_statistics/r/recursion.result | 119 + .../suite/column_statistics/r/select_insert.result | 56 + .../column_statistics/r/select_replace.result | 52 + .../suite/column_statistics/r/simple_delete.result | 37 + .../suite/column_statistics/r/simple_select.result | 96 + .../suite/column_statistics/r/simple_update.result | 37 + mysql-test/suite/column_statistics/r/unions.result | 66 + .../column_statistics/t/group_by_order_by.test | 47 + mysql-test/suite/column_statistics/t/joins.test | 70 + .../column_statistics/t/nested_statements.test | 58 + .../suite/column_statistics/t/recursion.test | 115 + .../suite/column_statistics/t/select_insert.test | 55 + .../suite/column_statistics/t/select_replace.test | 61 + .../suite/column_statistics/t/simple_delete.test | 38 + .../suite/column_statistics/t/simple_select.test | 71 + .../suite/column_statistics/t/simple_update.test | 37 + mysql-test/suite/column_statistics/t/unions.test | 54 + mysql-test/suite/innodb/r/innodb-ucs2.result | 8 +- .../suite/innodb/r/session_temp_tablespaces.result | 44 +- .../suite/innodb/t/session_temp_tablespaces.test | 3 +- mysql-test/suite/innodb_fts/r/opt.result | 10 +- .../r/innodb_segment_reserve_factor.result | 19 + .../t/innodb_segment_reserve_factor-master.opt | 1 + .../t/innodb_segment_reserve_factor.dat.gz | Bin 0 -> 370063 bytes .../t/innodb_segment_reserve_factor.test | 41 + .../include/statements_filesort_disk_usage.inc | 119 + .../perfschema/include/statements_skipped.inc | 59 + .../include/statements_tmp_table_disk_usage.inc | 119 + mysql-test/suite/perfschema/r/all_tests.result | 2 + .../suite/perfschema/r/dd_version_check.result | 2 +- .../perfschema/r/ddl_column_statistics.result | 11 + .../suite/perfschema/r/ddl_sql_findings.result | 11 + .../perfschema/r/dml_column_statistics.result | 19 + .../suite/perfschema/r/dml_esms_by_digest.result | 4 +- .../suite/perfschema/r/dml_esms_by_program.result | 4 +- mysql-test/suite/perfschema/r/dml_handler.result | 224 +- .../r/dml_prepared_statements_instances.result | 4 +- .../perfschema/r/dml_setup_instruments.result | 4 +- .../suite/perfschema/r/dml_sql_findings.result | 19 + .../r/idx_events_statements_history_long.result | 12 +- mysql-test/suite/perfschema/r/idx_threads.result | 36 +- .../suite/perfschema/r/information_schema.result | 20 + mysql-test/suite/perfschema/r/misc.result | 2 +- .../suite/perfschema/r/rpl_statements.result | 2 +- mysql-test/suite/perfschema/r/schema.result | 46 +- .../r/start_server_disable_statements.result | 10 +- .../suite/perfschema/r/start_server_nothing.result | 18 +- .../perfschema/r/statement_digest_charset.result | 2 +- .../r/statements_filesort_disk_usage.result | 201 + .../r/statements_tmp_table_disk_usage.result | 190 + mysql-test/suite/perfschema/r/table_schema.result | 100 +- .../suite/perfschema/t/dd_version_check.test | 2 +- .../suite/perfschema/t/ddl_column_statistics.test | 21 + .../suite/perfschema/t/ddl_sql_findings.test | 21 + .../suite/perfschema/t/dml_column_statistics.test | 35 + .../suite/perfschema/t/dml_sql_findings.test | 35 + .../t/statements_filesort_disk_usage.test | 231 ++ .../t/statements_tmp_table_disk_usage.test | 226 + mysql-test/suite/rocksdb/combinations | 5 +- mysql-test/suite/rocksdb/include/bulk_load.inc | 2 +- .../rocksdb/r/alter_column_default_inplace.result | 73 + mysql-test/suite/rocksdb/r/bulk_load.result | 4 +- mysql-test/suite/rocksdb/r/bulk_load_rev_cf.result | 4 +- .../rocksdb/r/bulk_load_rev_cf_and_data.result | 4 +- .../suite/rocksdb/r/bulk_load_rev_data.result | 4 +- .../suite/rocksdb/r/bypass_select_basic.result | 156 + .../rocksdb/r/bypass_select_basic_bloom.result | 156 + .../r/insert_duplicate_key_update_race.result | 2 + mysql-test/suite/rocksdb/r/perf_context.result | 4 - mysql-test/suite/rocksdb/r/rocksdb.result | 7 + .../rocksdb/r/rocksdb_deadlock_detect_rc.result | 1 - .../rocksdb/r/rocksdb_deadlock_detect_rr.result | 1 - mysql-test/suite/rocksdb/r/rocksdb_mrr.result | 87 +- .../r/track_and_verify_wals_in_manifest.result | 33 + .../rocksdb/t/allow_to_start_after_corruption.test | 1 + .../rocksdb/t/alter_column_default_inplace.cnf | 7 + .../rocksdb/t/alter_column_default_inplace.test | 89 + mysql-test/suite/rocksdb/t/bypass_select_basic.inc | 112 + mysql-test/suite/rocksdb/t/force_shutdown.test | 1 + mysql-test/suite/rocksdb/t/init_failure.test | 2 + .../t/insert_duplicate_key_update_race.test | 2 + mysql-test/suite/rocksdb/t/perf_context.test | 22 +- .../suite/rocksdb/t/rocksdb_deadlock_detect.inc | 16 +- mysql-test/suite/rocksdb/t/rocksdb_mrr.test | 53 +- .../t/track_and_verify_wals_in_manifest.test | 109 + mysql-test/suite/rocksdb_rpl/combinations | 5 + ..._gtid_crash_safe_wal_corrupt_dual_engine.result | 2 + .../t/rpl_gtid_crash_safe_wal_corrupt.inc | 33 +- ...pl_gtid_crash_safe_wal_corrupt_dual_engine.test | 40 +- ...cksdb_alter_column_default_inplace_basic.result | 75 + .../r/rocksdb_trace_queries_basic.result | 48 + ..._track_and_verify_wals_in_manifest_basic.result | 14 + ...ocksdb_write_batch_flush_threshold_basic.result | 100 + ...rocksdb_alter_column_default_inplace_basic.test | 21 + .../t/rocksdb_trace_block_cache_access_basic.test | 5 + .../t/rocksdb_trace_queries_basic.test | 69 + ...db_track_and_verify_wals_in_manifest_basic.test | 16 + .../rocksdb_write_batch_flush_threshold_basic.test | 18 + .../rpl/r/replication_lag_auto_throttling.result | 300 +- .../rpl_rbr_column_type_mismatch_whitelist.result | 4380 ++++---------------- mysql-test/suite/rpl/r/rpl_write_abort.result | 2649 ++++++++++++ mysql-test/suite/rpl/r/write_statistics.result | 2 +- .../rpl/t/replication_lag_auto_throttling.test | 193 +- .../t/rpl_rbr_column_type_mismatch_whitelist.test | 18 +- .../rpl_semi_sync_master_crash_if_active_trxs.test | 1 + mysql-test/suite/rpl/t/rpl_write_abort.test | 2021 +++++++++ .../rpl_raft/include/raft_promote_to_leader.inc | 6 +- mysql-test/suite/rpl_raft/my.cnf | 10 +- .../r/rpl_raft_auto_purge_apply_logs.result | 345 ++ .../rpl_raft_auto_purge_apply_logs_restart.result | 148 + .../r/rpl_raft_leader_election_simple.result | 86 + .../suite/rpl_raft/r/rpl_raft_purge_logs.result | 180 + .../rpl_raft/r/rpl_raft_purge_raft_logs.result | 325 ++ .../r/rpl_raft_purge_raft_logs_before_date.result | 341 ++ .../rpl_raft/r/rpl_raft_show_raft_logs.result | 96 + .../t/rpl_raft_auto_purge_apply_logs-master.opt | 2 + .../t/rpl_raft_auto_purge_apply_logs-slave.opt | 2 + .../rpl_raft/t/rpl_raft_auto_purge_apply_logs.test | 198 + ...l_raft_auto_purge_apply_logs_restart-master.opt | 2 + ...pl_raft_auto_purge_apply_logs_restart-slave.opt | 2 + .../t/rpl_raft_auto_purge_apply_logs_restart.test | 113 + .../t/rpl_raft_leader_election_simple.test | 128 + .../suite/rpl_raft/t/rpl_raft_purge_logs.test | 250 ++ .../rpl_raft/t/rpl_raft_purge_raft_logs-master.opt | 2 + .../rpl_raft/t/rpl_raft_purge_raft_logs-slave.opt | 2 + .../suite/rpl_raft/t/rpl_raft_purge_raft_logs.test | 286 ++ ...rpl_raft_purge_raft_logs_before_date-master.opt | 2 + .../rpl_raft_purge_raft_logs_before_date-slave.opt | 2 + .../t/rpl_raft_purge_raft_logs_before_date.test | 275 ++ .../suite/rpl_raft/t/rpl_raft_show_raft_logs.test | 149 + .../r/admission_control_wait_events_basic.result | 30 + .../r/admission_control_yield_freq_basic.result | 62 + .../sys_vars/r/column_stats_control_basic.result | 18 + .../suite/sys_vars/r/disallow_raft_basic.result | 4 +- .../sys_vars/r/enable_raft_plugin_basic.result | 3 +- .../innodb_log_wait_for_ready_timeout_basic.result | 74 + .../r/innodb_segment_reserve_factor_basic.result | 18 + .../sys_vars/r/innodb_sync_pool_size_basic.result | 36 + .../sys_vars/r/max_db_connections_basic.result | 131 + .../sys_vars/r/max_tmp_disk_usage_basic.result | 81 + .../r/reset_period_status_vars_basic.result | 45 + .../sql_duplicate_executions_control_basic.result | 51 + .../sys_vars/r/sql_findings_control_basic.result | 27 + .../sql_maximum_duplicate_executions_basic.result | 27 + .../r/thread_priority_as_root_basic.result | 73 + .../suite/sys_vars/r/thread_priority_basic.result | 17 + .../sys_vars/r/thread_priority_str_basic.result | 11 + .../r/write_cpu_limit_milliseconds_basic.result | 32 + .../sys_vars/r/write_time_check_batch_basic.result | 32 + .../t/admission_control_wait_events_basic.test | 23 + .../t/admission_control_yield_freq_basic.test | 41 + .../sys_vars/t/column_stats_control_basic.test | 14 + .../suite/sys_vars/t/enable_raft_plugin_basic.test | 7 +- .../t/innodb_log_wait_for_ready_timeout_basic.test | 88 + .../t/innodb_segment_reserve_factor_basic.test | 13 + .../sys_vars/t/innodb_sync_pool_size_basic.test | 69 + .../suite/sys_vars/t/max_db_connections_basic.test | 96 + .../suite/sys_vars/t/max_tmp_disk_usage_basic.test | 105 + .../sys_vars/t/reset_period_status_vars_basic.test | 57 + .../t/sql_duplicate_executions_control_basic.test | 55 + .../sys_vars/t/sql_findings_control_basic.test | 43 + .../t/sql_maximum_duplicate_executions_basic.test | 43 + .../sys_vars/t/thread_priority_as_root_basic.test | 63 + .../suite/sys_vars/t/thread_priority_basic.test | 19 + .../sys_vars/t/thread_priority_str_basic.test | 17 + .../t/write_cpu_limit_milliseconds_basic.test | 38 + .../sys_vars/t/write_time_check_batch_basic.test | 38 + mysql-test/t/admission_control.test | 19 +- mysql-test/t/admission_control_multi_query.py | 25 +- ...sion_control_multi_query_wait_events-master.opt | 1 + .../admission_control_multi_query_wait_events.test | 16 + mysql-test/t/admission_control_queue.test | 10 + mysql-test/t/admission_control_yield.test | 263 ++ mysql-test/t/admission_control_yield_debug.test | 100 + mysql-test/t/all_persisted_variables.test | 8 - .../t/disconnect_on_shutdown_semisync-master.opt | 2 + mysql-test/t/disconnect_on_shutdown_semisync.test | 68 + mysql-test/t/information_schema_cs.test | 2 +- mysql-test/t/kill.test | 6 +- mysql-test/t/max_db_connections.test | 266 ++ mysql-test/t/max_db_connections_stress.py | 104 + mysql-test/t/max_db_connections_stress.test | 40 + mysql-test/t/max_filesort_size.test | 98 +- mysql-test/t/max_tmp_disk_usage_stress.py | 123 + mysql-test/t/max_tmp_disk_usage_stress.test | 47 + mysql-test/t/max_tmp_table_size.test | 257 ++ mysql-test/t/sql_findings_basic.test | 130 + mysql-test/t/sql_maximum_duplicate_executions.test | 247 ++ mysql-test/t/thread_priorities_basic.test | 162 + mysql-test/valgrind.supp | 1 + mysys/mf_cache.cc | 1 + mysys/mf_iocache.cc | 20 + mysys/my_handler_errors.h | 4 +- mysys/psi_noop.cc | 21 + scripts/mysql_sys_schema.sql | 4 +- scripts/mysqld_safe.sh | 5 + share/errmsg-utf8.txt | 827 ++-- sql-common/client.cc | 283 +- sql-common/net_serv.cc | 11 + sql/CMakeLists.txt | 79 +- sql/auth/sql_authentication.cc | 19 +- sql/auth/sql_authorization.cc | 7 +- sql/binlog.cc | 94 +- sql/binlog.h | 5 +- sql/column_statistics.cc | 523 +++ sql/column_statistics.h | 225 + sql/column_statistics_dt.h | 70 + sql/conn_handler/connection_handler_manager.cc | 10 + sql/conn_handler/connection_handler_manager.h | 10 +- sql/conn_handler/connection_handler_per_thread.cc | 5 + sql/create_field.cc | 2 +- sql/debug_lock_order.cc | 14 + sql/field.h | 6 +- sql/field_conv.cc | 22 +- sql/filesort.cc | 66 +- sql/filesort_utils.cc | 7 +- sql/handler.cc | 127 +- sql/log_event.h | 31 +- sql/mdl.cc | 4 +- sql/merge_many_buff.h | 4 +- sql/mysqld.cc | 326 +- sql/mysqld.h | 108 +- sql/opt_range.cc | 1 + sql/parse_tree_nodes.cc | 1 + sql/parse_tree_nodes.h | 6 + sql/partitioning/partition_base.cc | 13 +- sql/rpl_applier_reader.cc | 15 + sql/rpl_applier_reader.h | 11 + sql/rpl_handler.cc | 7 +- sql/rpl_lag_manager.cc | 54 +- sql/rpl_lag_manager.h | 2 + sql/rpl_record.cc | 4 +- sql/rpl_slave.cc | 55 +- sql/rpl_slave.h | 2 + sql/sql_admission_control.cc | 746 +++- sql/sql_admission_control.h | 339 +- sql/sql_base.h | 3 + sql/sql_class.cc | 460 +- sql/sql_class.h | 168 +- sql/sql_connect.cc | 2 + sql/sql_db.cc | 48 +- sql/sql_db.h | 1 + sql/sql_derived.cc | 3 +- sql/sql_info.cc | 454 ++ sql/sql_info.h | 92 + sql/sql_lex.h | 9 + sql/sql_parse.cc | 118 +- sql/sql_plugin.cc | 34 +- sql/sql_select.cc | 14 + sql/sql_show.cc | 14 +- sql/sql_show_status.cc | 3 + sql/sql_sort.h | 4 + sql/sql_thd_api.cc | 38 + sql/sql_yacc.yy | 7 +- sql/sys_vars.cc | 301 +- sql/sys_vars.h | 2 + sql/system_variables.cc | 2 - sql/system_variables.h | 16 +- sql/table.h | 3 +- storage/innobase/dict/dict0stats.cc | 7 +- storage/innobase/fil/fil0fil.cc | 26 + storage/innobase/fsp/fsp0fsp.cc | 13 +- storage/innobase/handler/ha_innodb.cc | 60 + storage/innobase/handler/ha_innodb.h | 9 + storage/innobase/include/fil0fil.h | 6 + storage/innobase/include/fsp0fsp.h | 13 +- storage/innobase/include/ib0mutex.h | 13 +- storage/innobase/include/log0log.h | 3 + storage/innobase/include/os0event.h | 7 +- storage/innobase/include/os0event_impl.h | 303 ++ storage/innobase/include/srv0srv.h | 5 + storage/innobase/include/sync0rw.h | 8 +- storage/innobase/include/sync0rw.ic | 6 +- storage/innobase/include/ut0mutex.ic | 2 +- storage/innobase/include/ut0ut.h | 21 + storage/innobase/log/log0write.cc | 3 +- storage/innobase/os/os0event.cc | 403 +- storage/innobase/row/row0mysql.cc | 4 +- storage/innobase/row/row0pread.cc | 5 +- storage/innobase/srv/srv0srv.cc | 16 +- storage/innobase/sync/sync0arr.cc | 4 +- storage/innobase/sync/sync0rw.cc | 8 +- storage/innobase/trx/trx0purge.cc | 10 +- storage/perfschema/CMakeLists.txt | 4 + storage/perfschema/ha_perfschema.cc | 2 +- storage/perfschema/pfs.cc | 167 +- storage/perfschema/pfs_dd_version.h | 23 +- storage/perfschema/pfs_engine_table.cc | 4 + storage/perfschema/pfs_events_statements.h | 6 + storage/perfschema/pfs_instr.h | 4 + storage/perfschema/pfs_stat.h | 9 + storage/perfschema/table_column_statistics.cc | 169 + storage/perfschema/table_column_statistics.h | 109 + .../table_esms_by_account_by_event_name.cc | 3 + storage/perfschema/table_esms_by_all.cc | 28 +- storage/perfschema/table_esms_by_all.h | 5 +- storage/perfschema/table_esms_by_digest.cc | 19 +- .../perfschema/table_esms_by_host_by_event_name.cc | 3 + storage/perfschema/table_esms_by_program.cc | 3 + .../table_esms_by_thread_by_event_name.cc | 3 + .../perfschema/table_esms_by_user_by_event_name.cc | 3 + .../perfschema/table_esms_global_by_event_name.cc | 3 + storage/perfschema/table_events_statements.cc | 50 +- storage/perfschema/table_events_statements.h | 6 + storage/perfschema/table_helper.cc | 9 + storage/perfschema/table_helper.h | 9 + .../perfschema/table_prepared_stmt_instances.cc | 3 + storage/perfschema/table_sql_findings.cc | 171 + storage/perfschema/table_sql_findings.h | 114 + storage/perfschema/table_threads.cc | 13 + storage/perfschema/table_threads.h | 2 + storage/perfschema/unittest/pfs_noop-t.cc | 2 + storage/rocksdb/ha_rocksdb.cc | 305 +- storage/rocksdb/ha_rocksdb.h | 7 +- storage/rocksdb/nosql_access.cc | 6 +- storage/rocksdb/rdb_global.h | 4 +- storage/rocksdb/rdb_mutex_wrapper.cc | 7 + storage/rocksdb/rdb_sst_info.cc | 2 +- storage/temptable/src/handler.cc | 2 + testclients/mysql_client_fw.cc | 213 + testclients/mysql_client_test.cc | 235 +- unittest/gunit/innodb/log0log-t.cc | 3 + unittest/gunit/xplugin/xpl/stubs/pfs.cc | 3 + vio/viossl.cc | 23 +- 377 files changed, 25371 insertions(+), 5821 deletions(-) diff --cc mysql-test/suite/rocksdb/combinations index 54cce2c205b,acf2f49a0c3..5e3b56932c6 --- a/mysql-test/suite/rocksdb/combinations +++ b/mysql-test/suite/rocksdb/combinations @@@ -4,6 -4,6 +4,9 @@@ rocksdb_write_policy=write_committe [write_prepared] rocksdb_write_policy=write_prepared + [write_unprepared] + rocksdb_write_policy=write_unprepared + rocksdb_write_batch_flush_threshold=1 ++ +[range_locking] +rocksdb_use_range_locking=1 - diff --cc storage/rocksdb/ha_rocksdb.cc index 0f33dfe2a58,6b485cc5073..ae37394a7fb --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@@ -760,14 -763,7 +770,15 @@@ static uint32_t rocksdb_select_bypass_d static unsigned long long // NOLINT(runtime/int) rocksdb_select_bypass_multiget_min = 0; static bool rocksdb_skip_locks_if_skip_unique_check = false; + static bool rocksdb_alter_column_default_inplace = false; +// Range locking: how much memory to use. +// (note that this is different from rocksdb_max_row_locks as +// that one is a hard per-thread count limit, and this one is a +// global memory limit) +static ulonglong rocksdb_max_lock_memory; + +static bool rocksdb_use_range_locking = 0; +std::shared_ptr<rocksdb::RangeLockManagerHandle> range_lock_mgr; std::atomic<uint64_t> rocksdb_row_lock_deadlocks(0); std::atomic<uint64_t> rocksdb_row_lock_wait_timeouts(0); @@@ -2538,10 -2576,10 +2604,11 @@@ static struct SYS_VAR *rocksdb_system_v MYSQL_SYSVAR(max_manual_compactions), MYSQL_SYSVAR(manual_compaction_threads), MYSQL_SYSVAR(rollback_on_timeout), - + MYSQL_SYSVAR(use_range_locking), + MYSQL_SYSVAR(max_lock_memory), MYSQL_SYSVAR(enable_insert_with_update_caching), MYSQL_SYSVAR(trace_block_cache_access), + MYSQL_SYSVAR(trace_queries), MYSQL_SYSVAR(max_compaction_history), MYSQL_SYSVAR(mrr_batch_size), @@@ -2967,20 -3005,8 +3065,20 @@@ class Rdb_transaction virtual void release_lock(const Rdb_key_def &key_descr, const std::string &rowkey) = 0; + virtual + rocksdb::Status lock_range(rocksdb::ColumnFamilyHandle *const cf, + const rocksdb::Endpoint &start, + const rocksdb::Endpoint &end) = 0; + + rocksdb::Status lock_singlepoint_range(rocksdb::ColumnFamilyHandle *const cf, + const rocksdb::Slice &point) { + // Normally, one needs to "flip" the endpoint type for reverse-ordered CFs. + // But here we are locking just one point so this is not necessary. + rocksdb::Endpoint endp(point, false); + return lock_range(cf, endp, endp); + } - virtual bool prepare(const rocksdb::TransactionName &name) = 0; + virtual bool prepare() = 0; bool commit_or_rollback() { bool res; @@@ -3438,8 -3463,8 +3544,9 @@@ virtual bool is_tx_started() const = 0; virtual void start_tx() = 0; - virtual void start_stmt() = 0; + virtual void start_stmt(bool is_dml_statement) = 0; + virtual void start_autocommit_stmt(bool /*is_dml_statement*/){} + virtual void set_name() = 0; protected: // Non-virtual functions with actions to be done on transaction start and @@@ -4184,7 -4176,9 +4303,9 @@@ class Rdb_writebatch_impl : public Rdb_ set_initial_savepoint(); } + void start_stmt(bool /*is_dml_statement*/) override {} + void set_name() override {} + - void start_stmt() override {} void rollback_stmt() override { if (m_batch) rollback_to_stmt_savepoint(); @@@ -5510,11 -5422,19 +5603,21 @@@ static inline void rocksdb_register_tx DBUG_ASSERT(tx != nullptr); trans_register_ha(thd, false, rocksdb_hton, NULL); + if (rocksdb_write_policy == rocksdb::TxnDBWritePolicy::WRITE_UNPREPARED) { + // Some internal operations will call trans_register_ha, but they do not + // go through 2pc. In this case, the xid is set with query_id == 0, which + // means that rocksdb will receive transactions with duplicate names. + // + // Skip setting name in these cases. + if (thd->query_id != 0) { + tx->set_name(); + } + } if (my_core::thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { - tx->start_stmt(); + tx->start_stmt(is_dml_stmt); trans_register_ha(thd, true, rocksdb_hton, NULL); + } else { + tx->start_autocommit_stmt(is_dml_stmt); } } @@@ -16704,8 -16295,7 +16841,7 @@@ const rocksdb::ReadOptions &rdb_tx_acqu rocksdb::Iterator *rdb_tx_get_iterator( Rdb_transaction *tx, const rocksdb::ReadOptions &options, rocksdb::ColumnFamilyHandle *const column_family) { - global_stats.queries[QUERIES_RANGE].inc(); - return tx->get_iterator(options, column_family); + return tx->get_iterator(options, column_family, false); } bool rdb_tx_started(Rdb_transaction *tx) { return tx->is_tx_started(); }
participants (1)
-
psergey