1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

WL#3072 Maria Recovery. Making DDLs durable in Maria:

Sync table files after CREATE (of non-temp table), DROP, RENAME,
TRUNCATE, sync directories and symlinks (for the 3 first commands).
Comments for future log records.
In ma_rename(), if rename of index works and then rename of data fails,
try to undo the rename of the index to leave a consistent state.


mysys/my_symlink.c:
  sync directory after creation of a symbolic link in it, if asked
mysys/my_sync.c:
  comment. Fix for when the file's name has no directory in it.
storage/maria/ma_create.c:
  sync files and links and dirs when creating a non-temporary table.
  Optimizations of the above to reduce syncs in the common cases:
  * if index file and data file have the exact same paths (regular
  and link), sync the directories (of regular and link) only once
  after creating the last file (the data file).
  * don't sync the data file if we didn't write to it (always true
  in our builds).
storage/maria/ma_delete_all.c:
  sync files after truncating a table
storage/maria/ma_delete_table.c:
  sync files and symbolic links and dirs after dropping a table
storage/maria/ma_extra.c:
  a function which wraps the sync of the index file and the sync of the
  data file.
storage/maria/ma_locking.c:
  using a wrapper function
storage/maria/ma_rename.c:
  sync files and symbolic links and dirs after renaming a table.
  If rename of index works and then rename of data fails, try to undo
  the rename of the index to leave a consistent state. That is just a
  try, it may fail...
storage/maria/ma_test3.c:
  warning to not pay attention to this test.
storage/maria/maria_def.h:
  declaration for the function added to ma_extra.c
This commit is contained in:
unknown
2006-11-27 22:01:29 +01:00
parent adfba203ff
commit de6f550ec7
10 changed files with 134 additions and 24 deletions

View File

@ -52,7 +52,7 @@ int my_sync(File fd, myf my_flags)
#if defined(F_FULLFSYNC)
/*
In Mac OS X >= 10.3 this call is safer than fsync() (it forces the
disk's cache).
disk's cache and guarantees ordered writes).
*/
if (!(res= fcntl(fd, F_FULLFSYNC, 0)))
break; /* ok */
@ -89,6 +89,7 @@ int my_sync(File fd, myf my_flags)
} /* my_sync */
static const char cur_dir_name[]= {FN_CURLIB, 0};
/*
Force directory information to disk.
@ -107,11 +108,14 @@ int my_sync_dir(const char *dir_name, myf my_flags)
DBUG_PRINT("my",("Dir: '%s' my_flags: %d", dir_name, my_flags));
File dir_fd;
int res= 0;
const char *correct_dir_name;
/* Sometimes the path does not contain an explicit directory */
correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name;
/*
Syncing a dir may give EINVAL on tmpfs on Linux, which is ok.
EIO on the other hand is very important. Hence MY_IGNORE_BADFD.
*/
if ((dir_fd= my_open(dir_name, O_RDONLY, MYF(my_flags))) >= 0)
if ((dir_fd= my_open(correct_dir_name, O_RDONLY, MYF(my_flags))) >= 0)
{
if (my_sync(dir_fd, MYF(my_flags | MY_IGNORE_BADFD)))
res= 2;