Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:31 AM
alf
 
Posts: n/a
Default MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

Hi,

is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst case scenario for MyISAM
backend?


Also is it possible to not to lose data but get them corrupted?


Thx, Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:31 AM
Gordon Burditt
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

>is it possible that due to OS crash or mysql itself crash or some e.g.
>SCSI failure to lose all the data stored in the table (let's say million
>of 1KB rows).


It is always possible that your computer system will catch fire and
lose all data EVEN IF IT'S POWERED OFF. And the same nuclear attack
might take up all your backups, too. And you and all your employees.
Or the whole thing could just be stolen.

Managing to smash just one sector, the sector containing the data
file inode, or worse, the sector containing the data file, index
file, AND table definition inodes, could pretty well kill a table.
I have had the experience of a hard disk controller that sometimes
flipped some bits in the sectors before writing them. It took weeks
to discover this.

>In other words what is the worst case scenario for MyISAM
>backend?


Probably, total loss of data and hardware.

>Also is it possible to not to lose data but get them corrupted?


I call that 'lost'. But yes, it is possible to end up with a bunch
of data that's bad and you don't realize it until things have gotten
much worse.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:31 AM
alf
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

Gordon Burditt wrote:
>>is it possible that due to OS crash or mysql itself crash or some e.g.
>>SCSI failure to lose all the data stored in the table (let's say million
>>of 1KB rows).

>
> Managing to smash just one sector, the sector containing the data
> file inode, or worse, the sector containing the data file, index
> file, AND table definition inodes, could pretty well kill a table.
> I have had the experience of a hard disk controller that sometimes
> flipped some bits in the sectors before writing them. It took weeks
> to discover this.
>
>
>>In other words what is the worst case scenario for MyISAM
>>backend?

>
>
> Probably, total loss of data and hardware.
>


well, let's narrow it down to the mysql bug causing it to crash. Or
better to the all situations where trx's capabilities of InnoDB can
easily take care of a recovery (to the last committed trx).

I wonder if there is a possibility due to internal structure of MyISAM
backend to lose entire table where even recovery tools give up.

Would using ext3 help?


Thx in advance, Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 08:31 AM
Jerry Stuckle
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

alf wrote:
> Gordon Burditt wrote:
>
>>> is it possible that due to OS crash or mysql itself crash or some e.g.
>>> SCSI failure to lose all the data stored in the table (let's say million
>>> of 1KB rows).

>>
>>
>> Managing to smash just one sector, the sector containing the data
>> file inode, or worse, the sector containing the data file, index
>> file, AND table definition inodes, could pretty well kill a table.
>> I have had the experience of a hard disk controller that sometimes
>> flipped some bits in the sectors before writing them. It took weeks
>> to discover this.
>>
>>
>>> In other words what is the worst case scenario for MyISAM
>>> backend?

>>
>>
>>
>> Probably, total loss of data and hardware.
>>

>
> well, let's narrow it down to the mysql bug causing it to crash. Or
> better to the all situations where trx's capabilities of InnoDB can
> easily take care of a recovery (to the last committed trx).
>
> I wonder if there is a possibility due to internal structure of MyISAM
> backend to lose entire table where even recovery tools give up.
>
> Would using ext3 help?
>
>
> Thx in advance, Andy


As Gordon said - anything's possible.

I don't see why ext3 would help. It knows nothing about the internal
format of the tables, and that's what is most likely to get screwed up
in a database crash. I would think it would be almost impossible to
recover to a consistent point in the database unless you have a very
detailed knowledge of the internal format of the files. And even then
it might be impossible if your system is very busy.

The best strategy is to keep regular backups of the database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 08:32 AM
toby
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S, hardware, whatever)

Gordon Burditt wrote:
> >is it possible that due to OS crash or mysql itself crash or some e.g.
> >SCSI failure to lose all the data stored in the table (let's say million
> >of 1KB rows).

>
> It is always possible that your computer system will catch fire and
> lose all data EVEN IF IT'S POWERED OFF. And the same nuclear attack
> might take up all your backups, too. And you and all your employees.
> Or the whole thing could just be stolen.
>
> Managing to smash just one sector, the sector containing the data
> file inode, or worse, the sector containing the data file, index
> file, AND table definition inodes, could pretty well kill a table.
> I have had the experience of a hard disk controller that sometimes
> flipped some bits in the sectors before writing them. It took weeks
> to discover this.


I spent weeks on a similar problem too - turned out to be bad RAM. The
only filesystem that I know of which can handle such hardware failures
is Sun's ZFS:
http://blogs.sun.com/bonwick/entry/zfs_end_to_end_data

