diff options
author | unknown <ingo@mysql.com> | 2004-09-18 20:33:39 +0200 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2004-09-18 20:33:39 +0200 |
commit | 3573368ba9ed9037b6d26837fefa07502a745d62 (patch) | |
tree | f3658d5151d0eec668e2a6a6702b3ad26c908d15 /sql/sql_table.cc | |
parent | 3c1f414812cf11751638f0a6a16f0e58112df2d5 (diff) | |
download | mariadb-git-3573368ba9ed9037b6d26837fefa07502a745d62.tar.gz |
bug#2831 - --extenral-locking does not fully work with --myisam-recover.
Changed the semantics of open_count so that it is decremented
at every unlock (if it was incremented due to data changes).
So it indicates a crash, if it is non-zero after a lock.
The table will then be repaired.
myisam/mi_close.c:
bug#2831 - --extenral-locking does not fully work with --myisam-recover.
To avoid flushing the open_count at every unlock,
we need to do so at close at least.
myisam/mi_locking.c:
bug#2831 - --extenral-locking does not fully work with --myisam-recover.
open_count is now decremented at unlock (from a writelock) with
mi_unlock_open_count(). After every new lock the state is read
from the index file and the open_count checked. If not zero,
another server must have crashed, so the table is marked as crashed.
In certain situations the decremented open_count mut be flushed to
the index file. I tried to keep these extra flushes as seldom as possible.
sql/ha_myisam.cc:
bug#2831 - --extenral-locking does not fully work with --myisam-recover.
Added code to repair the table, if it is marked crashed after
successful locking and the --myisam-recover option is set.
sql/sql_table.cc:
This does not really belong to the bugfix for #2831.
But it was detected during fixing the external locking.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e2e186abb0d..0dd5c65bf79 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2208,7 +2208,12 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (!(copy= new Copy_field[to->fields])) DBUG_RETURN(-1); /* purecov: inspected */ - to->file->external_lock(thd,F_WRLCK); + if (to->file->external_lock(thd, F_WRLCK)) + { + /* We must always unlock, even when lock failed. */ + (void) to->file->external_lock(thd, F_UNLCK); + DBUG_RETURN(-1); + } to->file->extra(HA_EXTRA_WRITE_CACHE); from->file->info(HA_STATUS_VARIABLE); to->file->deactivate_non_unique_index(from->file->records); @@ -2308,11 +2313,12 @@ copy_data_between_tables(TABLE *from,TABLE *to, error=1; if (ha_commit(thd)) error=1; - if (to->file->external_lock(thd,F_UNLCK)) - error=1; err: free_io_cache(from); *copied= found_count; *deleted=delete_count; + /* we must always unlock the table on return. */ + if (to->file->external_lock(thd,F_UNLCK)) + error=1; DBUG_RETURN(error > 0 ? -1 : 0); } |