改进 InnoDB 设置 - 导致无法解释的锁

Improving InnoDB settings - causes unexplainable locks

我们在专用服务器上安装了 InnoDB,有时一个简单的连接查询(通常非常快)会导致无限等待并在 30 秒后死亡。

查询看起来像 "SELECT * FROM orders LEFT JOIN orders_products USING(code)"

这是解释:

我确信 InnoDB 是这样的,我不知道为什么,但是当更多的人同时访问脚本时。 我没有在那个脚本中做任何更新或插入,所以它没有意义。

可能是某个地方有一个脚本在执行并发写入,然后这个主脚本可能失败了?我没有任何线索。我在 MyIsam 上从未遇到过问题,我也不使用交易。

我们可以更改设置来解决这个问题吗?

我们有一个很大的服务器,但管理员和我都不知道如何正确设置它。

欢迎提出建议。

这是当前设置:

Variable_name
价值
innodb_adaptive_flushing
上
innodb_adaptive_flushing_lwm
10.000000
innodb_adaptive_hash_index
上
innodb_adaptive_hash_index_分区
1个
innodb_adaptive_max_sleep_delay
150000
innodb_additional_mem_pool_size
8388608
innodb_api_bk_commit_interval
5个
innodb_api_disable_rowlock
离开
innodb_api_enable_binlog
离开
innodb_api_enable_mdl
离开
innodb_api_trx_level
0
innodb_autoextend_increment
64
innodb_autoinc_lock_mode
1个
innodb_background_scrub_data_check_interval
3600
innodb_background_scrub_data_compressed
离开
innodb_background_scrub_data_interval
604800
innodb_background_scrub_data_uncompressed
离开
innodb_buf_dump_status_frequency
0
innodb_buffer_pool_dump_at_shutdown
离开
innodb_buffer_pool_dump_now
离开
innodb_buffer_pool_dump_pct
100
innodb_buffer_pool_filename
ib_buffer_pool
innodb_buffer_pool_instances
2个
innodb_buffer_pool_load_abort
离开
innodb_buffer_pool_load_at_startup
离开
innodb_buffer_pool_load_now
离开
innodb_buffer_pool_populate
离开
innodb_buffer_pool_size
2147483648
innodb_change_buffer_max_size
25
innodb_change_buffering
全部
innodb_checksum_algorithm
CRC32
innodb_checksums
上
innodb_cleaner_lsn_age_factor
HIGH_CHECKPOINT
innodb_cmp_per_index_enabled
离开
innodb_commit_concurrency
0
innodb_compression_algorithm
zlib
innodb_compression_failure_threshold_pct
5个
innodb_compression_level
6个
innodb_compression_pad_pct_max
50
innodb_concurrency_tickets
5000
innodb_corrupt_table_action
断言
innodb_data_file_path
ibdata1:12M:autoextend
innodb_data_home_dir
innodb_default_encryption_key_id
1个
innodb_default_row_format
袖珍的
innodb_defragment
离开
innodb_defragment_fill_factor
0.900000
innodb_defragment_fill_factor_n_recs
20
innodb_defragment_频率
40
innodb_defragment_n_页
7
innodb_defragment_stats_accuracy
0
innodb_disable_sort_file_cache
离开
innodb_disallow_writes
离开
innodb_doublewrite
上
innodb_empty_free_list_algorithm
回退
innodb_encrypt_log
离开
innodb_encrypt_tables
离开
innodb_encryption_rotate_key_age
1个
innodb_encryption_rotation_iops
100
innodb_encryption_threads
0
innodb_fake_changes
离开
innodb_fast_shutdown
1个
innodb_fatal_semaphore_wait_threshold
600
innodb_file_format
梭子鱼
innodb_file_format_检查
上
innodb_file_format_最大
羚羊
innodb_file_per_table
上
innodb_flush_log_at_timeout
1个
innodb_flush_log_at_trx_commit
2个
innodb_flush_method
O_DIRECT
innodb_flush_neighbors
1个
innodb_flushing_avg_loops
30
innodb_force_load_corrupted
离开
innodb_force_primary_key
离开
innodb_force_recovery
0
innodb_foreground_preflush
EXPONENTIAL_BACKOFF
innodb_ft_aux_table
innodb_ft_cache_size
8000000
innodb_ft_enable_diag_print
离开
innodb_ft_enable_stopword
上
innodb_ft_max_token_size
84
innodb_ft_min_token_size
3个
innodb_ft_num_word_optimize
2000
innodb_ft_result_cache_limit
2000000000
innodb_ft_server_stopword_table
innodb_ft_sort_pll_degree
2个
innodb_ft_total_cache_size
640000000
innodb_ft_user_stopword_table
innodb_idle_flush_pct
100
innodb_immediate_scrub_data_uncompressed
离开
innodb_instrument_semaphores
离开
innodb_io_capacity
200
innodb_io_capacity_最大
2000
innodb_kill_idle_transaction
0
innodb_large_prefix
上
innodb_lock_schedule_algorithm
fcfs
innodb_lock_wait_timeout
50
innodb_locking_fake_changes
上
innodb_locks_unsafe_for_binlog
离开
innodb_log_arch_dir
./
Variable_name
价值

