9taetae9 2024. 3. 15. 12:39
728x90

Testing for Conflict Serializability

Consider a schedule with transactions T1, T2, ..., Tn
Precedence graph
A direct graph where the vertices are the transactions
We draw an arc from Ti to Tj if the two transactions conflict, and Ti accesses the data item on which the conflict arises earlier
We may label the arc by the item that is accessed

 

Precedence Graph Example 1

 

 

 

 

 

 

 

 

 

์Šค์ผ€์ค„์— ๋Œ€ํ•œ ์„ ํ–‰ ๊ทธ๋ž˜ํ”„๋ฅผ ์ž‘์„ฑํ•œ ์˜ˆ์ œ์ด๋‹ค. ์„ ํ–‰ ๊ทธ๋ž˜ํ”„์— ์‚ฌ์ดํด์ด ์žˆ์œผ๋ฏ€๋กœ ํ•ด๋‹น ์Šค์ผ€์ค„์€ ์ถฉ๋Œ ์ง๋ ฌ๊ฐ€๋Šฅ ์Šค์ผ€์ค„์ด ์•„๋‹ˆ๋‹ค.

Precedence Graph Example 2

schedule 11

์„ ํ–‰ ๊ทธ๋ž˜ํ”„์— ๋Œ€ํ•œ ์šฐ๋ฆฌ์˜ ๊ด€์‹ฌ์€ ์‚ฌ์ดํด ์กด์žฌ ์—ฌ๋ถ€์ด๋ฏ€๋กœ, ์ค‘๋ณต๋˜๋Š” ์—ฃ์ง€๋Š” ๊ทธ๋ž˜ํ”„ ์ž‘์„ฑ ์‹œ์— ํ‘œ๊ธฐํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

์Šค์ผ€์ค„์— ์˜ํ•œ ์„ ํ–‰ ๊ทธ๋ž˜ํ”„์—๋Š” ์‚ฌ์ดํด์ด ์—†์œผ๋ฏ€๋กœ ํ•ด๋‹น ์Šค์ผ€์ค„์€ ์ถฉ๋Œ ์ง๋ ฌ๊ฐ€๋Šฅ ์Šค์ผ€์ค„์ด๋‹ค.

Cycle detection in precedence graphs is cheap

A schedule is conflict serializable if and only if its precedence graph is acyclic
Cycle-detection algorithms exist which take order n2 (or n+e) time complexity, where n is the number of vertices and e is the number of edges
If precedence graph is acyclic, the serializability order can be obtained by a topological sorting of the graph

 

A linear order consistent with the partial order of the graph
For example, a serializability order for Schedule 11 would be
T
5 -> T1 -> T3 -> T2 -> T4
There are actually 10 serialization orders!!!

์„ ํ–‰ ๊ทธ๋ž˜ํ”„๋Š” ๋ฐฉํ–ฅ์„ฑ ๊ทธ๋ž˜ํ”„์ด๋ฉฐ, ๋ฐฉํ–ฅ์„ฑ ๊ทธ๋ž˜ํ”„์—์„œ ์‚ฌ์ดํด ์กด์žฌ ์—ฌ๋ถ€ ํŒ๋ณ„์€ ๊ฐ„๋‹จํ•˜๊ณ  ์ €๋ ดํ•œ ์—ฐ์‚ฐ์ด๋‹ค.

์œ„์ƒ ์ •๋ ฌ(topological sort)์€ ๋ถ€๋ถ„ ์ˆœ์„œ๋ฅผ ๊ฐ€์ง€๋Š” ๋…ธ๋“œ(ํŠธ๋žœ์žญ์…˜)์— ๋Œ€ํ•˜์—ฌ ๋ถ€๋ถ„ ์ˆœ์„œ๋ฅผ ๋งŒ์กฑํ•˜๋ฉด์„œ ์ „์ฒด ๋…ธ๋“œ๋ฅผ ์ •๋ ฌํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค. ์Šค์ผ€์ค„ 11 ์„ ํ–‰ ๊ทธ๋ž˜ํ”„์—๋Š” ์ด 5๊ฐœ์˜ ๋…ธ๋“œ๊ฐ€ ์žˆ์œผ๋ฉฐ ๋…ธ๋“œ ๊ฐ„์—๋Š” ๋ถ€๋ถ„ ์ˆœ์„œ๊ฐ€ ๊ฒฐ์ •๋˜์–ด ์žˆ๋‹ค. ์Šค์ผ€์ค„ 11 ์„ ํ–‰ ๊ทธ๋ž˜ํ”„์— ๋Œ€ํ•˜์—ฌ ์œ„์ƒ ์ •๋ ฌ์„ ํ•˜๋ฉด T2, T3 ๊ฐ„์—๋Š” ์ˆœ์„œ๊ฐ€ ์—†์œผ๋ฏ€๋กœ 2๊ฐœ ์ •๋ ฌ์ด ๋‚˜์˜ค๊ณ  ๋˜ํ•œ T5๋Š” ๋‹ค๋ฅธ ๋…ธ๋“œ์™€ ์ˆœ์„œ๊ฐ€ ์—†์œผ๋ฏ€๋กœ 5๊ฐ€์ง€ ์ •๋ ฌ์ด ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ ์ด 10๊ฐœ์˜ ์œ„์ƒ์ •๋ ฌ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

  - T1 T2 T3 T4 T5     - T1 T2 T3 T5 T4

  - T1 T2 T5 T3 T4   - T1 T5 T2 T3 T4

  - T5 T1 T2 T3 T4   - T1 T3 T2 T4 T5

  - T1 T3 T2 T5 T4   - T1 T3 T5 T2 T4

  - T1 T5 T3 T2 T4   - T5 T1 T3 T2 T4

 

<T1,T2,T3,T4> T5  => T5๊ฐ€ 1,2,3,4์˜ ์ „ํ›„๋กœ ๋“ค์–ด๊ฐˆ ๊ฒฝ์šฐ 5๊ฐ€์ง€

<T1,T3,T2,T4> 5  => T5๊ฐ€ 1,2,3,4์˜ ์ „ํ›„๋กœ ๋“ค์–ด๊ฐˆ ๊ฒฝ์šฐ 5๊ฐ€์ง€

์ด 10๊ฐ€์ง€ ์ง๋ ฌ ์Šค์ผ€์ค„

 

728x90