您的位置:首页 > Web前端

innodb_locks_unsafe_for_binlog

2011-06-13 12:50 519 查看
disable next-key lock

This variable affects how
InnoDB
uses gap locking for searches and index scans. Normally,
InnoDB
uses an algorithm called next-key locking that combines index-row locking with gap locking.
InnoDB
performs row-level locking in such a way that when it searches or scans a table index, it sets shared or exclusive locks on the index records it encounters. Thus, the row-level locks are actually index-record locks. In addition, a next-key lock on an index record also affects the “gap” before that index record. That is, a next-key lock is an index-record lock plus a gap lock on the gap preceding the index record. If one session has a shared or exclusive lock on record
R
in an index, another session cannot insert a new index record in the gap immediately before
R
in the index order.

By default, the value of
innodb_locks_unsafe_for_binlog
is 0 (disabled), which means that gap locking is enabled:
InnoDB
uses next-key locks for searches and index scans. To enable the variable, set it to 1. This causes gap locking to be disabled:
InnoDB
uses only index-record locks for searches and index scans.

The effect of enabling
innodb_locks_unsafe_for_binlog
is similar to but not identical to setting the transaction isolation level to
READ           COMMITTED
:

Enabling
innodb_locks_unsafe_for_binlog
is a global setting and affects all sessions, whereas the isolation level can be set globally for all sessions, or individually per session.

innodb_locks_unsafe_for_binlog
can be set only at server startup, whereas the isolation level can be set at startup or changed at runtime.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  休闲 innodb binlog