innodb_log_arch_expire_sec
0
innodb_log_archive
离开
innodb_log_block_size
512
innodb_log_buffer_size
16777216
innodb_log_checksum_algorithm
创新数据库
innodb_log_compressed_pages
上
innodb_log_file_size
268435456
innodb_log_files_in_group
2个
innodb_log_group_home_dir
./
innodb_lru_scan_depth
1024
innodb_max_bitmap_file_size
104857600
innodb_max_changed_pages
1000000
innodb_max_dirty_pages_pct
75.000000
innodb_max_dirty_pages_pct_lwm
0.001000
innodb_max_purge_lag
0
innodb_max_purge_lag_延迟
0
innodb_mirrored_log_groups
1个
innodb_monitor_disable
innodb_monitor_enable
innodb_monitor_reset
innodb_monitor_reset_全部
innodb_mtflush_threads
8个
innodb_old_blocks_pct
37
innodb_old_blocks_time
1000
innodb_online_alter_log_max_size
134217728
innodb_open_files
5000
innodb_optimize_fulltext_only
离开
innodb_page_size
16384
innodb_prefix_index_cluster_optimization
离开
innodb_print_all_deadlocks
离开
innodb_print_lock_wait_timeout_info
离开
innodb_purge_batch_size
300
innodb_purge_threads
1个
innodb_random_read_ahead
离开
innodb_read_ahead_threshold
56
innodb_read_io_threads
4个
innodb_read_only
离开
innodb_replication_delay
0
innodb_rollback_on_timeout
离开
innodb_rollback_segments
128
innodb_sched_priority_cleaner
19
innodb_scrub_log
离开
innodb_scrub_log_速度
256
innodb_show_locks_held
10
innodb_show_verbose_locks
0
innodb_simulate_comp_failures
0
innodb_sort_buffer_size
1048576
innodb_spin_wait_delay
6个
innodb_stats_auto_recalc
上
innodb_stats_include_delete_marked
离开
innodb_stats_method
nulls_equal
innodb_stats_modified_counter
0
innodb_stats_on_metadata
离开
innodb_stats_persistent
上
innodb_stats_persistent_sample_pages
20
innodb_stats_sample_pages
8个
innodb_stats_traditional
上
innodb_stats_transient_sample_pages
8个
innodb_status_output
离开
innodb_status_output_锁
离开
innodb_strict_mode
离开
innodb_support_xa
上
innodb_sync_array_size
1个
innodb_sync_spin_loops
30
innodb_table_locks
上
innodb_thread_concurrency
0
innodb_thread_sleep_delay
10000
innodb_tmpdir
innodb_track_changed_pages
离开
innodb_undo_directory
.
innodb_undo_logs
128
innodb_undo_tablespaces
0
innodb_use_atomic_writes
离开
innodb_use_fallocate
离开
innodb_use_global_flush_log_at_trx_commit
上
innodb_use_mtflush
离开
innodb_use_native_aio
上
innodb_use_stacktrace
离开
innodb_use_sys_malloc
上
innodb_use_trim
离开
innodb_version
5.6.46-86.2
innodb_write_io_threads
4个

所以,我只是将查询拆分为 2 个查询(很多 rows/conditions),现在可以使用了。

可能是一个困难的查询(尽管它很快)并且当有更多的点击时,它停滞了。同上。