diff options
author | unknown <jimw@mysql.com> | 2005-03-02 18:14:58 -0800 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-03-02 18:14:58 -0800 |
commit | f88269794e8e6ab4433fc4b34aea12e5de2dd86c (patch) | |
tree | 5becdc820031f0da17e62597662fcbf51b21b056 | |
parent | fd4b5c8ddcb29f22343f4e84fbf3ac02fe8aab50 (diff) | |
download | mariadb-git-f88269794e8e6ab4433fc4b34aea12e5de2dd86c.tar.gz |
Avoid calls to my_seek() and my_tell() on log files so that
non-seekable files like FIFOs can be used for logs other
than the binlog. (Bug #8271)
include/my_sys.h:
Add APPEND_CACHE cache type
mysys/mf_iocache.c:
Handle APPEND_CACHE cache type to avoid calling my_seek() and my_tell()
on logs opened O_APPEND that we never read from (so they can be a
non-seekable file like a FIFO).
sql/mysqld.cc:
Use APPEND_CACHE for log files not set to SEQ_READ_APPEND.
-rw-r--r-- | include/my_sys.h | 1 | ||||
-rw-r--r-- | mysys/mf_iocache.c | 16 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index 0fdb8d640e7..0aae1ac3c9d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -270,6 +270,7 @@ enum loglevel { enum cache_type { READ_CACHE,WRITE_CACHE, + APPEND_CACHE, /* Like WRITE_CACHE, but only append */ SEQ_READ_APPEND /* sequential read or append */, READ_FIFO, READ_NET,WRITE_NET}; diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index a7937da0cc2..e8cef2a2529 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -88,7 +88,7 @@ static void my_aiowait(my_aio_result *result); void setup_io_cache(IO_CACHE* info) { /* Ensure that my_b_tell() and my_b_bytes_in_cache works */ - if (info->type == WRITE_CACHE) + if (info->type == WRITE_CACHE || info->type == APPEND_CACHE) { info->current_pos= &info->write_pos; info->current_end= &info->write_end; @@ -223,7 +223,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, #endif } - if (type == WRITE_CACHE) + if (type == WRITE_CACHE || type == APPEND_CACHE) info->write_end= info->buffer+info->buffer_length- (seek_offset & (IO_SIZE-1)); else @@ -293,6 +293,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, /* One can't do reinit with the following types */ DBUG_ASSERT(type != READ_NET && info->type != READ_NET && type != WRITE_NET && info->type != WRITE_NET && + type != APPEND_CACHE && info->type != APPEND_CACHE && type != SEQ_READ_APPEND && info->type != SEQ_READ_APPEND); /* If the whole file is in memory, avoid flushing to disk */ @@ -1098,7 +1099,8 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) my_off_t pos_in_file; DBUG_ENTER("my_b_flush_io_cache"); - if (!(append_cache = (info->type == SEQ_READ_APPEND))) + if (!(append_cache = (info->type == SEQ_READ_APPEND || + info->type == APPEND_CACHE))) need_append_buffer_lock=0; if (info->type == WRITE_CACHE || append_cache) @@ -1145,7 +1147,13 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) else { info->end_of_file+=(info->write_pos-info->append_read_pos); - DBUG_ASSERT(info->end_of_file == my_tell(info->file,MYF(0))); + /* + We only need to worry that info->end_of_file is really accurate + for SEQ_READ_APPEND. For APPEND_CACHE, it is possible that the + file is non-seekable, like a FIFO. + */ + DBUG_ASSERT(info->type != SEQ_READ_APPEND || + info->end_of_file == my_tell(info->file,MYF(0))); } info->append_read_pos=info->write_pos=info->write_buffer; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f104e461d6a..aac42e95c85 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2198,7 +2198,7 @@ bool open_log(MYSQL_LOG *log, const char *hostname, opt_name=tmp; } return log->open(opt_name, type, 0, index_file_name, - (read_append) ? SEQ_READ_APPEND : WRITE_CACHE, + (read_append) ? SEQ_READ_APPEND : APPEND_CACHE, no_auto_events, max_size); } |