Commit efe42792 authored by Mayank Prasad's avatar Mayank Prasad

Bug#13417440 : 63340: ARCHIVE FILE IO NOT INSTRUMENTED

      
Details:
 - Archive storage engine file access were not instrumented and thus
   were not shown in PS tables.
      
Fix:
 - Added instrumentation code by using PS Apis for I/O.
parent b91be277
......@@ -38,7 +38,7 @@ spins
NULL
select name from performance_schema.setup_instruments order by name limit 1;
name
wait/io/file/csv/data
wait/io/file/archive/data
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
......@@ -53,7 +53,7 @@ spins
NULL
select name from performance_schema.setup_instruments order by name limit 1;
name
wait/io/file/csv/data
wait/io/file/archive/data
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
......
......@@ -9,4 +9,4 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
misc.test : bug#14113704 24/04/2012 Mayank issure reported causing failure.
......@@ -37,6 +37,8 @@ void putLong(File file, uLong x);
uLong getLong(azio_stream *s);
void read_header(azio_stream *s, unsigned char *buffer);
extern PSI_file_key arch_key_file_data;
/* ===========================================================================
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb"). The file is given either by file descriptor
......@@ -113,7 +115,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd)
s->stream.avail_out = AZ_BUFSIZE_WRITE;
errno = 0;
s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd;
s->file = fd < 0 ? mysql_file_open(arch_key_file_data, path, Flags, MYF(0)) : fd;
DBUG_EXECUTE_IF("simulate_archive_open_failure",
{
if (s->file >= 0)
......@@ -235,7 +237,7 @@ int get_byte(s)
if (s->stream.avail_in == 0)
{
errno = 0;
s->stream.avail_in= (uInt) my_read(s->file, (uchar *)s->inbuf,
s->stream.avail_in= (uInt) mysql_file_read(s->file, (uchar *)s->inbuf,
AZ_BUFSIZE_READ, MYF(0));
if (s->stream.avail_in == 0)
{
......@@ -277,7 +279,8 @@ void check_header(azio_stream *s)
if (len < 2) {
if (len) s->inbuf[0] = s->stream.next_in[0];
errno = 0;
len = (uInt)my_read(s->file, (uchar *)s->inbuf + len, AZ_BUFSIZE_READ >> len, MYF(0));
len = (uInt)mysql_file_read(s->file, (uchar *)s->inbuf + len,
AZ_BUFSIZE_READ >> len, MYF(0));
if (len == (uInt)-1) s->z_err = Z_ERRNO;
s->stream.avail_in += len;
s->stream.next_in = s->inbuf;
......@@ -468,7 +471,8 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, size_t len, int *error)
if (s->stream.avail_out > 0)
{
s->stream.avail_out -=
(uInt)my_read(s->file, (uchar *)next_out, s->stream.avail_out, MYF(0));
(uInt)mysql_file_read(s->file, (uchar *)next_out,
s->stream.avail_out, MYF(0));
}
len -= s->stream.avail_out;
s->in += len;
......@@ -481,7 +485,8 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, size_t len, int *error)
if (s->stream.avail_in == 0 && !s->z_eof) {
errno = 0;
s->stream.avail_in = (uInt)my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0));
s->stream.avail_in = (uInt)mysql_file_read(s->file, (uchar *)s->inbuf,
AZ_BUFSIZE_READ, MYF(0));
if (s->stream.avail_in == 0)
{
s->z_eof = 1;
......@@ -548,7 +553,7 @@ unsigned int azwrite (azio_stream *s, const voidp buf, unsigned int len)
{
s->stream.next_out = s->outbuf;
if (my_write(s->file, (uchar *)s->outbuf, AZ_BUFSIZE_WRITE,
if (mysql_file_write(s->file, (uchar *)s->outbuf, AZ_BUFSIZE_WRITE,
MYF(0)) != AZ_BUFSIZE_WRITE)
{
s->z_err = Z_ERRNO;
......@@ -596,7 +601,7 @@ int do_flush (azio_stream *s, int flush)
if (len != 0)
{
s->check_point= my_tell(s->file, MYF(0));
if ((uInt)my_write(s->file, (uchar *)s->outbuf, len, MYF(0)) != len)
if ((uInt)mysql_file_write(s->file, (uchar *)s->outbuf, len, MYF(0)) != len)
{
s->z_err = Z_ERRNO;
return Z_ERRNO;
......@@ -783,7 +788,7 @@ void putLong (File file, uLong x)
for (n = 0; n < 4; n++)
{
buffer[0]= (int)(x & 0xff);
my_write(file, buffer, 1, MYF(0));
mysql_file_write(file, buffer, 1, MYF(0));
x >>= 8;
}
}
......
......@@ -114,6 +114,8 @@ static HASH archive_open_tables;
#define DATA_BUFFER_SIZE 2 // Size of the data used in the data file
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
extern "C" PSI_file_key arch_key_file_data;
/* Static declarations for handerton */
static handler *archive_create_handler(handlerton *hton,
TABLE_SHARE *table,
......@@ -159,6 +161,14 @@ static PSI_mutex_info all_archive_mutexes[]=
{ &az_key_mutex_ARCHIVE_SHARE_mutex, "ARCHIVE_SHARE::mutex", 0}
};
PSI_file_key arch_key_file_metadata, arch_key_file_data, arch_key_file_frm;
static PSI_file_info all_archive_files[]=
{
{ &arch_key_file_metadata, "metadata", 0},
{ &arch_key_file_data, "data", 0},
{ &arch_key_file_frm, "FRM", 0}
};
static void init_archive_psi_keys(void)
{
const char* category= "archive";
......@@ -169,6 +179,9 @@ static void init_archive_psi_keys(void)
count= array_elements(all_archive_mutexes);
PSI_server->register_mutex(category, all_archive_mutexes, count);
count= array_elements(all_archive_files);
PSI_server->register_file(category, all_archive_files, count);
}
#endif /* HAVE_PSI_INTERFACE */
......@@ -262,7 +275,7 @@ int archive_discover(handlerton *hton, THD* thd, const char *db,
build_table_filename(az_file, sizeof(az_file) - 1, db, name, ARZ, 0);
if (!(my_stat(az_file, &file_stat, MYF(0))))
if (!(mysql_file_stat(arch_key_file_data, az_file, &file_stat, MYF(0))))
goto err;
if (!(azopen(&frm_stream, az_file, O_RDONLY|O_BINARY)))
......@@ -712,7 +725,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
There is a chance that the file was "discovered". In this case
just use whatever file is there.
*/
if (!(my_stat(name_buff, &file_stat, MYF(0))))
if (!(mysql_file_stat(arch_key_file_data, name_buff, &file_stat, MYF(0))))
{
my_errno= 0;
if (!(azopen(&create_stream, name_buff, O_CREAT|O_RDWR|O_BINARY)))
......@@ -729,19 +742,19 @@ int ha_archive::create(const char *name, TABLE *table_arg,
/*
Here is where we open up the frm and pass it to archive to store
*/
if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0)
if ((frm_file= mysql_file_open(arch_key_file_frm, name_buff, O_RDONLY, MYF(0))) >= 0)
{
if (!mysql_file_fstat(frm_file, &file_stat, MYF(MY_WME)))
{
frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0));
if (frm_ptr)
{
my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
mysql_file_read(frm_file, frm_ptr, file_stat.st_size, MYF(0));
azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size);
my_free(frm_ptr);
}
}
my_close(frm_file, MYF(0));
mysql_file_close(frm_file, MYF(0));
}
if (create_info->comment.str)
......@@ -1607,7 +1620,7 @@ int ha_archive::info(uint flag)
{
MY_STAT file_stat; // Stat information for the data file
(void) my_stat(share->data_file_name, &file_stat, MYF(MY_WME));
(void) mysql_file_stat(arch_key_file_data, share->data_file_name, &file_stat, MYF(MY_WME));
if (flag & HA_STATUS_TIME)
stats.update_time= (ulong) file_stat.st_mtime;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment