SlideShare a Scribd company logo
1 of 4
Download to read offline
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 IdiomsAlex 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 profitAlex Matrosov
 
HexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierHexRaysCodeXplorer: make object-oriented RE easier
HexRaysCodeXplorer: make object-oriented RE easierAlex Matrosov
 
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 8Hermann Hueck
 
разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4разработка серверов и серверных приложений лекция №4
разработка серверов и серверных приложений лекция №4Eugeniy Tyumentcev
 
[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 GCDPrashant Rane
 
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 2015Ben Asher
 
Transactional Memory for Smalltalk
Transactional Memory for SmalltalkTransactional Memory for Smalltalk
Transactional Memory for SmalltalkLukas Renggli
 
Python Deserialization Attacks
Python Deserialization AttacksPython Deserialization Attacks
Python Deserialization AttacksNSConclave
 

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 (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 BlockDB transaction processing analysis

Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Béo Tú
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with BlocksJeff 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 2019GOG.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 SystemdRichard 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 .docxoscars29
 
Let's Talk Locks!
Let's Talk Locks!Let's Talk Locks!
Let's Talk Locks!C4Media
 
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 OptimizationWei Lin
 
Memory Optimization
Memory OptimizationMemory Optimization
Memory Optimizationguest3eed30
 
Lockless Programming GDC 09
Lockless Programming GDC 09Lockless Programming GDC 09
Lockless Programming GDC 09Lee Hanxue
 

Similar to BlockDB transaction processing analysis (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

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

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 

BlockDB transaction processing analysis

  • 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.