๐Ÿ”’Mysql์˜ ์ž ๊ธˆ(Lock)๊ณผ ๋ฐ๋“œ๋ฝ(DeadLock) ๋ฐœ์ƒ

KwonKusangยท2022๋…„ 11์›” 7์ผ
2

๋ฉ€ํ‹ฐ ํŠธ๋žœ์žญ์…˜ ํ™˜๊ฒฝ์—์„œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์ผ๊ด€์„ฑ๊ณผ ๋ฌด๊ฒฐ์„ฑ์„ ์œ ์ง€ํ•˜๋ ค๋ฉด ํŠธ๋žœ์žญ์…˜์˜ ์ˆœ์ฐจ์  ์ง„ํ–‰์„ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ๋Š” ์ง๋ ฌํ™” ์žฅ์น˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค. DB๋Š” ์—ฌ๋Ÿฌ ๊ฒฉ๋ฆฌ ์ˆ˜์ค€๊ณผ Lock ๋ฐฉ์‹์ด ์กด์žฌํ•œ๋‹ค.

1. ํŠธ๋žœ์žญ์…˜ ๊ฒฉ๋ฆฌ ์ˆ˜์ค€(isolation level)

DB๊ฐ€ ์„ค์ •ํ•˜๋Š” ๊ฒฉ๋ฆฌ ์ˆ˜์ค€์€ ์•„๋ž˜ 4๊ฐ€์ง€ ๋ฐฉ์‹์œผ๋กœ ์ •์˜๋œ๋‹ค.

  • READ UNCOMMITTED (์ปค๋ฐ‹๋˜์ง€ ์•Š์€ ์ฝ๊ธฐ)
  • READ COMMITTED (์ปค๋ฐ‹๋œ ์ฝ๊ธฐ)
  • REPEATABLE READ (๋ฐ˜๋ณต ๊ฐ€๋Šฅํ•œ ์ฝ๊ธฐ)
  • SERIALIZABLE (์ง๋ ฌํ™” ๊ฐ€๋Šฅ)

๊ฐ๊ฐ์˜ ๊ฒฉ๋ฆฌ ์ˆ˜์ค€์—์„œ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ ๋“ค์ด ์กด์žฌํ•˜๋‹ˆ ํ•œ ๋ฒˆ ์ฐพ์•„๋ณด๋Š” ๊ฒƒ๋„ ๋„์›€์ด ๋  ๊ฒƒ์ด๋‹ค.

Mysql ๊ฒฉ๋ฆฌ ์ˆ˜์ค€

Mysql์€ REPEATABLE READ๋ฅผ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ํ•ด๋‹น ๊ฒฉ๋ฆฌ ์ˆ˜์ค€์—์„œ ๋ฐœ์ƒํ•˜๋Š” PANTHOM READ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š”๋ฐ InnoDB ์Šคํ† ๋ฆฌ์ง€ ์—”์ง„์€ ๋„ฅ์ŠคํŠธ ํ‚ค ๋ฝ (Next key lock)์„ ์ด์šฉํ•˜์—ฌ ํ•ด๊ฒฐํ•˜์˜€๋‹ค.

MySQL ํŠธ๋žœ์žญ์…˜๊ณผ ๋ฝ - InnoDB ๋ฝ, ์ด๋ ‡๊ฒŒ ๋™์ž‘ํ•œ๋‹ค!

2. Lock์˜ ์ข…๋ฅ˜

๋Œ€ํ‘œ์ ์œผ๋กœ ์•„๋ž˜ 2๊ฐ€์ง€์˜ Lock์ด ์กด์žฌํ•œ๋‹ค.

  • S-Lock์€ ๊ณต์œ  ์ž ๊ธˆ(Shared-Lock), ์ฝ๊ธฐ ์ž ๊ธˆ(Read Lock)
  • X-Lock์€ ๋ฐฐํƒ€์  ์ž ๊ธˆ(Exclusive-Lock), ์“ฐ๊ธฐ ์ž ๊ธˆ(Write Lock)

S-Lock (์ฝ๊ธฐ ์ž ๊ธˆ)

