Guest User

Untitled

a guest
May 10th, 2016
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. Hi, friendly neighborhood DBA here.
  2.  
  3. Turns out @Abdussamad and @jarland are both right because "data corruption/data loss" has two different meanings.
  4.  
  5. **Where @Abdussamad was right:**
  6.  
  7. MyISAM doesn't support foreign keys and is not transactionally consistent. So if we send these two statements like these (semi-colons left out because CloudFlare was having kittens):
  8.  
  9. UPDATE accounts SET balance = balance - 1000, note = 'Taylor Swift Fan Club Special Dues' WHERE owner = 'jarland'
  10.  
  11. UPDATE accounts SET balance = balance + 1000, note = 'From jarland' where owner = 'tswift'
  12.  
  13. And the server fails after command #1, then jarland will be out 1000 dollars and Taylor Swift will not receive the credit, meaning she won't send her concert-worn panties to @jarland and man, will he be pissed. Some would call that data loss/data corruption.
  14.  
  15. On the other hand:
  16.  
  17. BEGIN TRANSACTION
  18. UPDATE accounts SET balance = balance - 1000, note = 'Taylor Swift Fan Club Dues' WHERE owner = 'jarland'
  19. UPDATE accounts SET balance = balance + 1000, note = 'From jarland' where owner = 'tswift'
  20. COMMIT
  21.  
  22. Means that either both statements succeed or both fail as a unit - no partial failures. You get that with InnoDB, you don't get it with MyISAM.
  23.  
  24. Now if you're not running the Taylor Swift Fan Club but are instead running a Wordpress blog, you might not even notice a problem if it's just that one comment isn't associated correctly or something.
  25.  
  26. **Where @jarland was right:**
  27.  
  28. If InnoDB isn't recording in a crash-tolerant way, that's actually a completely different issue. The theory is simple - write to an append-only log for performance, then have a daemon the follows behind to flush those blocks back to the datafiles asynchronously. Add something smart in memory to keep track of which blocks are current, and maybe a couple levels of indirection if you want to support point-in-time queries or flashing the DB back, and that's the modern RDBMS. Quite disappointing if InnoDB is not getting something write.
  29.  
  30. I don't do a lot of InnoDB in my ${DAY_JOB} but I've had numerous experience in the last ten years where the rug was pulled from under Oracle or MS SQL Server (from a datacenter power outage to a bad SAN controller to someone doing something stupid) and I've never seen a case where there was a problem with recovery. In general the main commercial DBs are stellar at recovering from mayhem.
Add Comment
Please, Sign In to add comment