Lost-Update-Problem in Concurrent schedules

In a schedule, if update performed by transaction T1 on data item ‘X’ gets overwritten by the update performed by transaction T2 on same data item ‘X’, then we say that update of T1 is lost to the update of T2.

This problem is known as Lost-Update-Problem in concurrent schedules.

Example:

with X = 50 and Y =50 (initial values)

T1 T2
read(x) (T1I1)
x=x+10 (T1I2)
read(x) (T2I1)
x=x+20 (T2I2)
write(x) (T1I3)
read(y) (T1I4)
write(x) (T2I2)
commit (T2I2)
y=y+10 (T1I5)
write(y) (T1I6)
commit (T1I7)

Explanation:

in concurrent execution,

  • T1 reads data item X(=50) from DB and increment its value by 10. (till now it has not performed any write and commit operation)
  • now T2 reads data item X(=50 because T1 has not performed any write and commit) from DB and increment it by 20.
  • T1 writes X. it will write X = 60 (50+10) in local cache. it has not perform any commit so value will not be updated in DB.
  • T1 read Y(=50).
  • T2 writes X. As T2 performed x=x+20 which x=70 will be written to local cache.
  • T2 performs commit which will write x=70 from local cache to DB. Now DB holds X value as 70.
  • Here in this step value of X which is updated as 60 in local cache but not committed to DB is lost to the update done by T2. it is defined as Lost Update Problem.
  • Now T1 will increment Y by 10. (Y = 60 after increment)
  • T1 will write Y = 60 to local cache.
  • T1 commit will update Y value as 60 to DB.
  • final X = 70 and Y = 60 values will be there in DB.

Serial Schedules, Concurrent Schedules and Conflict Operations

A schedule is the representation of execution sequence for all the instructions of the transactions.

Schedules are categorized in two types:

  • Serial Schedules
  • Concurrent Schedules

Serial Schedules:

A schedule is said to be serial if and only if all the instructions of all the transactions get executed non-preemptively as an unit.

OR

Each serial schedule consists of a sequence of instructions from various transactions, where the instructions belonging to one single transaction appear together in that schedule.

Thus, for a set of n transactions, there exist n! different valid serial schedules.

if there exist three transactions then all possible serial schedules are:

            here n = 3(no of transactions)

           3! = 3*2*1 = 6 serial schedules

T1->T2->T3, T1->T3->T2,

T2->T1->T3, T2->T3->T1,

T3->T2->T1, T3->T2->T1

Serial schedules gives guarantee for data consistency.

Concurrent Schedules:

A schedule is said to be concurrent in case the instructions of the transactions get executed preemptively.

When the database system executes several transactions concurrently, the corresponding schedule no longer needs to be serial.

If two transactions are running concurrently, the operating system may execute one transaction for a little while, then perform a context switch, execute the second transaction for some time, and then switch back to the first transaction for some time, and so on. With multiple transactions, the CPU time is shared among all the transactions.

Several execution sequences are possible, since the various instructions from both
transactions may now be interleaved.

In general, it is not possible to predict exactly how many instructions of a transaction will be executed before the CPU switches to another transaction.

Thus, the number of possible schedules for a set of n transactions is much larger than n!.

Concurrent schedules might get affected with conflicting operations and hence does not give guaranty for data consistency.

Conflicting Operations:

A pair of operations is said to be conflicting with each other if and only if:

  • They belong to different transactions
  • Both the operations are accessing the same data item.
  • At least one of these operations is write operation.

Possible conflict:

write-write, write-read, read-write.

Disadvantages of Serial Schedules:

  1. High average waiting time.
  2. Low response time and low throughput could be possible.

Advantage of Serial Schedules:

  1. It always gives guarantee for data consistency.

Disadvantages of Concurrent Schedules:

  1. Possible data inconsistency.
  2. some time too much context switching

Advantage of Concurrent Schedules:

  1. Reduce waiting time.
  2. improve response time and throughput.

Hence RDBMS has implemented Concurrency control mechanism to produce serializable schedules.

Serializable Schedules:

A schedule is said to be serializable if and only if the result of the given concurrent schedule is equivalent to one of the possible serial schedule.

 

 

 

 

Concurrent Executions in Transaction

Transaction-processing systems usually allow multiple transactions to run concurrently. Allowing multiple transactions to update data concurrently causes several complications with consistency of the data.

Ensuring consistency in spite of concurrent execution of transactions requires extra work; it is far easier to insist that transactions run serially—that is, one at a time, each starting only after the previous one has completed.

However, there are two good reasons for allowing concurrency:

Improved throughput and resource utilization:

  • A transaction consists of many steps. Some involve I/O activity; others involve CPU activity. The CPU and the disks in a computer system can operate in parallel. Therefore, I/O activity can be done in parallel with processing at the CPU.
  • The parallelism of the CPU and the I/O system can therefore be exploited to run multiple transactions in parallel.
  • While a read or write on behalf of one transaction is in progress on one disk, another transaction can be running in the CPU, while another disk may be executing a read or write on behalf of a third transaction.
  • All of this increases the throughput of the system—that is, the number of transactions executed in a given amount of time.
  • Correspondingly, the processor and disk utilization also increase; in other words, the processor and disk spend less time idle, or not performing any useful work.

Reduced waiting time:

  • There may be a mix of transactions running on a system, some short and some long.
  • If transactions run serially, a short transaction may have to wait for a preceding long transaction to complete, which can lead to unpredictable delays in running a transaction.
  • If the transactions are operating on different parts of the database, it is better to let them run concurrently, sharing the CPU cycles and disk accesses among them.
  • Concurrent execution reduces the unpredictable delays in running transactions.
  • Moreover, it also reduces the average response time: the average time for a transaction to be completed after it has been submitted.

The idea behind using concurrent execution in a database is essentially the same
as the idea behind using multi programming in an operating system.

The database system must control the interaction among the concurrent transactions to prevent them from destroying the consistency of the database. It is achieved using concurrency-control schemes.

How Google knows everything about you

In current days data is very important thing than money. Hackers tries to stole your data. Many companies working to keep track your data.As all of us knows Google keeps your data… Ok it’s fine… bcz its secured i think. but, for to know Google how much know about you see below.. History – Google […]

via How Google knows everything about you — bewithdhanu

Difference between Normalization and Normal Forms

Normalization:

Normalization is the systematic process applied on the relations to reduce the degree of redundancy.

Normalization is defined as systematic because it always gives guarantee for following properties –

  • Lossless decomposition.
  • Dependency preservation.

Continue reading

Convert local path to UNC (Universal) File Path using Java Script ActiveXObject


<script>

function getUNCPath() {
 var filePath = document.getElementById("uploadedFile").value;

var WshNetwork = new ActiveXObject("WScript.Network"); 
 var Drives = WshNetwork.EnumNetworkDrives(); 
 for (i = 0; i < Drives.length; i += 2) {
 if(Drives.Item(i) != "")
 {
 if(filePath.match("^"+Drives.Item(i))){ 
 filePath = filePath.replace(Drives.Item(i), Drives.Item(i + 1)); 
 break;
 }
 }}
 }

</script>

<form onsubmit="getUNCPath()">
<input type="file" id="uploadedFile"/>
<input type="submit" value="Get the UNC Path!" />
</form>

in razor view engine add the following line to support ActiveXObject:

@using System.Web.Script.Serialization