ํŠน์ • Row๋ฅผ ์ฝ์„(Read) ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. A ํŠธ๋žœ์žญ์…˜์—์„œ ํŠน์ • Row์— S-Lock์„ ๊ฑธ์—ˆ๋‹ค๋ฉด, B ํŠธ๋žœ์žญ์…˜์—์„œ๋Š” ์ฝ๊ธฐ๋Š” ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์“ฐ๊ธฐ๋Š” ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

์ฆ‰, ๋‹ค๋ฅธ ํŠธ๋žœ์žญ์…˜์—์„œ S-Lock์€ ๊ฑธ ์ˆ˜ ์žˆ์ง€๋งŒ X-Lock์€ ๊ฑธ ์ˆ˜ ์—†๋‹ค.

X-Lock (์“ฐ๊ธฐ ์ž ๊ธˆ)

ํŠน์ • Row๋ฅผ ๋ณ€๊ฒฝ(Write)ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. A ํŠธ๋žœ์žญ์…˜์—์„œ ํŠน์ • Row์— X-Lock์„ ๊ฑธ์—ˆ๋‹ค๋ฉด, B ํŠธ๋žœ์žญ์…˜์—์„œ๋Š” ํ•ด๋‹น Row๋ฅผ ์ฝ๊ธฐ, ์“ฐ๊ธฐ ๋ชจ๋‘ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ํ•ด๋‹น A ํŠธ๋žœ์žญ์…˜์ด ๊ฑด Lock์ด ์ข…๋ฃŒ๋˜๊ธธ ๊ธฐ๋‹ค๋ฆฐ๋‹ค.

์ฆ‰, ๋‹ค๋ฅธ ํŠธ๋žœ์žญ์…˜์—์„œ S-Lock, X-Lock์„ ๊ฑธ ์ˆ˜ ์—†๋‹ค.

X-Lock์€ SELECT ... FOR UPDATE, UPDATE, DELETE ๋“ฑ์˜ ๋ณ€๊ฒฝ ์ฟผ๋ฆฌ๋ฅผ ๋‚ ๋ฆฌ๋ฉด ๊ฐ๊ฐ์˜ Row๋งˆ๋‹ค ์ž ๊ธˆ์ด ๊ฑธ๋ฆฌ๋Š” Row-Level-Lock์ด๋‹ค.

Intention lock

ํ…Œ์ด๋ธ” ์•ˆ์˜ ํŠน์ • Row์— ๋Œ€ํ•ด์„œ ๋‚˜์ค‘์— ์–ด๋–ค Row-Level Lock์„ ๊ฑธ ๊ฒƒ์ด๋ผ๋Š” ์˜๋„๋ฅผ ์•Œ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด ๋ฏธ๋ฆฌ Table-Level์— ๊ฑธ์–ด๋‘๋Š” Lock์ด๋‹ค.

Intention Shared Lock (IS), Intention Exclusive Lock (IX) ์กด์žฌํ•œ๋‹ค.

  • SELECT ... LOCK IN SHARE MODE ์ด ์‹คํ–‰๋˜๋ฉด,
    - ๋จผ์ € Intention Shared Lock (IS) ์ด ํ…Œ์ด๋ธ”์— ๊ฑธ๋ฆฐ๋‹ค.
    - ๊ทธ ํ›„ Row-Level์— S lock์ด ๊ฑธ๋ฆฐ๋‹ค.
  • SELECT ... FOR UPDATE, INSERT, DELETE, UPDATE ์ด ์‹คํ–‰๋˜๋ฉด,
    - ๋จผ์ € Intention Exclusive Lock (IX) ์ด ํ…Œ์ด๋ธ”์— ๊ฑธ๋ฆฐ๋‹ค.
    - ๊ทธ ํ›„ Row-Level์— X lock์ด ๊ฑธ๋ฆฐ๋‹ค.

์ฐธ๊ณ 

Q. Table-level์—์„œ ํ•œ๋ฒˆ, Row-Level์—์„œ ํ•œ๋ฒˆ, 2๋‹จ๊ณ„(2-phase)๋กœ Lock์„ ์ ์šฉํ•˜๋Š” ์ด์œ ๋Š”?

