TIL
-
2024.08.06 Intention lockTIL 2024. 8. 6. 22:18
MySQL :: MySQL 8.4 Reference Manual :: 17.7.1 InnoDB LockingMySQL 8.4 Reference Manual / ... / The InnoDB Storage Engine / InnoDB Locking and Transaction Model / InnoDB Locking This section describes lock types used by InnoDB. Shared and Exclusive Locks InnoDB implements standard row-level locking wdev.mysql.com오늘도 이어서.. Intention lock은 테이블 수준의 lock으로 잠금의도를 나타내는 lock입니다. Sql에 따라 IS, IX l..
-
2024.08.05 Locks Set by SQL 3, INSERT INTO T SELECT ... FROM S WHERE..TIL 2024. 8. 5. 23:05
MySQL :: MySQL 8.0 Reference Manual :: 17.7.3 Locks Set by Different SQL Statements in InnoDB17.7.3 Locks Set by Different SQL Statements in InnoDB A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of an SQL statement. It does not matter whether there are WHERE conditions in dev.mysql.com INSERT INTO ... SELECT Performance w..
-
2024.08.02~04 Locks Set by SQL 2TIL 2024. 8. 4. 17:12
MySQL :: MySQL 8.0 Reference Manual :: 17.7.3 Locks Set by Different SQL Statements in InnoDB17.7.3 Locks Set by Different SQL Statements in InnoDB A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of an SQL statement. It does not matter whether there are WHERE conditions indev.mysql.com읽은 부분은 insert 시 발생하는 lock에 관한 부분입니다. I..
-
2024.08.01 Locks Set by SQLTIL 2024. 8. 1. 23:59
MySQL :: MySQL 8.0 Reference Manual :: 17.7.3 Locks Set by Different SQL Statements in InnoDB17.7.3 Locks Set by Different SQL Statements in InnoDB A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of an SQL statement. It does not matter whether there are WHERE conditions indev.mysql.comgap lock을 공부하려 이거 저거 읽어보는 중.. sql에 따라 ..
-
2024.07.27~28 gap lockTIL 2024. 8. 1. 00:42
락 관련 문서 MySQL Gap Lock (두번째 이야기)Why ?medium.com 위의 글을 보면 데이터 페이지에 따른 잠금을 소개하고 있다.. 실제 개발 시 이런 것까지 확인하기는 힘든데, 이로 인해 잠금이 발생한 다는 것을 모를 수 있다. gap lock을 사용하는 쿼리를 사용할 때 데이터 페이지에 마지막이 조건의 끝에 들어간다면 supremum pseudo-record에 락을 잡는다는 것이다. 존재하지 않는 행에 대한 gap lock SELECT … FOR UPDATE on non-existent rowsi am interested about locks when "select ... for update on non-existed rows"; currently, the data in table '..
-
2024.07.23 gap lockTIL 2024. 7. 23. 00:17
gap lock MySQL Gap Lock 다시보기우리가 일반적으로 알고 있는 데이터베이스 서버의 잠금(Lock)은 레코드 자체에 대한 잠금(Record Lock)이에요. 어떤 트랜잭션에서 레코드를 변경하기 위해서는 그 레코드를 잠그고, 그 동안은 다른medium.com음 pk와 uk는 gap lock을 사용하지 않고 record lock만 사용.non unique secondary index는 항상 record lock과 gap lock을 사용. 값이 없을 때는 record lock 없이 gap lock만 획득 -> select, delete가 대기 없이 실행.4, 5가 'INSERT Intention Gap Lock'을 필요로 하고 서로의 gap lock을 기다리면서 dead lock이 발생.pk,..
-
2024.07.22 gap lockTIL 2024. 7. 22. 23:04
InnoDB의 Lock 처리 방식 - miintto.log필자가 속한 개발팀의 여러 Django 프로젝트에서는 데이터베이스의 동시성을 제어하기 위해 select_for_update() 메소드가 적용되어 있습니다. 비슷하게 SQLAlchemy 라이브러리에서는 with_for_update() 메소miintto.github.ioselect for update를 이어서 보면..mysql에서는 next key lock을 사용한다(innodb repeatable read). gap lock과 record lock을 합친 형태.인덱스를 걸지 않은 컬럼에 사용하면 테이블 fullscan하니 테이블 전체에 lock이 걸린다. 조심하라. uk를 조건에 사용하면 next key lock을 사용하지 않고 단일 레코드에만 ..
-
2024.07.21 select for updateTIL 2024. 7. 21. 21:48
select for update 시 행이 없다면? select .. for update 대상 유무에 따른 잠금 상태개요 InnoDB 엔진은 기본적으로 DDL 쿼리를 제외한 모든 데이터 조작 작업에서 테이블 락을 사용하지 않고 레코드 기반의 잠금 방식을 사용합니다. 더 자세히는 레코드 자체보다는 인덱스에 잠금dkswnkk.tistory.com select for update 시 잠금에 대한 내용이다.요약하자면 repeatable read 격리 수준에서 phantom read를 막기 위해 gap lock을 잡는다아래와 같이 처음 발견된 레코드(12)와 쿼리가 정의한 범위 내의 빈 공간의 수정을 방지하는 것이다.SELECT * FROM t_user WHERE id > 10 FOR UPDATE; 존재하지 않는 ..