INTRODUCTION TO TRANSACTION PROCESSING
CHAPTER 21 (6/E) CHAPTER 17 (5/E)
INTRODUCTION TO TRANSACTION PROCESSING CHAPTER 21 (6/E) CHAPTER - - PowerPoint PPT Presentation
INTRODUCTION TO TRANSACTION PROCESSING CHAPTER 21 (6/E) CHAPTER 17 (5/E) CHAPTER 21 OUTLINE Introduction to Transaction Processing Desirable Properties of Transactions Transaction Support in SQL 2 DEFINITIONS
CHAPTER 21 (6/E) CHAPTER 17 (5/E)
2
more database access operations
chequing account to a savings account
different parameters
chequing account number, transfer amount
database systems supporting thousands of concurrent transactions (user processes) per minute
3
database item named X
4
5
program variables DB items
memory is one disk block (or page).
1. Find the address of the disk block that contains item X. 2. Copy that disk block into a buffer in main memory (if that disk block is not already in some main memory buffer). 3. Copy item X from the buffer to the program variable named X.
1. Find the address of the disk block that contains item X. 2. Copy that disk block into a buffer in main memory (if it is not already in some main memory buffer). 3. Copy item X from the program variable named X into its correct location in the buffer. 4. Store the updated block from the buffer back to disk
6
interactively, or
transactions separated by Begin and End transaction boundaries
spawning multiple transactions
7
8
interleaved on a single CPU
multiple CPUs
9
10
at ATM window #1 at ATM window #2
1
read_item(savings);
2
savings = savings - $100;
3
read_item(chequing);
4
write_item(savings);
5
read_item(chequing);
6
chequing = chequing - $20;
7
write_item(chequing);
8
chequing = chequing + $100;
9
write_item(chequing);
10
dispense $20 to customer;
12
at ATM window #1 at ATM window #2
1 read_item(savings); a read_item(chequing); 2 savings = savings - $100; b chequing = chequing - $20; 3 write_item(savings); c write_item(chequing); 4 read_item(chequing); d dispense $20 to customer; 5 chequing = chequing + $100; 6 write_item(chequing);
performed in its entirety or not performed at all.
take the database from one consistent state to another.
should appear to be executed in isolation – that is, their final effect should be as if each transaction was executed in isolation from start to finish.
applied to the database must never be lost because of subsequent failure.
responsible for C (introduced in previous classes)
14
and leaves the database unchanged.
statement after previous transaction terminates
transaction had not yet begun
15
update_proc() { EXEC SQL WHENEVER SQLERROR GO TO error; EXEC SQL INSERT INTO EMPLOYEE VALUES ('Robert','Smith','991004321',2,35000); EXEC SQL UPDATE EMPLOYEE SET SALARY = SALARY * 1.1 WHERE DNO = 2; EXEC SQL COMMIT; return(0); error: /* continue if error on rollback */ EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK; return(1); }
16
17