A. ํŠธ๋žœ์žญ์…˜ A์—์„œ ์ด๋ฏธ ํ…Œ์ด๋ธ”์— ๋Œ€ํ•ด ๋ฝ์ด ๊ฑธ๋ ค์žˆ๋Š”๋ฐ, ํŠธ๋žœ์žญ์…˜ B์—์„œ ํ•ด๋‹น ํ…Œ์ด๋ธ”์˜ ํŠน์ • Row์— Lock์„ ๊ฑฐ๋Š”๊ฒƒ์„ ์›์ฒœ์ ์œผ๋กœ ๋ฐฉ์ง€ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ฐ˜๋Œ€์˜ ๊ฒฝ์šฐ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ด๋‹ค.

  • ex) Row-Level์˜ write์ด ์ผ์–ด๋‚˜๊ณ  ์žˆ์„๋•Œ ํ…Œ์ด๋ธ” ์Šคํ‚ค๋งˆ๊ฐ€ ๋ณ€๊ฒฝ๋˜์–ด์„œ๋Š” ์•ˆ๋œ๋‹ค. Write query์˜ ๊ฒฝ์šฐ ์ด๋ฏธ IX ๋ฝ์„ ํš๋“ํ•œ ์ƒํƒœ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น ํ…Œ์ด๋ธ”์˜ ์Šคํ‚ค๋งˆ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋Š”๊ฒƒ์„ ๋ง‰์„ ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ’ก UPDATE ํ•  ๋•Œ!
๋ณดํ†ต์€ย UPDATE๋˜๋Š” ๋Œ€์ƒ row์—ย  Lock์ด ๊ฑธ๋ฆฌ์ง€๋งŒ, WHERE ์ ˆ์— ์ธ๋ฑ์Šค๋ฅผ ์ ์ ˆํžˆ ํƒœ์šฐ์ง€ ์•Š๊ฑฐ๋‚˜ ์ธ๋ฑ์Šค๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ๋Š”ย ํ…Œ์ด๋ธ” ์ „์ฒด์— Lock์ด ๊ฑธ๋ฆฐ๋‹ค.

Lock์˜ ์ข…๋ฅ˜ (Shared Lock, Exclusive Lock, Record Lock, Gap Lock, Next-key Lock)

3. SELECT์™€ S-Lock โœ”

๋‚˜๋Š” SELECT๋ฅผ ํ•˜๋ฉด ํ•ด๋‹น Row์— S-Lock์ด ๊ฑธ๋ฆฐ๋‹ค๊ณ  ์ƒ๊ฐํ•œ ์ ์ด ์žˆ๋‹ค. S-Lock์„ ๊ฐœ๋…์ ์œผ๋กœ ์ดํ•ดํ•œ ํ›„ ์ฝ๊ธฐ๋Š” SELECT ์ ˆ์„ ์˜๋ฏธํ•œ๋‹ค๊ณ  ์˜คํ•ดํ–ˆ๋‹ค.๐Ÿ˜ฅ ์ดํ›„ DeadLock ๋ฐœ์ƒ ์›์ธ์„ ํŠธ๋ž˜ํ‚น ํ•˜๋ฉด์„œ ์ดํ•ดํ–ˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋˜ S-Lock์— ๊ต‰์žฅํžˆ ํ˜ผ๋™์ด ์™€์„œ ์ง€๊ธˆ ๋‹ค์‹œ ํ•™์Šตํ•˜๊ณ ์ž ํ•œ๋‹ค.

์ผ๋ฐ˜์ ์ธ SELECT ์ฟผ๋ฆฌ๋Š” ์ž ๊ธˆ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  DB๋ฅผ ์ฝ์–ด ๋“ค์ธ๋‹ค. SELECT๋Š” ํŠน์ • Row๋ฅผ ์ฝ์€ ํ–‰์œ„์ผ๋ฟ์ด์ง€ ์ž ๊ธˆ์„ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค ๋ผ๋Š” ๋ง์ด ๊นŠ์ด ์™€๋‹ฟ์•˜๋‹ค.

์‹ค์ œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ์„ ๋•Œ ๋‹ค๋ฅธ ํŠธ๋žœ์žญ์…˜์—์„œ ๋ณ€๊ฒฝ(Write)๊ฐ€ ๊ฐ€๋Šฅํ•œ ๊ฒƒ์„ ์ง์ ‘ ํ™•์ธํ–ˆ๋‹ค.

