SSIè«æã®ã¡ã¢
Making Snapshot Isolation Serializable 再考 - 急がば回れ、選ぶなら近道
ã§ç´¹ä»ããã¦ãã2ã¤ã®è«æãèªãã ã®ã§ã¡ã¢ã
Making Snapshot Isolation SerializableÂ
Alan Feketeã®è«æã
Â
okachimachiorzããã詳ããæ¸ãã¦ããã®ã§å¼ã£æãã£ãã¨ããã ãã¡ã¢ã
Â
ç¨èªã«ã¤ãã¦
- Predicate Read
ååï¼Identifierï¼ã«ãã£ã¦ç¹å®ããã対象ã«å¯¾ããReadã§ã¯ãªãã¦ãæ¯è¼æ¼ç®çã®è¿°èªãçãã©ãããè©ä¾¡ãé¸æãã¦Readããæä½ãç¹å¥ã«Predicate Readã¨å¼ãã§ããã
ãã¡ããæ®éã ã¨æã£ã¦ãããé常ã¯Indexã«ãã£ã¦ä¸æ¬é£ãã§ãããã¨ãåæã«ãªãããè¿°èªã®è©ä¾¡ã«ããé¸æã«æ¢ãã¦ååãã¤ãã¦ããã®ããªã - First Commiter Winã«ã¼ã«
åã対象ãWrite使ç¨ã¨ããã¨ãæåã«Commitãããã©ã³ã¶ã¯ã·ã§ã³ãæå¹ã«ãªãã«ã¼ã«ãFirst Updater Winã«ã¼ã«ãåºã¦ããã - Write Skew
Anomalyã®1ã¤ãSnapshot Isolationã§é¤å»ã§ããªãã2ã¤ã®rw-dependencyã«ãã£ã¦èµ·ããã - Lost Update
Anomalyã®ã²ã¨ã¤ãã¡ã¸ã£ãªãã¤ã - Phantom Read
Anomalyã®ã²ã¨ã¤ãANSIã«ãåºã¦ãããPostgreSQLã®å®è£ ãé ã«ããã¨Non-repeatable Readã¨ã®éããããããªãã¦å°ã£ãã
Â
Typo/誤ã
- Example 2.1
H1:W1(X1) W1(Y1) W1(Z1) C1 W3(X3) R2(X1) W2(Y2) C2 R3(Y1) C3
ä¸è¨ã®ãã¹ããªã¯Serializableã§ããï¼T1âT2âT3ã®é ï¼ã¨æ¸ãã¦ããããSerializableã§ã¯ãªããT2âT3ã®rw-dependencyã¨T3âT2ã®rw-dependencyãåå¨ãããµã¤ã¯ã«ã«ãªã£ã¦ãã¾ãã
ãã®ä¾ã®ã¾ã¾ã§ã¯ã¢ã¤ãã Zãåºã¦ããæå³ããªãã®ã§ãæ£ããã¯æãã以ä¸ã®ãã¹ããªã
H1:W1(X1) W1(Y1) W1(Z1) C1 W3(X3) R2(X1) W2(Y2) C2 R3(Z1) C3
ãã£ã¨æ¤ç´¢ããã¨ããã以ä¸ã®è«æã§ä¸è¨ã¨ã»ã¼åãä¾ãZ1ã«å¤ãã¦è¼ã£ã¦ããã®ã§èª¤ãã§ããã¨æãã
Â
Nonserializable executionãå¼ãèµ·ããããã«ã¯ä¾åé¢ä¿ã®ãµã¤ã¯ã«ãå¿
è¦ã ãããµã¤ã¯ã«ã«2ã¤ã®é£ç¶ããrw-dependencyãå¿
è¦ãã®ç´æçãªè§£é
- ä¾åé¢ä¿ã§ãµã¤ã¯ã«ãä½ãããã«ã¯ãã©ããã§æéãéè¡ãããããªä¾åé¢ä¿ãå¿ è¦
- Snapshot Isolationä¸ã§ã¯ããã©ã³ã¶ã¯ã·ã§ã³beginæã®ãã¼ã¸ã§ã³ãRead/Writeããã®ã§ãRead/Writeãèµ·ãã£ãæå»ããåã®ãã¼ã¸ã§ã³ï¼æå»ï¼ã«å¯¾ãã¦ä¾åé¢ä¿ã®æå»ã®èµ·ç¹ããããSnapshot Isolationã«æ½å¨çã«æéã®éè¡ãããã
- ãã ãWriteãæå¹ã«ãªãã®ã¯ãã©ã³ã¶ã¯ã·ã§ã³ã®commitæãªã®ã§ãWriteãèµ·ç¹ã¨ããä¾åé¢ä¿ã¯Writeã®å¾ã«ããèµ·ãããªãï¼éè¡ããªãï¼ã
- ãã£ã¦æéãéè¡ããã®ã¯Readãèµ·ç¹ã¨ããä¾åé¢ä¿ã§ããã¯ãRead-Write dependencyã®ã¿ã
- 1ã¤ã®rw-dependencyãå«ã¿ãµã¤ã¯ã«ãä½ããã¨ããã¨ããã1ã¤ã®ä¾åé¢ä¿ãå¿ è¦ã ããæå»ã®é¢ä¿ããããã®ä¾åé¢ä¿ã«é¢ãããã©ã³ã¶ã¯ã·ã§ã³ã¯concurrentã§ãããã¨ããããã
- Concurrentãªãã©ã³ã¶ã¯ã·ã§ã³éã®ä¾åé¢ä¿ã¯rw-dependencyã«ãããªããªãã®ã§ãçµæçã«2ã¤ã®rw-dependencyããããã¨ã«ãªãã
Â
Â
Â
Serializable Isolation for Snapshot Databases
Michael Cahillã®è«æ
Â
å
容ã«ã¤ãã¦
- Non-serializable executionã®æ¤åºãDBMSã®å é¨ã§ãããã¨ãã話ã
- ãã ãä¾åé¢ä¿ã®ãµã¤ã¯ã«ã®å®å ¨ãªæ¤åºã§ã¯ãªããé£ç¶ãã2ã¤ã®rw-dependencyãæ¤åºããï¼ããã¦ããããã®ãã©ã³ã¶ã¯ã·ã§ã³ãabortããï¼ãã¨ã§non-serializable executionãæé¤ããã
- ãã®ãããå½é½æ§ï¼False Positiveï¼ããµã¤ã¯ã«ã«ãªã£ã¦ãªãã®ã«abortãããã¨ãããã
- ãããæ¹åããã¢ã«ã´ãªãºã ãæ示ããã¦ããã
- 2ã¤ã®æ¹æ³ã§rw-dependencyãæ¤åºãã¦ããã
- 2ã¤ããçç±ã¯ãrw-dependencyãæ§æããRead,Writeå¦çãã1ï¼ReadãWriteã«å è¡ããï¼ReadããVersionãWriteããï¼å ´åã¨ã2ï¼ReadãWriteã®å¾ã«èµ·ããï¼ReadããVersionãWriteããï¼å ´åãããããã
- Readå è¡ã«å¯¾ãã¦ã¯ãRowããã¯ã«æ°ããªããã¯ã¢ã¼ãSIREADã追å ããæ¹æ³ãã¨ãã
- ããã¯ã¢ã¼ãã§ãããSIREADã¯ä»ã®ã©ã®ããã¯ã¢ã¼ãã¨ã競åããªãã
- SIREADã¨EXCLUSIVEãåãRowã«å¯¾ãã¦çºããããã¨ã¯ãrw-dependencyã®åå¨ã表ãã
- Writeå è¡ã«å¯¾ãã¦ã¯ãReadæã«ãReadããVersionããæ°ããVersionãåå¨ãããã©ããããã§ãã¯ãããã¨ã§è¡ãã
- åºæ¬çãªã¢ã«ã´ãªãºã ã¯ä¸è¨ã®éãã ãããã®ã¾ã¾ã§ã¯Phantomã«ä¼´ãrw-dependencyãæ¤åºã§ããªãã
- InnoDBã«å¯¾ãããããã¿ã¤ãå®è£ ã§ã¯ãInnoDBã«ï¼Phantom Read対çã®ããã«ï¼ï¼å®è£ æ¸ã§ãããgapããã¯ãnext-keyããã¯ã«ãåæ§ã«SIREADããã¯ã¢ã¼ãã追å ãããã¨ã§è¡ãã
Typo/誤ã
- Fig 2.3(a)
Tinã¨Tpivotã®çååºéããªã¼ãã©ãããã¦ããªãããã«æããã¦ããï¼concurrentã«ãªã£ã¦ããªãï¼ã®ã§ãrw-dependencyãåå¨ããªããªã£ã¦ãã¾ãã
æ£ããã¯ãb_in < c_pivot ã¨ãªãããã«æãããã¹ãã
Â
PostgreSQLã«ã¤ãã¦æã£ããã¨ï¼è«æã«ã¯æ¸ãã¦ããªã話ï¼
- MVCCå®è£ ã¯ã¿ã¤ã ã¹ã¿ã³ããã¼ã¹ï¼ãã®ãã¼ã¸ã§ã³ãä½æ/åé¤ãããã©ã³ã¶ã¯ã·ã§ã³IDï¼ã§è¡ã£ã¦ããã®ã§ãPhantom Readã®é¤å»ã¨Non-repeatable Readã®é¤å»ã¯åãä»çµã¿ã§è¡ããã¦ããï¼ã¨æã£ã¦ããï¼ã
- ãªã®ã§ãPostgreSQLã«ã¯gapããã¯ãnext-keyããã¯ã¯ï¼SSI以åã¯ï¼ãªãã£ããã¨æ³åãããã
- Serializable Snapshot Isolationã®å®è£ ã«ã¨ããªã£ã¦gapããã¯ãå®è£ ãããã®ã ãããããï¼
- ï¼PostgreSQLã®SSIè«æè¦ãã°ãã£ã¨æ¸ãã¦ãããï¼
Â