Вы находитесь на странице: 1из 14

Information Management Technology Ecosystems

Spring 2011

Transactions

Information Management

2011 IBM Corporation

Information Management

Agenda
SQL Concurrency and Isolation
Special Columns
Insert, Delete, Update Operations
Aborting a transaction
Invisibility List

2011 IBM Corporation

Information Management

Concurrency and Isolation


 Netezza SQL complies with the ACID properties for transactions:
 Atomicity
 Consistency
 Isolation
 Durability
 Netezza SQL implements serializable transaction isolation that
provides the highest possible level of consistency
No dirty reads
No non-repeatable reads
No phantom reads
 Netezza SQL does not use conventional locking to enforce
consistency among concurrently executing transactions

2011 IBM Corporation

Information Management

Multi-Versioning + Serialization Dependency Checking


 Netezza implements a combination of two mechanisms to handle
concurrent transactions:
Multi-versioning
Transactions see a consistent state that is isolated from other
transaction that have not been committed
Serialization Dependency Checking
Concurrent executions are not serializable are not permitted
2 concurrent transactions attempt to modify the same data, system
will roll back the youngest transaction
 Optimistic concurrency control is suitable for low-conflict warehousing
environment
 A user can not explicitly lock tables
 Dirty reads of uncommitted data is not all allowed
4

2011 IBM Corporation

Information Management

Special Columns
createxid

deletexid

rowid

Null Vector

row length

8 bytes

8 bytes

8 bytes

N/8 Bytes

4 Bytes

Column_1..Column_n
Number of bytes..

 In all tables, every record includes three 8-byte special columns, representing:

rowid
unique row ID

createXid
the transaction ID of the transaction that created the row

deleteXid
the transaction ID of the transaction that deleted the row
 These columns can be seen using SELECT rowid, createXid, deleteXid

2011 IBM Corporation

Information Management

rowid
createxid

deletexid

rowid

Null Vector

row length

8 bytes

8 bytes

8 bytes

N/8 Bytes

4 Bytes

Column_1..Column_n
Number of bytes..

 8-byte integer stored in each record in a table


 Guaranteed to be unique
But not necessarily sequential within a table
 In a new installation, the initial rowid value is 100,000
The next available rowid value is stored in the /nz/data/RowCounter file
 The SMP host allocates a block of sequential rowids to each S-Blade
When records are inserted the S-Blade assigns a rowid to the row.

2011 IBM Corporation

Information Management

createXid and deleteXid transaction IDs


createxid

deletexid

rowid

Null Vector

row length

8 bytes

8 bytes

8 bytes

N/8 Bytes

4 Bytes

Column_1..Column_n
Number of bytes..

 Two transaction IDs (Xids) stored in each row in a table


createXid is the transaction ID that created the row
deleteXid is the transaction ID that deleted the row
0 if the row is not deleted
 8-byte integer
48 bits are significant
 Xids are sequential in nature
Starting value 1,024
Each time the Netezza Appliance starts up, the next xid value used will be a
multiple of 1,024

2011 IBM Corporation

Information Management

Insertion and Deletion


 To insert a row, createxid is populated, with deletexid marked with 0

Transaction 1024: INSERT INTO VALUES (data, data, data);


createxid

deletexid

rowid

1024

100000

row

data, data, data

 To delete a row, createxid is untouched, with deletexid marked with the transaction id

Transaction 1025: DELETE FROM ... WHERE ;


createxid

deletexid

rowid

1024

1025

100000

row

data, data, data

Row is logically deleted!


8

2011 IBM Corporation

Information Management

Updating a Row
 Rows are NOT updated in-place on disk
 The original record is marked for deletion (logically deleted) and the deleteXid
value is updated
 A new record, with the same rowid, is INSERTed and the createXid and
deleteXid values are updated
 Maintains data integrity
Write once
No transactional log files
 Simplifies and accelerates rollback/recovery operations

2011 IBM Corporation

Information Management

Example of an Update
 Transaction 1027: UPDATE SET changed_data WHERE data =
ORIGINAL
createxid

deletexid

rowid

1024

100000

row

data, data, data

Row is updated
The original record is marked as deleted
createxid

deletexid

rowid

row

1024

1027

100000

data, data, data

1027

100000

data, some changed data, data

A new record is added to the database


10

2011 IBM Corporation

Information Management

Aborted Transactions INSERT or DELETE


Aborting an INSERT or load:
createxid

deletexid

rowid

2100

100000

row

data, data, data

INSERT or load is aborted


The deletexid is set to a special value of 1

Aborting an DELETE:
createxid

deletexid

rowid

2300

300000

row

data, some changed data, data

DELETE is aborted
The deletexid is simply set back to a value of 0

11

2011 IBM Corporation

Information Management

Aborted Transactions - UPDATE


Aborting an UPDATE
row

createxid

deletexid

rowid

2200

200000

data, data, data

2201

200000

data, some changed data, data

UPDATE is aborted
System reverts to the prior version of the record

12

2011 IBM Corporation

Information Management

Invisibility lists
 When a query or backup operation is executed, it is allowed to access rows that
were created but not deleted before the transaction began
 xid values are sequential, it simply needs to compare the createXid and deleteXid
values

 An invisible list is created, consists of lower xid value that it needs to ignore, ie
any other active transactions or transaction or transactions that have not finished
rolling back
Any records created (but not committed) are excluded
Any records deleted (but not committed) are included

13

2011 IBM Corporation

Information Management Technology Ecosystems


Spring 2011

Questions?

Information Management

2011 IBM Corporation

Вам также может понравиться