4. SELECT โ€ฆ FOR UPDATE

ํŠน์ • Row๋ฅผ ์กฐํšŒ ์‹œ์— X-Lock์„ ๊ฑธ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ์กด์žฌํ•œ๋‹ค. ๋ช…์นญ์„ ๋ณด๋”๋ผ๋„ UPDATE ์ ˆ์„ ์œ„ํ•ด Row ์กฐํšŒ๋ฅผ ํ•˜์˜€๊ณ  ํŠธ๋žœ์žญ์…˜์ด ์ข…๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๋ณ€๊ฒฝ๋˜๊ธธ ์›์น˜ ์•Š๋Š”๋‹ค! ๋ผ๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

SQL ๋ฌธ๋ฒ•์œผ๋กœ๋Š” SELECT ์ ˆ ๋’ค์— FOR UPDATE๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค.

SELECT * FROM USERS FOR UPDATE

JPA์—์„œ๋Š” Repository์˜ @Lock ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ ์ž ๊ธˆ์„ ์„ค์ •ํ•œ๋‹ค.

public interface UserRepository extends JpaRepository<User, Long> {
  @Lock(LockModeType.PESSIMISTIC_READ)
  User findById(Long id);
}

์ฐธ๊ณ ๋กœ @Lock ์–ด๋…ธํ…Œ์ด์…˜์—๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ์ž ๊ธˆ์ด ์กด์žฌํ•œ๋‹ค.

  • @Lock(LockModeType.PESSIMISTIC_READ)
    ํ•ด๋‹น ๋ฆฌ์†Œ์Šค์— ๊ณต์œ  ์ž ๊ธˆ์„ ๊ฑด๋‹ค. ๋‹ค๋ฅธ ํŠธ๋žœ์žญ์…˜์—์„œ ์ฝ๊ธฐ๋Š” ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์“ฐ๊ธฐ๋Š” ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

  • @Lock(LockModeType.PESSIMISTIC_WRITE)
    ํ•ด๋‹น ๋ฆฌ์†Œ์Šค์— ๋ฐฐํƒ€์  ์ž ๊ธˆ์„ ๊ฑด๋‹ค. ๋‹ค๋ฅธ ํŠธ๋žœ์žญ์…˜์—์„œ๋Š” ์ฝ๊ธฐ์™€ ์“ฐ๊ธฐ ๋ชจ๋‘ ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค.

  • @Lock(LockModeType.PESSIMISTIC_FORCE_INCREMENT)
    PESSIMISTIC_WRITE์™€ ์œ ์‚ฌํ•˜๊ฒŒ ์ž‘๋™ํ•˜์ง€๋งŒ ์ถ”๊ฐ€์ ์œผ๋กœ ๋‚™๊ด€์  ์ž ๊ธˆ์ฒ˜๋Ÿผ ๋ฒ„์ €๋‹์„ ํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ๋ฒ„์ „์— ๋Œ€ํ•œ ์นผ๋Ÿผ์ด ํ•„์š”ํ•˜๋‹ค.

Select ์ฟผ๋ฆฌ๋Š” S๋ฝ์ด ์•„๋‹ˆ๋‹ค. (X๋ฝ๊ณผ S๋ฝ์˜ ์ฐจ์ด)

5. ์™ธ๋ž˜ํ‚ค(Foreign Key) ์ž ๊ธˆ ์ „ํŒŒ

์™ธ๋ž˜ํ‚ค ์นผ๋Ÿผ์˜ ๋ณ€๊ฒฝ(INSERT, UPDATE) ์‹œ ๋ถ€๋ชจ ํ…Œ์ด๋ธ”์ด๋‚˜ ์ž์‹ ํ…Œ์ด๋ธ”์— ๋ฐ์ดํ„ฐ๊ฐ€ ์กด์žฌํ•˜๋Š” ์ง€ ํ™•์ธ ์ ˆ์ฐจ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ์ž ๊ธˆ์ด ์—ฐ๊ด€ ๊ด€๊ณ„๋ฅผ ๋งบ๊ณ  ์žˆ๋Š” ์—ฌ๋Ÿฌ ํ…Œ์ด๋ธ”๋กœ ์ž ๊ธˆ์ด ์ „ํŒŒ๋œ๋‹ค. ํ•ด๋‹น ๋ณ€๊ฒฝ ์ž‘์—…์„ ์œ„ํ•ด ์™ธ๋ž˜ํ‚ค ์ปฌ๋Ÿผ์— S-Lock์ด ๊ฑธ๋ฆฌ๊ฒŒ ๋˜๊ณ  ๊ทธ๋กœ ์ธํ•ด ๋ฐ๋“œ๋ฝ(DeadLock) ๋ฐœ์ƒ ์›์ธ์ด ๋  ์ˆ˜ ์žˆ์Œ์œผ๋กœ ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค.

6. ๋ฐ๋“œ๋ฝ(DeadLock)

๋ฉ€ํ‹ฐ ํŠธ๋žœ์žญ์…˜ ๊ฐ„ ๊ต์ฐฉ ์ƒํƒœ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ์ž ๊ธˆ ๋•Œ๋ฌธ์— ์„œ๋กœ์˜ ์ž ๊ธˆ์ด ํ’€๋ฆฌ๊ธฐ๋ฅผ ๋ฌดํ•œํžˆ ๋Œ€๊ธฐํ•˜๋Š” ์ƒํ™ฉ์ด๋‹ค. ๋ณดํ†ต์€ ํŠธ๋žœ์žญ์…˜์˜ ์ฟผ๋ฆฌ ์ˆœ์„œ๋ฅผ ์กฐ์œจํ•˜์—ฌ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๊ณ  ๋‚™๊ด€์  ์ž ๊ธˆ(Optimistic Lock)์œผ๋กœ ์–ด๋Š ์ •๋„์˜ ๋กค๋ฐฑ์„ ํ—ˆ์šฉํ•˜๋ฉฐ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.

๋ฐ๋“œ๋ฝ ๋ฐœ์ƒ ํŠธ๋ž˜ํ‚น๐Ÿšง

๋ฐ๋“œ๋ฝ์„ ๋ฐœ์ƒ ์›์ธ์„ ํ•œ๋ฒˆ์— ์ถ”์ ํ•˜๊ธฐ๋Š” ์‰ฝ์ง€ ์•Š๋‹ค. ์ƒํƒœ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” SQL๋ฌธ์„ ์‹คํ–‰ํ•˜๋ฉด latest detection deadlock ๋ถ€๋ถ„์ด ์กด์žฌํ•˜์—ฌ ์ตœ๊ทผ์— ๋ฐ๋“œ๋ฝ์ด ๋ฐœ์ƒํ•œ ์ฟผ๋ฆฌ๋ฅผ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.

SHOW ENGINE INNODB STATUS

APM(Application Performance Management)

์ด๋ฒˆ ๊ฒฝ์šฐ์—๋Š” APM์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ๋“œ๋ฝ์ด ๋ฐœ์ƒํ•œ ํŠธ๋žœ์žญ์…˜๊ณผ ๊ฐ™์€ ์‹œ๊ธฐ์— ์‹คํ–‰๋˜๊ณ  ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•  ๋งŒํ•œ ์ฟผ๋ฆฌ๋ฅผ ์˜ˆ์ƒํ•ด๋ณผ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

(Exception์ด ๋ฐœ์ƒํ•  ๋•Œ ๋ฐ๋“œ๋ฝ์ด ๋ฐœ์ƒํ•œ 2๊ฐœ์˜ ์ฟผ๋ฆฌ ๋ชจ๋‘ ๋กœ๊ทธ๋ฅผ ์ฐ์–ด์ฃผ๋ฉด ์›์ธ ๋ถ„์„์ด ์‰ฌ์šธํ…๋ฐโ€ฆ๐Ÿ˜ฅ)

ํ•ด๊ฒฐ ๋ฐฉ์•ˆ

์ฟผ๋ฆฌ ์ˆœ์„œ๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ ์™ธ๋ž˜ํ‚ค์— ์˜ํ•œ ์ž ๊ธˆ ์ „ํŒŒ๊ฐ€ ์ด๋ฒˆ ๋ฐ๋“œ๋ฝ์˜ ๋ฐœ์ƒ ์›์ธ์ด์—ˆ๋‹ค.