>
> >In other words what is the worst case scenario for MyISAM
> >backend?

>
> Probably, total loss of data and hardware.
>
> >Also is it possible to not to lose data but get them corrupted?

>
> I call that 'lost'. But yes, it is possible to end up with a bunch
> of data that's bad and you don't realize it until things have gotten
> much worse.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 08:32 AM
alf
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

Jerry Stuckle wrote:

> I don't see why ext3 would help.



only to not to get the file system corrupted.



> It knows nothing about the internal
> format of the tables, and that's what is most likely to get screwed up
> in a database crash. I would think it would be almost impossible to
> recover to a consistent point in the database unless you have a very
> detailed knowledge of the internal format of the files.



Well, mysql recovery procedures does have that knowledge. There are
different levels of disaster. My assumption is that the file system
survives.


>
> The best strategy is to keep regular backups of the database.
>


in my case it is a bit different. There are millions of rows which get
inserted, live for a few minutes or hours and then they get deleted. the
backup is not even feasible. While I can afford some (1-5%) data loss
due to crash, I still must not lose entire table. Wonder if mysql
recovery procedures can ensure that.

--
alf
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-28-2008, 08:32 AM
Jerry Stuckle
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

alf wrote:
> Jerry Stuckle wrote:
>
>> I don't see why ext3 would help.

>
>
>
> only to not to get the file system corrupted.
>
>


That doesn't mean the tables themselves can't be corrupted. For instance
if MySQL crashes in the middle of large write operation. Nothing the
file system can do to prevent that from happening. And you would have
to know exactly where to stop the file system restore to recover the
data - which would require a good knowledge of MySQL table structure.

>
>> It knows nothing about the internal format of the tables, and that's
>> what is most likely to get screwed up in a database crash. I would
>> think it would be almost impossible to recover to a consistent point
>> in the database unless you have a very detailed knowledge of the
>> internal format of the files.

>
>
>
> Well, mysql recovery procedures does have that knowledge. There are
> different levels of disaster. My assumption is that the file system
> survives.
>


Yes, it does. That's its job, after all. But if the tables themselves
are corrupted, nothing the file system will do will help that. And if
MySQL can't recover the data because of this, which file system you use
doesn't make any difference.
>
>>
>> The best strategy is to keep regular backups of the database.
>>

>
> in my case it is a bit different. There are millions of rows which get
> inserted, live for a few minutes or hours and then they get deleted. the
> backup is not even feasible. While I can afford some (1-5%) data loss
> due to crash, I still must not lose entire table. Wonder if mysql
> recovery procedures can ensure that.
>


Backups are ALWAYS feasible. And critical if you want to keep your data
safe. There is no replacement.

You can get some help by using INNODB tables and enabling the binary
log. That will allow MySQL to recover from the last good backup by
rolling the logs forward. There should be little or no loss of data.

But you still need the backups. There's no way to feasibly roll forward
a year's worth of data, for instance.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-28-2008, 08:32 AM
alf
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

Jerry Stuckle wrote:

> That doesn't mean the tables themselves can't be corrupted. For instance
> if MySQL crashes in the middle of large write operation. Nothing the
> file system can do to prevent that from happening. And you would have
> to know exactly where to stop the file system restore to recover the
> data - which would require a good knowledge of MySQL table structure.


I understand that.


> Yes, it does. That's its job, after all. But if the tables themselves
> are corrupted, nothing the file system will do will help that. And if
> MySQL can't recover the data because of this, which file system you use
> doesn't make any difference.


Not sure I agree. ext3 enables a quick recovery because there is a
trxlog of the file system itself. In ext2 you can lose files. So there
is a small step froward.


>
> Backups are ALWAYS feasible. And critical if you want to keep your data
> safe. There is no replacement.


In my case backups get outdated every minute or so. There is a lot of
data coming into DB and leaving it. Also losing the data from last
minute or so is not as critical (as opposed to banking systems).
Critical is losing like 5%. I know the system is just different.


> You can get some help by using INNODB tables and enabling the binary
> log. That will allow MySQL to recover from the last good backup by
> rolling the logs forward. There should be little or no loss of data.



For some other reasons INNODB is not an option. My job is to find out
if crashing the mysql or the actual hardware the mysql is running on can
lead that significant amount of data (more then 5%) is lost. From what
I understand from here it is.

Thx a lot, A.








Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-28-2008, 08:32 AM
Jerry Stuckle
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S,hardware, whatever)

alf wrote:
> Jerry Stuckle wrote:
>
>> That doesn't mean the tables themselves can't be corrupted. For
>> instance if MySQL crashes in the middle of large write operation.
>> Nothing the file system can do to prevent that from happening. And
>> you would have to know exactly where to stop the file system restore
>> to recover the data - which would require a good knowledge of MySQL
>> table structure.

>
>
> I understand that.
>
>
>> Yes, it does. That's its job, after all. But if the tables
>> themselves are corrupted, nothing the file system will do will help
>> that. And if MySQL can't recover the data because of this, which file
>> system you use doesn't make any difference.

>
>
> Not sure I agree. ext3 enables a quick recovery because there is a
> trxlog of the file system itself. In ext2 you can lose files. So there
> is a small step froward.
>


So? If the file itself is corrupted, all it will do is recover a
corrupted file. What's the gain there?

>
>>
>> Backups are ALWAYS feasible. And critical if you want to keep your
>> data safe. There is no replacement.

>
>
> In my case backups get outdated every minute or so. There is a lot of
> data coming into DB and leaving it. Also losing the data from last
> minute or so is not as critical (as opposed to banking systems).
> Critical is losing like 5%. I know the system is just different.
>


Without backups or logs/journals, I don't think ANY RDB can provide the
recovery you want.

>
>> You can get some help by using INNODB tables and enabling the binary
>> log. That will allow MySQL to recover from the last good backup by
>> rolling the logs forward. There should be little or no loss of data.

>
>
>
> For some other reasons INNODB is not an option. My job is to find out if
> crashing the mysql or the actual hardware the mysql is running on can
> lead that significant amount of data (more then 5%) is lost. From what
> I understand from here it is.
>
> Thx a lot, A.
>
>


You have a problem. The file system will be able to recover a file, but
it won't be able to fix a corrupted file. And without backups and
logs/journals, neither MySQL nor any other RDB will be able to guarantee
even 1% recovery - much less 95%.

Let's say MySQL starts to completely rewrite a 100Mb table. 10 bytes
into it, MySQL crashes. Your file system will see a 10 byte file and
recover that much. The other 99.99999MB will be lost. And without a
backup and binary logs, MySQL will not be able to recover.

Sure, you might be able to roll forward the file system journal. But
you'll have to know *exactly* where to stop or your database will be
inconsistent. And even if you do figure out *exactly* where to stop,
the database may still not be consistent.

You have the wrong answer to your problem. The RDB must do the
logging/journaling. For MySQL that means INNODB. MSSQL, Oracle, DB2,
etc. all have their versions of logging/journaling, also. And they
still require a backup to start.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-28-2008, 08:32 AM
Axel Schwenke
 
Posts: n/a
Default Re: MyISAM engine: worst case scenario in case of crash (mysql, O/S, hardware, whatever)

Jerry Stuckle <jstucklex@attglobal.net> wrote:
> alf wrote:
>>
>> Not sure I agree. ext3 enables a quick recovery because there is a
>> trxlog of the file system itself. In ext2 you can lose files. So there
>> is a small step froward.

>
> So? If the file itself is corrupted, all it will do is recover a
> corrupted file. What's the gain there?


The gain is, that you have a chance to recover at all. With no files,
there is *no* way to recover.

However, thats not a real problem. MySQL never touches the datafile
itself once it is created. Only exception: REPAIR TABLE. This will
recreate the datafile (as new file with extension .TMD) and then
rename files.

DELETE just marks a record as deleted (1 bit). INSERT writes a new
record at the end of the datafile (or into a hole, if one exists).
UPDATE is done either in place or as INSERT + DELETE.

Most file operations on MyISAM tables are easier, faster and less
risky, if the table uses fixed length records. Then there is no need to
collapse adjacent unused records into one, UPDATE can be done in place,
there will be no fragmentation and such.

The MyISAM engine is quite simple. Data and index are held in separate
files. Data is structured in records. Whenever a record is modified,
it's written to disk immediately (however the operation system might
cache this). MyISAM never touches records without need. So if mysqld
goes down while in normal operation, only those records can be damaged
that were in use by active UPDATE, DELETE or INSERT operations.

There are two exceptions: REPAIR TABLE and OPTIMIZE TABLE. Both
recreate the datafile with new name and then switch by renaming.
There is still no chance to lose *both* files.

Indexes are different, though. Indexes are organized in pages and
heavily cached. You can even instruct mysqld to never flush modified
index pages to disk (except at shutdown or cache restructuring).
However indexes can be rebuilt from scratch, without losing data.
The only thing lost is the time needed for recovery.


HTH, XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417