SlideShare a Scribd company logo
CSEP 545 Transaction Processing for E-Commerce 1/4/2012
Assignment 1 1
Assignment 1
Reading - Chapter 1 of the textbook.
Project – Let us know who you’ll partner with and whether you do the project in Java or C#. If you
don’t know Java or C#, start learning one of them now.
This problem is about how the ACID properties are affected by the internal structure and behavior of
data management software. It also raises some design considerations that may affect your project. The
code is simple, rather than useful or interesting, so as to make it easy to think and argue about the
implementation of ACID properties.
BlockDB is a transactional block-oriented storage system that allows its users to issue transactions
that access multiple blocks. A user of BlockDB identifies each block by its physical address on disk.
BlockDB offers the following five operations. Underlined parameters are output.
 /* Start new transaction */
int start()
Returns: -1, if there is an active transaction
tId < -1 (a new Transaction Identifier) otherwise
 /* If possible, read block at diskBlockAddr on behalf of transaction
tId from disk into main memory and save a pointer to it in memBlock */
int read(int diskBlockAddr, int tId, int *memBlock)
Returns: 0 if successful, -1 otherwise
 /* Tell BlockDB that transaction tId has updated a block at
diskBlockAddr */
int write(int diskBlockAddr, int tId)
Returns: 0 if there is no cached entry for diskBlockAddr
1 otherwise
 /* Try to commit transaction tId */
int commit(int tId)
Returns: 0 if successful, -1 otherwise
 /* Abort transaction tId */
int abort(int tId)
Returns: 0
BlockDB is implemented as follows:
 BlockDB maintains a cache of blocks in main memory. It organizes this as a collection, called
Cache, of cache entries. Each cache entry e is an object Cache(e) with three attributes:
o int Cache(e).tId, which contains a transaction ID
o int Cache(e).diskBlockAddr, which contains the identity (i.e. disk address) of the
block stored in Cache(e)
o int Cache(e).oldBlock, which contains the last committed content of the block
o int Cache(e).newBlock, which contains the last written content of the block
The cache is initially empty. This means that the cache has been allocated, and for all entries
e in the cache, Cache(e).tId = 0.
CSEP 545 Transaction Processing for E-Commerce 1/4/2012
Assignment 1 2
 BlockDB maintains a variable lastTransId, which is the (sometimes negated) transaction
identifier of the last transaction that was started. It is initialized to 1.
 There can be at most one instance of BlockDB running on a system at a given time. It has
