Concurrency control with locks ---------------------------------- Two phase locking/Strict two phase locking Deadlocks: -> Periodically check for deadlocks: wait-for graph -> Avoid deadlocks: --------------------- What are we locking? --------------------- Relation Page Tuple Trade off: high concurrency - high overhead -------------------------- Lock Granularity ----------------- IS IX S X PHANTOM UPDATE ----------------- Read uncommitted -> possible to read uncommitted data Read committed -> possible to read the same data twice and get different results Repeatable read -> possible to have phantom updates Serializable -> not possible to have phantom updates T1: SELECT count(*) FROM episodes WHERE year = 2020; Locked all tuples using S (or IS) T2: INSERT INTO episodes VALUES(....) ; << possible since no lock on a new tuple!>> To implement serializability: lock a condition!