L3:Multi-Version Concurrency Control (part 1):  what is MVCC

L3:Multi-Version Concurrency Control (part 1): what is MVCC

Agenda :

What is MVCC .

: Design Decision .

Concurrency control protocol.

version storage.

Garbage Collection.

Index Management.


??? ?? ?????? ????? ???? ?? ??? MVCC at a very high level

.??? ???? MVCC ???? ???? ?? ???? ???? Concurrency Control Protocol ???? ???? ???? ???? ???? ??? ?? ?????

?? ??? ?? ????? ?????? ????? ???? ???? ??? ????? ??? ??? ???

?? ?????? ??? ?????? ??? ??? ?? ???? ??? A = 15 ?? ??? ???? write ? A ????? A =20 ?? 15 ?? ????? ?????? ?????? ????? ???? ???? ?? ????? ?????? ??? 100$ ???? ???? ???? ?? ?????? ?????? ???? ???? ??? ???? ?????? 324$ ??? ???? ???? ??? ??? ??? ???????? ??? ????? ???????? ?? transaction ??? ????? ??? ??? ???? ??? ?? ??????? ???? ?? ??????? ??????? ?? ?????

??? ?? MVCC ??? ????? ??? :

?? ????? ?? ???? ??? ???? ???? ?????? ?? ???? ?????? ?? ?????? ?? ?????? ??? ?????? ???? ?? ??????? ???? ??? ??? ???? ???? A = 15 ?? write ??? A = 25 ?? A = 15 ?? ?????? ?? ?????? ??? ?????? ????? ????? ???? metadata ?? ???? ??A ???? ?????? 15 ????? ?? ??? Write ??? ?A ?????? ?????? ?????????? ?? ??????? version ???? ?? attribute A ???? ?????? ?? ???? ?? ????? create ?? ??? ?????? ?? ????? ?? ????? ??????? ?? ????? ?? ?? ?? ????? version ????? ??????? ???????

?? ???? ?? ???? ???? ??????

???? ??????? ?? ??? ?? ?? ??????? ????? ???? ??????



???? ???? ?? MVCC core idea

????? ???? in depth

you can define MVCC as A way to design a database system

:the main benefits off MVCC

writers don't block readers -

readers don't block writer -

???? ??? ?

???? ???? ???? ???? ? ????? ?? conflicts

"Read-Write conflicts "unrepeatable reads

???? ?? transaction ? read A ??? ??? ????? transaction ???? ???? ?????? ?? transaction ????? ??? ???? A ???? ????? ???? ????? ? ??? ???? ??? lock ???? ???? ???? ?? ??? ???? readers block writers

problem solved using MVCC

??? ?? transaction ? write ????? version ????? ???????? ????? ?????? ?? transaction ???? ????

: "Write -Read conflicts "dirty reads

???? ?? ?? "running transaction "uncommitted yet ??? write ? A ??? transaction ???? ? read ???? ?????? ??? ? block it ?? ???? lock ? lose performance , ?? ? prefer performance upon integrity ????? ??? ???? uncommitted data

problem solved using MVCC

??? running transaction ??? ???? ? commit ????? version ????? ? ??? transaction ??? ???? read ????? last committed version ???? ???? ??? ???? uncommited

Write-Write

??? ?????? ??????? ??? MVCC ?? ????? ??? ?? ??? 2 transaction ?????? ? write at the same time ??? ?????? ????? ????? ?? concurrency control protocol ???? ????

??? benefit ????? ?? ?? MVCC support time travel queries ?? ?? ???? ???? ? ????? ?? object

???? ????? why MVCC

MVCC is really useful in read only transactions as the DB system does not require any locks

???? ???? ?? A transaction sees a consistent snapshot

???? ??? ?? Transaction ????, ?? ???? ?? ???? ?? ?? DB ?????? ????? ????????? ?? ???? ?????? ??? ???

??? ???? : ??? ???? transactions ????? ?? ??? ??????? Write ???? ?? tuple ??? ??? ????? ?

??????? :first writer always win ???? ??? ???? ? write ?????? ??? ???? ?write ??? ?? object ?????? abort ?? ???? ? write ?? ? commit

consistent snapshot ?? isolation level ???? snapshot isolation

?? ?? ???? ?????? ???? ??

snapshot isolation is serializable ? NO

??? ??? ?

???? ???? ????? write skew anomaly

???? ????? ????? ?? ?? instructor ??? ????

?????? ?? ????

A = 0, B=0, C =1, D=1

assume you have 2 queries started at the same time

the queries are

1-set A,B,C,D to 0

2-set A,B,C,D to 1

what u will get is :A=1 ,B=1 ,C=0 ,D=0

?how ?!! , isn't that a write -write conflict

NO it's not ,query 1 writes A and B ,query 2 writes to C and D so it's not an Write -Write conflict as long as they writes different objects

that's why snapshot isolation is not serializable

??? ?? serializable ??????? ???? ????? ??? 0 ?? 1

?? ???? ?? ???? ???? ??????


?? ?? isolation level hierarchy ?? ??? ?? isolation level ???? strict ???? ????? ??? ??performance

??? ?????? ??DBMS ????? ?? performance ??? ?? correctness ?? ???? it depends

?? ???????? ????? : you don't get snapshot isolation by default with MVCC ,like postgress uses MVCC but the default u get is read committed but if you follow the strict definition u end up with snapshot isolation

??????? ???? ?? what is MVCC

?? ??? ????? ????? ??????? ??? design decisions ?????? ?? ????? ????? ?? ??? ????

要查看或添加评论,请登录

Mahmoud Abd-Almaksoud的更多文章

社区洞察

其他会员也浏览了