Transaction Server Process Structure A typical transaction server consists of multiple processes accessing data in shared memory Shared memory contains shared data ·Buffer pool ·Lock table ·Log buffer Cached query plans (reused if same query submitted again) All database processes can access shared memory ■Server processes These receive user queries (transactions),execute them and send results back Processes may be multithreaded,allowing a single process to execute several user queries concurrently Typically multiple multithreaded server processes Database System Concepts-7th Edition 20.7 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 20.7 ©Silberschatz, Korth and Sudarshan th Edition Transaction Server Process Structure ▪ A typical transaction server consists of multiple processes accessing data in shared memory ▪ Shared memory contains shared data • Buffer pool • Lock table • Log buffer • Cached query plans (reused if same query submitted again) ▪ All database processes can access shared memory ▪ Server processes • These receive user queries (transactions), execute them and send results back • Processes may be multithreaded, allowing a single process to execute several user queries concurrently • Typically multiple multithreaded server processes
Transaction Server Processes (Cont.) Database writer process Output modified buffer blocks to disks continually Log writer process Server processes simply add log records to log record buffer Log writer process outputs log records to stable storage. ■Checkpoint process .Performs periodic checkpoints Process monitor process Monitors other processes,and takes recovery actions if any of the other processes fail E.g.aborting any transactions being executed by a server process and restarting it Database System Concepts-7th Edition 20.8 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 20.8 ©Silberschatz, Korth and Sudarshan th Edition Transaction Server Processes (Cont.) ▪ Database writer process • Output modified buffer blocks to disks continually ▪ Log writer process • Server processes simply add log records to log record buffer • Log writer process outputs log records to stable storage. ▪ Checkpoint process • Performs periodic checkpoints ▪ Process monitor process • Monitors other processes, and takes recovery actions if any of the other processes fail ▪ E.g. aborting any transactions being executed by a server process and restarting it
Transaction System Processes (Cont.) Lock manager process To avoid overhead of interprocess communication for lock request/grant,each database process operates directly on the lock table instead of sending requests to lock manager process Lock manager process still used for deadlock detection To ensure that no two processes are accessing the same data structure at the same time,databases systems implement mutual exclusion using either ·Atomic instructions Test-And-Set Compare-And-Swap(CAS) Operating system semaphores Higher overhead than atomic instructions Database System Concepts-7th Edition 20.9 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 20.9 ©Silberschatz, Korth and Sudarshan th Edition Transaction System Processes (Cont.) ▪ Lock manager process • To avoid overhead of interprocess communication for lock request/grant, each database process operates directly on the lock table ▪ instead of sending requests to lock manager process • Lock manager process still used for deadlock detection ▪ To ensure that no two processes are accessing the same data structure at the same time, databases systems implement mutual exclusion using either • Atomic instructions ▪ Test-And-Set ▪ Compare-And-Swap (CAS) • Operating system semaphores ▪ Higher overhead than atomic instructions
Atomic Instructions ■Test-And-SetM) Memory location M,initially 0 Test-and-set(M)sets M to 1,and returns old value of M Return value 0 indicates process has acquired the mutex Return value 1 indicates someone is already holding the mutex ·Must try again later Release of mutex done by setting M=0 Compare-and-swap(M,V1,V2) Atomically do following If M=V1,set M=V2 and return success Else return failure With M=0 initially,CAS(M,0,1)equivalent to test-and-set(M) Can use CAS(M,0,id)where id thread-id or process-id to record who has the mutex Database System Concepts-7th Edition 20.10 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 20.10 ©Silberschatz, Korth and Sudarshan th Edition Atomic Instructions ▪ Test-And-Set(M) • Memory location M, initially 0 • Test-and-set(M) sets M to 1, and returns old value of M ▪ Return value 0 indicates process has acquired the mutex ▪ Return value 1 indicates someone is already holding the mutex • Must try again later ▪ Release of mutex done by setting M = 0 ▪ Compare-and-swap(M, V1, V2) • Atomically do following ▪ If M = V1, set M = V2 and return success ▪ Else return failure • With M = 0 initially, CAS(M, 0, 1) equivalent to test-and-set(M) • Can use CAS(M, 0, id) where id = thread-id or process-id to record who has the mutex
Data Servers/Data Storage Systems m Data items are shipped to clients where processing is performed Updated data items written back to server Earlier generation of data servers would operated in units of data items, or pages containing multiple data items a Current generation data servers(also called data storage systems)only work in units of data items Commonly used data item formats include JSON,XML,or just uninterpreted binary strings Database System Concepts-7th Edition 20.11 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 20.11 ©Silberschatz, Korth and Sudarshan th Edition Data Servers/Data Storage Systems ▪ Data items are shipped to clients where processing is performed ▪ Updated data items written back to server ▪ Earlier generation of data servers would operated in units of data items, or pages containing multiple data items ▪ Current generation data servers (also called data storage systems) only work in units of data items • Commonly used data item formats include JSON, XML, or just uninterpreted binary strings