์ฟผ๋ฆฌ ์‹คํ–‰ ์ˆœ์„œ๋ฅผ ์ˆœ์ฐจ์ ์œผ๋กœ ํ™•์ธํ•ด๋ณด์ž.

  • ํŠธ๋žœ์žญ์…˜ A๋Š” ํฌ์ง€์…˜(Position) ํ…Œ์ด๋ธ”์˜ ํŠน์ • Row ๋ณ€๊ฒฝ์„ ์œ„ํ•ด X-Lock์„ ๊ฑด๋‹ค.
    - PK์— ๋Œ€ํ•œ ์ธ๋ฑ์Šค๋ฅผ ํƒ”๊ธฐ ๋•Œ๋ฌธ์— Table-Level Lock์€ ๊ฑธ๋ฆฌ์ง€ ์•Š๋Š”๋‹ค.

  • ํŠธ๋žœ์žญ์…˜ B๋Š” Row์˜ INSERT ์ ˆ์„ ์‹คํ–‰ํ•˜๋ ค ํ•œ๋‹ค. ๋ฉ”์‹œ์ง€(Message) ํ…Œ์ด๋ธ”์€ ์ง€์›์ž(Applicant), ํฌ์ง€์…˜(Position) ํ…Œ์ด๋ธ”์— ์™ธ๋ž˜ํ‚ค๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.
    - 16535 PK์˜ ์ง€์›์ž๋ฅผ ์กฐํšŒํ•˜์—ฌ S-Lock์ด ์ „ํŒŒ๋œ๋‹ค.
    - 1446 PK์˜ ํฌ์ง€์…˜์„ ์กฐํšŒํ•˜์—ฌ S-Lock์ด ์ „ํŒŒ๋˜๋Š”๋ฐ ํŠธ๋žœ์žญ์…˜ A์—์„œ ์ด๋ฏธ X-Lock์ด ๊ฑธ๋ ธ์œผ๋ฏ€๋กœ ๋Œ€๊ธฐ ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

  • ํŠธ๋žœ์žญ์…˜ A์—์„œ 16535 PK์˜ ์ง€์›์ž(Applicant)๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค ํ•œ๋‹ค. ํŠธ๋žœ์žญ์…˜ B์—์„œ X-Lock์ด ๊ฑธ๋ ธ์œผ๋ฏ€๋กœ ๋Œ€๊ธฐ ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

  • ํŠธ๋žœ์žญ์…˜ A, B๊ฐ€ ์„œ๋กœ์˜ ์ž ๊ธˆ์ด ํ’€๋ฆฌ๊ธฐ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๊ต์ฐฉ ์ƒํƒœ์— ๋น ์ง„๋‹ค.

๊ฐ„๋‹จํ•˜๊ฒŒ ํŠธ๋žœ์žญ์…˜ A์˜ ์ฟผ๋ฆฌ ์‹คํ–‰ ์ˆœ์„œ๋ฅผ ๋’ค๋ฐ”๊ฟ”์ฃผ๋ฉฐ ๊ต์ฐฉ ์ƒํƒœ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋‹ค.

์ง€์›์ž(Applicant)์˜ UPDATE ์ ˆ์„ ๋จผ์ € ์‹คํ–‰ํ•˜๊ณ  ํฌ์ง€์…˜(Position)์˜ UPDATE ์ ˆ์„ ์ฒ˜๋ฆฌํ•œ๋‹ค. 16535 PK์˜ ์ง€์›์ž Row์— ๋Œ€ํ•ด ๋จผ์ € X-Lock์„ ํš๋“ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํŠธ๋žœ์žญ์…˜ B์˜ INSERT๋Š” ์™ธ๋ž˜ํ‚ค์ธ ์ง€์›์ž๋ฅผ ์กฐํšŒํ•˜๋Š” ๊ณผ์ •์—์„œ ๋Œ€๊ธฐ ์ƒํƒœ๊ฐ€ ๋œ๋‹ค.

profile
์•ˆ๋…•ํ•˜์„ธ์š”! ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ์ž ๊ถŒ๊ตฌ์ƒ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€