exclusive access to the disk drive that it uses.
BlockDB uses a raw disk drive, which supports two operations diskRead and diskWrite
 /* Read the value of block at diskBlockAddr from disk and return it in
main memory at address memAddr */
int diskRead(int diskBlockAddr, int memAddr)
 /* Store the content of the main memory beginning at address memAddr
into block diskBlockAddr on disk */
int diskWrite(int diskblockAddr, int memAddr)
Returns:
For each operation, read or write, the disk drive either performs the
intended operation and returns 0 or it has no effect and returns -1.
BlockDB implements its five operations as follows. It executes operations one-at-a-time. That is, it
executes each invoked operation in its entirety before executing the next invoked operation.
lastTrans = 1;
int start()
{
if (lastTrans < 0) { return -1 }
else
{
lastTrans = -(++lastTrans);
return lastTrans
}
}
int read(int diskBlockAddr, int tId, int *memBlock)
{
/* find the cache element e containing the block whose disk address
is diskBlockAddr */
if (there is such a cache element e)
{
/* the disk block at diskBlockAddr is in cache */
Cache(e).tId = tId;
memBlock = &Cache(e).newBlock;
/* &Cache(e).newBlock is the address of Cache(e).newBlock */
return 0
}
else
{
/* pick a cache entry e, where Cache(e).tId = 0.
If there is no such entry, then return -1 */
status = diskRead(diskBlockAddr, &Cache(e).oldBlock);
if (status != 0) { return -1 };
Cache(e).newBlock = Cache(e).oldBlock;
CSEP 545 Transaction Processing for E-Commerce 1/4/2012
Assignment 1 3
memBlock = &Cache(e).newBlock;
Cache(e).diskBlockAddr = diskBlockAddr;
Cache(e).tId = tId;
return 0
}
}
/* A transaction should call write(&Cache(e).newBlock, tId) after it
updates Cache(e).newBlock. */
int write(int diskBlockAddr, int tId)
{
/* find the cache entry e for block diskBlockAddr */
if (there is no such entry) { return 0 }
else
{
Cache(e).tId = tId;
return 1
}
}
int commit(int tId)
{
for (each cache entry e where Cache(e).tId == tId)
{
status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).newBlock);
Cache(e).tId = -tId;
if (status == -1)
{
Abort(tId);
return -1
}
Cache(e).oldBlock = Cache(e).newBlock
}
for (each cache entry e where Cache(e).tId == -tId) {
Cache(e).tId = 0
}
lastTrans = -lastTrans;
return 0
}
int abort(int tId)
{
for (all cache entries e, where Cache(e).tId == -tId)
{
Repeat
{
status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).oldBlock)
} until (status == 0);
/* Of course, this will not terminate if diskWrite keeps */
/* failing, but ignore that issue */
Cache(e).newBlock = Cache(e).oldBlock
}
CSEP 545 Transaction Processing for E-Commerce 1/4/2012
Assignment 1 4
for (all cache entries e)
{
Cache(e).tId = 0
}
lastTrans = -lastTrans;
return 0
}
Questions
For each of the scenarios below, analyze whether transactions that use BlockDB satisfy the four
ACID properties. In each case, if a property is violated, show a counterexample where it does not
satisfy the property. In the latter case, you might want to suggest a way to fix the implementation, but
don’t lose sleep over it, since it might be pretty hard.
a. The operating system and BlockDB never crash. Transactions run serially. Please
consider the case in which a transaction is terminated early (e.g., due to division by zero)
and an agent detects this and aborts the transaction.
b. The operating system can crash, in which case main memory is lost. Transactions run
serially.
c. The operating system and BlockDB never crash. Transactions run serially. DiskWrite(b,
addr) always returns 0, but it might corrupt block b on disk.
d. A variation of (c): The operating system and BlockDB never crash. Transactions run
serially. If DiskWrite(b, addr) returns -1 then it might have corrupted block b on disk (but
not if it returns 0).
e. The operating system and BlockDB never crash. The specification of Start is modified to
allow up to two transactions to run concurrently. So its implementation is modified to
keep track of the number of active transactions and return -1 if it is called when two
transactions are concurrently active.

More Related Content

What's hot

Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
Alex Miller
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatchcqtt191
 
HexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profitHexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profit
Alex Matrosov
 
HexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierHexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easier
Alex Matrosov
 
GCD and OperationQueue.
GCD and OperationQueue.GCD and OperationQueue.
GCD and OperationQueue.
HSIEH CHING-FAN
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
Hermann Hueck
 
разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4
Eugeniy Tyumentcev
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
Carol McDonald
 
RealmDB for Android
RealmDB for AndroidRealmDB for Android
RealmDB for Android
GlobalLogic Ukraine
 
C++11 Multithreading - Futures
C++11 Multithreading - FuturesC++11 Multithreading - Futures
C++11 Multithreading - Futures
GlobalLogic Ukraine
 
