Fix Bug #59390 row_merge_build_indexes() fails to register tmpfd for PFS

rb://582 approved by Marko
This commit is contained in:
Jimmy Yang 2011-01-28 01:38:21 -08:00
parent 5d2239e118
commit fe4e126849

View file

@ -2158,13 +2158,15 @@ row_merge_drop_temp_indexes(void)
} }
/*********************************************************************//** /*********************************************************************//**
Create a merge file. */ Creates temperary merge files, and if UNIV_PFS_IO defined, register
static the file descriptor with Performance Schema.
void @return File descriptor */
row_merge_file_create( UNIV_INLINE
/*==================*/ int
merge_file_t* merge_file) /*!< out: merge file structure */ row_merge_file_create_low(void)
/*===========================*/
{ {
int fd;
#ifdef UNIV_PFS_IO #ifdef UNIV_PFS_IO
/* This temp file open does not go through normal /* This temp file open does not go through normal
file APIs, add instrumentation to register with file APIs, add instrumentation to register with
@ -2176,14 +2178,46 @@ row_merge_file_create(
"Innodb Merge Temp File", "Innodb Merge Temp File",
__FILE__, __LINE__); __FILE__, __LINE__);
#endif #endif
merge_file->fd = innobase_mysql_tmpfile(); fd = innobase_mysql_tmpfile();
#ifdef UNIV_PFS_IO
register_pfs_file_open_end(locker, fd);
#endif
return(fd);
}
/*********************************************************************//**
Create a merge file. */
static
void
row_merge_file_create(
/*==================*/
merge_file_t* merge_file) /*!< out: merge file structure */
{
merge_file->fd = row_merge_file_create_low();
merge_file->offset = 0; merge_file->offset = 0;
merge_file->n_rec = 0; merge_file->n_rec = 0;
#ifdef UNIV_PFS_IO
register_pfs_file_open_end(locker, merge_file->fd);
#endif
} }
/*********************************************************************//**
Destroy a merge file. And de-register the file from Performance Schema
if UNIV_PFS_IO is defined. */
UNIV_INLINE
void
row_merge_file_destroy_low(
/*=======================*/
int fd) /*!< in: merge file descriptor */
{
#ifdef UNIV_PFS_IO
struct PSI_file_locker* locker = NULL;
PSI_file_locker_state state;
register_pfs_file_io_begin(&state, locker,
fd, 0, PSI_FILE_CLOSE,
__FILE__, __LINE__);
#endif
close(fd);
#ifdef UNIV_PFS_IO
register_pfs_file_io_end(locker, 0);
#endif
}
/*********************************************************************//** /*********************************************************************//**
Destroy a merge file. */ Destroy a merge file. */
static static
@ -2192,20 +2226,10 @@ row_merge_file_destroy(
/*===================*/ /*===================*/
merge_file_t* merge_file) /*!< out: merge file structure */ merge_file_t* merge_file) /*!< out: merge file structure */
{ {
#ifdef UNIV_PFS_IO
struct PSI_file_locker* locker = NULL;
PSI_file_locker_state state;
register_pfs_file_io_begin(&state, locker, merge_file->fd, 0, PSI_FILE_CLOSE,
__FILE__, __LINE__);
#endif
if (merge_file->fd != -1) { if (merge_file->fd != -1) {
close(merge_file->fd); row_merge_file_destroy_low(merge_file->fd);
merge_file->fd = -1; merge_file->fd = -1;
} }
#ifdef UNIV_PFS_IO
register_pfs_file_io_end(locker, 0);
#endif
} }
/*********************************************************************//** /*********************************************************************//**
@ -2600,7 +2624,7 @@ row_merge_build_indexes(
row_merge_file_create(&merge_files[i]); row_merge_file_create(&merge_files[i]);
} }
tmpfd = innobase_mysql_tmpfile(); tmpfd = row_merge_file_create_low();
/* Reset the MySQL row buffer that is used when reporting /* Reset the MySQL row buffer that is used when reporting
duplicate keys. */ duplicate keys. */
@ -2642,7 +2666,7 @@ row_merge_build_indexes(
} }
func_exit: func_exit:
close(tmpfd); row_merge_file_destroy_low(tmpfd);
for (i = 0; i < n_indexes; i++) { for (i = 0; i < n_indexes; i++) {
row_merge_file_destroy(&merge_files[i]); row_merge_file_destroy(&merge_files[i]);