One of the most important properties of database transaction management is consi
ID: 3813647 • Letter: O
Question
One of the most important properties of database transaction management is consistency. Synchronization of the reads and writes of data is a crucial step in achieving consistency. In this lab, please use SimPy to simulate database transaction reading and writing. Your project should randomly generate read and write events that will read or write a set of data for a period of time. The simulation times, number of data blocks, and longest read or write time period are set at the beginning of the simulation. The simulation time needs to be at least 2xnumber of data blocks x longest read or write time Strategy 1: typically reader and writer: This is the typical strategy where there are multiple readers and a single writer Read Request: if there is no write lock on the data, then grant read lock for the period of time requested. If there is a write lock, then wait till the read lock is free and it is the reader’s turn. Write Request: if there is no write lock on the data, then grant write lock for the period of time requested. If there is a write lock, then wait till the write lock is free and it is the writers’ turn. Lab A: Utilizing this strategy there is still a chance for starvation. Please suggest and implement a solution that would avoid starvation. Strategy 2: invalid dirty write This approach assumes that the likelihood of write conflict is rare. Thus, locks to read or write are not acquired, but rather the timestamp of the last read/write is used. If the time stamp of the last read/write is after the start of the current write, the write is invalidated and the write transaction is reattempted. Lab B: please implement this strategy and run the simulation to see how many data blocks do you need to reduce the average percent (at least 10 runs) write invalid events to below 5% * If you are working on this project by yourself, you may choose either part A or B. SimPY is a simulation package that you can install after you have setup your Python environments. Anaconda is a simple Python package with most of the libraries and packages installed. SimPY can be installed via “pip install simpy” after conda install. Examples of interests includes: Resources: Store (Event Latency and Process Communication) and Shared events: Move Renege
Explanation / Answer
The characteristics of these four properties as defined by Reuter and Härder are as follows:
Atomicity.
Consistency.
Isolation.
Durability.
Atomicity failure.
Consistency failure.
Isolation failure.
Durability failure.
Transactional databases[edit]
A transactional database is a DBMS where write transactions on the database are able to be rolled back if they are not
completed properly (e.g. due to power or connectivity loss).
Most modern relational database management systems fall into the category of databases that support transactions.
In a database system a transaction might consist of one or more data-manipulation statements and queries, each reading
and/or writing information in the database. Users of database systems consider consistency and integrity of data as highly
important. A simple transaction is usually issued to the database system in a language like SQL wrapped in a transaction,
using a pattern similar to the following:
Begin the transaction
Execute a set of data manipulations and/or queries
If no errors occur then commit the transaction and end it
If errors occur then roll back the transaction and end it
If no errors occurred during the execution of the transaction then the system commits the transaction. A transaction
commit operation applies all data manipulations within the scope of the transaction and persists the results to the
database. If an error occurs during the transaction, or if the user specifies a rollback operation, the data manipulations
within the transaction are not persisted to the database. In no case can a partial transaction be committed to the
database since that would leave the database in an inconsistent state.
Internally, multi-user databases store and process transactions, often by using a transaction ID or XID.
There are multiple varying ways for transactions to be implemented other than the simple way documented above. Nested
transactions, for example, are transactions which contain statements within them that start new transactions
(i.e. sub-transactions). Multi-level transactions are a variant of nested transactions where the sub-transactions take
place at different levels of a layered system architecture (e.g., with one operation at the database-engine level, one
operation at the operating-system level) [2] Another type of transaction is the compensating transaction.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.