[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++
Dimitrios Platis
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
Prashant Rane
 
Nicety of Java 8 Multithreading
Nicety of Java 8 MultithreadingNicety of Java 8 Multithreading
Nicety of Java 8 Multithreading
GlobalLogic Ukraine
 
Finding root blocker in oracle database
Finding root blocker in oracle databaseFinding root blocker in oracle database
Finding root blocker in oracle databaseMohsen B
 
Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015
Ben Asher
 
Transactional Memory for Smalltalk
Transactional Memory for SmalltalkTransactional Memory for Smalltalk
Transactional Memory for Smalltalk
Lukas Renggli
 
Python Deserialization Attacks
Python Deserialization AttacksPython Deserialization Attacks
Python Deserialization Attacks
NSConclave
 

What's hot (20)

Java Concurrency Idioms
Java Concurrency IdiomsJava Concurrency Idioms
Java Concurrency Idioms
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
 
HexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profitHexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profit
 
HexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierHexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easier
 
GCD and OperationQueue.
GCD and OperationQueue.GCD and OperationQueue.
GCD and OperationQueue.
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
 
разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4
 
Java Persistence API
Java Persistence APIJava Persistence API
Java Persistence API
 
Java 7
Java 7Java 7
Java 7
 
RealmDB for Android
RealmDB for AndroidRealmDB for Android
RealmDB for Android
 
C++11 Multithreading - Futures
C++11 Multithreading - FuturesC++11 Multithreading - Futures
C++11 Multithreading - Futures
 
[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++[grcpp] Refactoring for testability c++
[grcpp] Refactoring for testability c++
 
Memory management
Memory managementMemory management
Memory management
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
 
Nicety of Java 8 Multithreading
Nicety of Java 8 MultithreadingNicety of Java 8 Multithreading
Nicety of Java 8 Multithreading
 
Finding root blocker in oracle database
Finding root blocker in oracle databaseFinding root blocker in oracle database
Finding root blocker in oracle database
 
Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015Grand Central Dispatch - iOS Conf SG 2015
Grand Central Dispatch - iOS Conf SG 2015
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 
Transactional Memory for Smalltalk
Transactional Memory for SmalltalkTransactional Memory for Smalltalk
Transactional Memory for Smalltalk
 
Python Deserialization Attacks
Python Deserialization AttacksPython Deserialization Attacks
Python Deserialization Attacks
 

Viewers also liked

10 Ways to be a great Solution Architect
10 Ways to be a great Solution Architect10 Ways to be a great Solution Architect
10 Ways to be a great Solution Architect
Bernard Panes
 
Web 2.0
Web 2.0Web 2.0
5 application serversforproject
5 application serversforproject5 application serversforproject
5 application serversforproject
ashish61_scs
 
4 db recovery
4 db recovery4 db recovery
4 db recovery
ashish61_scs
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
ashish61_scs
 
19 structured files
19 structured files19 structured files
19 structured files
ashish61_scs
 
Jeopardy (cecilio)
Jeopardy (cecilio)Jeopardy (cecilio)
Jeopardy (cecilio)
Cecilio Dolores
 
The buransh mahotsav_report
The buransh mahotsav_report The buransh mahotsav_report
The buransh mahotsav_report
Prasanna Kapoor
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
ashish61_scs
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
ashish61_scs
 
Unidadees de almacenamiento
Unidadees de almacenamientoUnidadees de almacenamiento
Unidadees de almacenamiento
Edwincitto Patrix
 
Correspondencia unidad 2
Correspondencia unidad 2Correspondencia unidad 2
Correspondencia unidad 2
Edwincitto Patrix
 
Formato de celdas unidad 2
Formato de celdas unidad 2Formato de celdas unidad 2
Formato de celdas unidad 2
Edwincitto Patrix
 
Cuadro comparativo prezi point
Cuadro comparativo prezi pointCuadro comparativo prezi point
Cuadro comparativo prezi point
Edwincitto Patrix
 
Digital: An Inflection Point for Mankind
Digital: An Inflection Point for MankindDigital: An Inflection Point for Mankind
Digital: An Inflection Point for Mankind
Bernard Panes
 

Viewers also liked (20)

10 Ways to be a great Solution Architect
10 Ways to be a great Solution Architect10 Ways to be a great Solution Architect
10 Ways to be a great Solution Architect
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
5 application serversforproject
5 application serversforproject5 application serversforproject
5 application serversforproject
 
Ibrahim Thesis
Ibrahim ThesisIbrahim Thesis
Ibrahim Thesis
 
4 db recovery
4 db recovery4 db recovery
4 db recovery
 
14 scaleabilty wics
14 scaleabilty wics14 scaleabilty wics
14 scaleabilty wics
 
19 structured files
19 structured files19 structured files
19 structured files
 
Jeopardy (cecilio)
Jeopardy (cecilio)Jeopardy (cecilio)
Jeopardy (cecilio)
 
The buransh mahotsav_report
The buransh mahotsav_report The buransh mahotsav_report
The buransh mahotsav_report
 
01 whirlwind tour
01 whirlwind tour01 whirlwind tour
01 whirlwind tour
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
 
Unidadees de almacenamiento
Unidadees de almacenamientoUnidadees de almacenamiento
Unidadees de almacenamiento
 
Correspondencia unidad 2
Correspondencia unidad 2Correspondencia unidad 2
Correspondencia unidad 2
 
Formato de celdas unidad 2
Formato de celdas unidad 2Formato de celdas unidad 2
Formato de celdas unidad 2
 
Cuadro comparativo prezi point
Cuadro comparativo prezi pointCuadro comparativo prezi point
Cuadro comparativo prezi point
 
kevin tercero
kevin tercerokevin tercero
kevin tercero
 
Guia kevin
Guia kevinGuia kevin
Guia kevin
 
Digital: An Inflection Point for Mankind
Digital: An Inflection Point for MankindDigital: An Inflection Point for Mankind
Digital: An Inflection Point for Mankind
 
Solution6.2012
Solution6.2012Solution6.2012
Solution6.2012
 
Solution8 v2
Solution8 v2Solution8 v2
Solution8 v2
 

Similar to Assignment.1

Frits Hoogland - About multiblock reads
Frits Hoogland - About multiblock readsFrits Hoogland - About multiblock reads
Frits Hoogland - About multiblock reads
Getting value from IoT, Integration and Data Analytics
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
Béo Tú
 
Memory model
Memory modelMemory model
Memory model
MingdongLiao
 
Sqllite
SqlliteSqllite
Sqllite
Senthil Kumar
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
Programming Homework Help
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
Deniz Oguz
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
Jeff Kelley
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
GOG.com dev team
 
CoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdCoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love Systemd
Richard Lister
 
The program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docxThe program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docx
oscars29
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!
C4Media
 
Assignment1.2012
Assignment1.2012Assignment1.2012
Assignment1.2012
ashish61_scs
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...tutorialsruby
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...tutorialsruby
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimizationguest3eed30
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory OptimizationWei Lin
 
Lockless Programming GDC 09
Lockless Programming GDC 09Lockless Programming GDC 09
Lockless Programming GDC 09
Lee Hanxue
 

Similar to Assignment.1 (20)

Frits Hoogland - About multiblock reads
Frits Hoogland - About multiblock readsFrits Hoogland - About multiblock reads
Frits Hoogland - About multiblock reads
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
 
Memory model
Memory modelMemory model
Memory model
 
Updates
UpdatesUpdates
Updates
 
Updates
UpdatesUpdates
Updates
 
Sqllite
SqlliteSqllite
Sqllite
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
 
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019In-depth caching in Varnish - GOG Varnish Meetup, march 2019
In-depth caching in Varnish - GOG Varnish Meetup, march 2019
 
CoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love SystemdCoreOS, or How I Learned to Stop Worrying and Love Systemd
CoreOS, or How I Learned to Stop Worrying and Love Systemd
 
oracle dba
oracle dbaoracle dba
oracle dba
 
The program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docxThe program reads data from two files, itemsList-0x.txt and .docx
The program reads data from two files, itemsList-0x.txt and .docx
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!
 
Assignment1.2012
Assignment1.2012Assignment1.2012
Assignment1.2012
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
 
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
exploit-writing-tutorial-part-5-how-debugger-modules-plugins-can-speed-up-bas...
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimization
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimization
 
Lockless Programming GDC 09
Lockless Programming GDC 09Lockless Programming GDC 09
Lockless Programming GDC 09
 

More from ashish61_scs

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
ashish61_scs
 
Transactions
TransactionsTransactions
Transactions
ashish61_scs
 
22 levine
22 levine22 levine
22 levine
ashish61_scs
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
ashish61_scs
 
20 access paths
20 access paths20 access paths
20 access paths
ashish61_scs
 
18 philbe replication stanford99
18 philbe replication stanford9918 philbe replication stanford99
18 philbe replication stanford99
ashish61_scs
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
ashish61_scs
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
ashish61_scs
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
ashish61_scs
 
14 turing wics
14 turing wics14 turing wics
14 turing wics
ashish61_scs
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
ashish61_scs
 
11 tm
11 tm11 tm
10b rm
10b rm10b rm
10b rm
ashish61_scs
 
10a log
10a log10a log
10a log
ashish61_scs
 
09 workflow
09 workflow09 workflow
09 workflow
ashish61_scs
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
ashish61_scs
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
ashish61_scs
 
05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
ashish61_scs
 
03 fault model
03 fault model03 fault model
03 fault model
ashish61_scs
 
02 fault tolerance
02 fault tolerance02 fault tolerance
02 fault tolerance
ashish61_scs
 

More from ashish61_scs (20)

7 concurrency controltwo
7 concurrency controltwo7 concurrency controltwo
7 concurrency controltwo
 
Transactions
TransactionsTransactions
Transactions
 
22 levine
22 levine22 levine
22 levine
 
21 domino mohan-1
21 domino mohan-121 domino mohan-1
21 domino mohan-1
 
20 access paths
20 access paths20 access paths
20 access paths
 
18 philbe replication stanford99
18 philbe replication stanford9918 philbe replication stanford99
18 philbe replication stanford99
 
17 wics99 harkey
17 wics99 harkey17 wics99 harkey
17 wics99 harkey
 
16 greg hope_com_wics
16 greg hope_com_wics16 greg hope_com_wics
16 greg hope_com_wics
 
15 bufferand records
15 bufferand records15 bufferand records
15 bufferand records
 
14 turing wics
14 turing wics14 turing wics
14 turing wics
 
13 tm adv
13 tm adv13 tm adv
13 tm adv
 
11 tm
11 tm11 tm
11 tm
 
10b rm
10b rm10b rm
10b rm
 
10a log
10a log10a log
10a log
 
09 workflow
09 workflow09 workflow
09 workflow
 
08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick08 message and_queues_dieter_gawlick
08 message and_queues_dieter_gawlick
 
06 07 lock
06 07 lock06 07 lock
06 07 lock
 
05 tp mon_orbs
05 tp mon_orbs05 tp mon_orbs
05 tp mon_orbs
 
03 fault model
03 fault model03 fault model
03 fault model
 
02 fault tolerance
02 fault tolerance02 fault tolerance
02 fault tolerance
 

Recently uploaded

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

Assignment.1

  • 1. CSEP 545 Transaction Processing for E-Commerce 1/4/2012 Assignment 1 1 Assignment 1 Reading - Chapter 1 of the textbook. Project – Let us know who you’ll partner with and whether you do the project in Java or C#. If you don’t know Java or C#, start learning one of them now. This problem is about how the ACID properties are affected by the internal structure and behavior of data management software. It also raises some design considerations that may affect your project. The code is simple, rather than useful or interesting, so as to make it easy to think and argue about the implementation of ACID properties. BlockDB is a transactional block-oriented storage system that allows its users to issue transactions that access multiple blocks. A user of BlockDB identifies each block by its physical address on disk. BlockDB offers the following five operations. Underlined parameters are output.  /* Start new transaction */ int start() Returns: -1, if there is an active transaction tId < -1 (a new Transaction Identifier) otherwise  /* If possible, read block at diskBlockAddr on behalf of transaction tId from disk into main memory and save a pointer to it in memBlock */ int read(int diskBlockAddr, int tId, int *memBlock) Returns: 0 if successful, -1 otherwise  /* Tell BlockDB that transaction tId has updated a block at diskBlockAddr */ int write(int diskBlockAddr, int tId) Returns: 0 if there is no cached entry for diskBlockAddr 1 otherwise  /* Try to commit transaction tId */ int commit(int tId) Returns: 0 if successful, -1 otherwise  /* Abort transaction tId */ int abort(int tId) Returns: 0 BlockDB is implemented as follows:  BlockDB maintains a cache of blocks in main memory. It organizes this as a collection, called Cache, of cache entries. Each cache entry e is an object Cache(e) with three attributes: o int Cache(e).tId, which contains a transaction ID o int Cache(e).diskBlockAddr, which contains the identity (i.e. disk address) of the block stored in Cache(e) o int Cache(e).oldBlock, which contains the last committed content of the block o int Cache(e).newBlock, which contains the last written content of the block The cache is initially empty. This means that the cache has been allocated, and for all entries e in the cache, Cache(e).tId = 0.
  • 2. CSEP 545 Transaction Processing for E-Commerce 1/4/2012 Assignment 1 2  BlockDB maintains a variable lastTransId, which is the (sometimes negated) transaction identifier of the last transaction that was started. It is initialized to 1.  There can be at most one instance of BlockDB running on a system at a given time. It has exclusive access to the disk drive that it uses. BlockDB uses a raw disk drive, which supports two operations diskRead and diskWrite  /* Read the value of block at diskBlockAddr from disk and return it in main memory at address memAddr */ int diskRead(int diskBlockAddr, int memAddr)  /* Store the content of the main memory beginning at address memAddr into block diskBlockAddr on disk */ int diskWrite(int diskblockAddr, int memAddr) Returns: For each operation, read or write, the disk drive either performs the intended operation and returns 0 or it has no effect and returns -1. BlockDB implements its five operations as follows. It executes operations one-at-a-time. That is, it executes each invoked operation in its entirety before executing the next invoked operation. lastTrans = 1; int start() { if (lastTrans < 0) { return -1 } else { lastTrans = -(++lastTrans); return lastTrans } } int read(int diskBlockAddr, int tId, int *memBlock) { /* find the cache element e containing the block whose disk address is diskBlockAddr */ if (there is such a cache element e) { /* the disk block at diskBlockAddr is in cache */ Cache(e).tId = tId; memBlock = &Cache(e).newBlock; /* &Cache(e).newBlock is the address of Cache(e).newBlock */ return 0 } else { /* pick a cache entry e, where Cache(e).tId = 0. If there is no such entry, then return -1 */ status = diskRead(diskBlockAddr, &Cache(e).oldBlock); if (status != 0) { return -1 }; Cache(e).newBlock = Cache(e).oldBlock;
  • 3. CSEP 545 Transaction Processing for E-Commerce 1/4/2012 Assignment 1 3 memBlock = &Cache(e).newBlock; Cache(e).diskBlockAddr = diskBlockAddr; Cache(e).tId = tId; return 0 } } /* A transaction should call write(&Cache(e).newBlock, tId) after it updates Cache(e).newBlock. */ int write(int diskBlockAddr, int tId) { /* find the cache entry e for block diskBlockAddr */ if (there is no such entry) { return 0 } else { Cache(e).tId = tId; return 1 } } int commit(int tId) { for (each cache entry e where Cache(e).tId == tId) { status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).newBlock); Cache(e).tId = -tId; if (status == -1) { Abort(tId); return -1 } Cache(e).oldBlock = Cache(e).newBlock } for (each cache entry e where Cache(e).tId == -tId) { Cache(e).tId = 0 } lastTrans = -lastTrans; return 0 } int abort(int tId) { for (all cache entries e, where Cache(e).tId == -tId) { Repeat { status = diskWrite(Cache(e).diskBlockAddr, &Cache(e).oldBlock) } until (status == 0); /* Of course, this will not terminate if diskWrite keeps */ /* failing, but ignore that issue */ Cache(e).newBlock = Cache(e).oldBlock }
  • 4. CSEP 545 Transaction Processing for E-Commerce 1/4/2012 Assignment 1 4 for (all cache entries e) { Cache(e).tId = 0 } lastTrans = -lastTrans; return 0 } Questions For each of the scenarios below, analyze whether transactions that use BlockDB satisfy the four ACID properties. In each case, if a property is violated, show a counterexample where it does not satisfy the property. In the latter case, you might want to suggest a way to fix the implementation, but don’t lose sleep over it, since it might be pretty hard. a. The operating system and BlockDB never crash. Transactions run serially. Please consider the case in which a transaction is terminated early (e.g., due to division by zero) and an agent detects this and aborts the transaction. b. The operating system can crash, in which case main memory is lost. Transactions run serially. c. The operating system and BlockDB never crash. Transactions run serially. DiskWrite(b, addr) always returns 0, but it might corrupt block b on disk. d. A variation of (c): The operating system and BlockDB never crash. Transactions run serially. If DiskWrite(b, addr) returns -1 then it might have corrupted block b on disk (but not if it returns 0). e. The operating system and BlockDB never crash. The specification of Start is modified to allow up to two transactions to run concurrently. So its implementation is modified to keep track of the number of active transactions and return -1 if it is called when two transactions are concurrently active.