|
Ahhh databases and atomics.....
In theory the transaction either "commits" or "rolls back"
but consider at what stage is the data considered "written" , The issue is that the database can consider it is "committed" , but it is actually held in a volatile ram buffer waiting to be written. a "commit" IS NOT the same as a guarantee of being physically written to the disk surface. There is NO WAY a database can know what the attached storage is.
1. the disk buffer in the computer 2. the ram buffer in the computer 3. the ram buffer in the drive 4. the data is on the disk surface
to understand this you need a very good grounding in database design , have a look on the "oracle" forums , you will see that even with an oracle database it makes extensive use of disk buffers and ram buffers, they even implemented their own file system that wrote directly to the sectors of the disk drive without intervening OS calls.
When a database reads data there is NO flag telling it if the data was from : a disk buffer a drive cache a disk surface a NAS system.
They get round this by using something called a "transaction log" , this is a file that contains the current state of every modification to the database , if the system crashes during a write this log will contain the information and the "commit" status, if you are really really lucky after bringing the system back up you can "roll forward" and the log will exactly match your data files, saying the state of the database is intact. if you are "unlucky" ,I'm afraid it is time for a programmer to go into the database and try and tidy up the mess, this is potentially a bigger problem if you have multi-site replication, where databases allover the world are being synchronized, since the other databases continue to process and get ahead of the "crashed" database, it is also very dependent on how well written the applications that use the database are, a good database cannot make up for a crap application that holds multiple record "locks" over an extended time period.
As such there is a requirement to be able to clearly differentiate mentally between a "commit" and a physical sector write, again..... they are NOT the same thing.
_________________ Universal Declaration of Human Rights: Article 19
|