summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorSatya B <satya.bn@sun.com>2009-03-20 14:48:14 +0530
committerSatya B <satya.bn@sun.com>2009-03-20 14:48:14 +0530
commit295e876718d03d8c19fae2427421571b5c935f7f (patch)
tree0a9eb20256ee6e39197b38f77205532f80c1daa5 /myisam
parent27e3214b494b0cec3bdb5de927d18bc04323f6fb (diff)
downloadmariadb-git-295e876718d03d8c19fae2427421571b5c935f7f.tar.gz
Fix for BUG#41330 -Myisam table open count set to zero before index blocks
are written. When we have a myisam table with DELAY_KEY_WRITE option, index updates are not applied until the flush tables command is issued or until the server is shutdown. If server gets killed before the index updates are written to disk, the index file is corrupted as expected but the table is not marked as crashed. So when we start server with myisam-recover, table is not repaired leaving the table unusable. The problem is when we try to write the index updates to index file, we decrement the open_count even before the flushing the keys to index file. Fixed by moving the decrement operation after flushing the keys to the index file. So we always have non zero open count if the flush table operation is killed and when the server is started with mysiam-recover option, it marks the table as crashed and repairs it. Note: No testcase for added as we need to kill the server and start the server with different set of options and other non trivial operations involved. myisam/mi_close.c: Decrement open count after flushing the key blocks to the key file. If the server(with DELAY_KEY_WRITE option) is killed before flush_key_blocks operation, we will have non zero open count and the table can be repaired when server is started with --myisam-recover option.
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_close.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/myisam/mi_close.c b/myisam/mi_close.c
index 81d32be468a..43eebed520b 100644
--- a/myisam/mi_close.c
+++ b/myisam/mi_close.c
@@ -35,8 +35,6 @@ int mi_close(register MI_INFO *info)
if (info->lock_type == F_EXTRA_LCK)
info->lock_type=F_UNLCK; /* HA_EXTRA_NO_USER_CHANGE */
- if (share->reopen == 1 && share->kfile >= 0)
- _mi_decrement_open_count(info);
if (info->lock_type != F_UNLCK)
{
@@ -78,6 +76,8 @@ int mi_close(register MI_INFO *info)
*/
if (share->mode != O_RDONLY && mi_is_crashed(info))
mi_state_info_write(share->kfile, &share->state, 1);
+ /* Decrement open count must be last I/O on this file. */
+ _mi_decrement_open_count(info);
if (my_close(share->kfile,MYF(0)))
error = my_errno;
}