Commit 93bcda59 authored by unknown's avatar unknown

Merge latest XtraDB from lp:percona-xtradb into MariaDB.


include/my_sys.h:
  Move generic file parsing functions out to shared code, as they are used in several places.
mysys/mf_iocache2.c:
  Move generic file parsing functions out to shared code, as they are used in several places.
sql/log_event.cc:
  Fix XtraDB build with embedded server.
  XtraDB needs access to replication stuff, which is missing in embedded server.
  Solved by defining wrapper function for this which is compiled differently for normal and
  embedded case.
sql/log_event.h:
  Fix XtraDB build with embedded server.
  XtraDB needs access to replication stuff, which is missing in embedded server.
  Solved by defining wrapper function for this which is compiled differently for normal and
  embedded case.
sql/slave.cc:
  Move generic file parsing functions out to shared code, as they are used in several places.
parents d2d7b5bb 121461f6
......@@ -793,6 +793,9 @@ extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
extern my_off_t my_b_filelength(IO_CACHE *info);
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...);
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
extern int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val);
extern int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
const char *prefix, size_t cache_size,
myf cache_myflags);
......
......@@ -29,19 +29,19 @@ TABLE_PRIVILEGES
TRIGGERS
USER_PRIVILEGES
VIEWS
INNODB_BUFFER_POOL_PAGES_INDEX
INNODB_RSEG
INNODB_LOCKS
INNODB_BUFFER_POOL_PAGES
PBXT_STATISTICS
INNODB_CMP
INNODB_RSEG
XTRADB_ENHANCEMENTS
INNODB_TRX
INNODB_BUFFER_POOL_PAGES_INDEX
INNODB_BUFFER_POOL_PAGES_BLOB
INNODB_LOCK_WAITS
INNODB_TRX
INNODB_CMP_RESET
INNODB_CMP
INNODB_LOCK_WAITS
INNODB_CMPMEM_RESET
INNODB_LOCKS
INNODB_CMPMEM
PBXT_STATISTICS
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
......@@ -85,19 +85,19 @@ TABLE_PRIVILEGES TABLE_SCHEMA
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
VIEWS TABLE_SCHEMA
INNODB_BUFFER_POOL_PAGES_INDEX schema_name
INNODB_RSEG rseg_id
INNODB_LOCKS lock_id
INNODB_BUFFER_POOL_PAGES page_type
PBXT_STATISTICS ID
INNODB_CMP page_size
INNODB_RSEG rseg_id
XTRADB_ENHANCEMENTS name
INNODB_TRX trx_id
INNODB_BUFFER_POOL_PAGES_INDEX schema_name
INNODB_BUFFER_POOL_PAGES_BLOB space_id
INNODB_LOCK_WAITS requesting_trx_id
INNODB_TRX trx_id
INNODB_CMP_RESET page_size
INNODB_CMP page_size
INNODB_LOCK_WAITS requesting_trx_id
INNODB_CMPMEM_RESET page_size
INNODB_LOCKS lock_id
INNODB_CMPMEM page_size
PBXT_STATISTICS ID
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
INNER JOIN
......@@ -141,19 +141,19 @@ TABLE_PRIVILEGES TABLE_SCHEMA
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
VIEWS TABLE_SCHEMA
INNODB_BUFFER_POOL_PAGES_INDEX schema_name
INNODB_RSEG rseg_id
INNODB_LOCKS lock_id
INNODB_BUFFER_POOL_PAGES page_type
PBXT_STATISTICS ID
INNODB_CMP page_size
INNODB_RSEG rseg_id
XTRADB_ENHANCEMENTS name
INNODB_TRX trx_id
INNODB_BUFFER_POOL_PAGES_INDEX schema_name
INNODB_BUFFER_POOL_PAGES_BLOB space_id
INNODB_LOCK_WAITS requesting_trx_id
INNODB_TRX trx_id
INNODB_CMP_RESET page_size
INNODB_CMP page_size
INNODB_LOCK_WAITS requesting_trx_id
INNODB_CMPMEM_RESET page_size
INNODB_LOCKS lock_id
INNODB_CMPMEM page_size
PBXT_STATISTICS ID
select 1 as f1 from information_schema.tables where "CHARACTER_SETS"=
(select cast(table_name as char) from information_schema.tables
order by table_name limit 1) limit 1;
......@@ -248,19 +248,19 @@ Database: information_schema
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_RSEG |
| INNODB_LOCKS |
| INNODB_BUFFER_POOL_PAGES |
| PBXT_STATISTICS |
| INNODB_CMP |
| INNODB_RSEG |
| XTRADB_ENHANCEMENTS |
| INNODB_TRX |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_BUFFER_POOL_PAGES_BLOB |
| INNODB_LOCK_WAITS |
| INNODB_TRX |
| INNODB_CMP_RESET |
| INNODB_CMP |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM_RESET |
| INNODB_LOCKS |
| INNODB_CMPMEM |
| PBXT_STATISTICS |
+---------------------------------------+
Database: INFORMATION_SCHEMA
+---------------------------------------+
......@@ -294,19 +294,19 @@ Database: INFORMATION_SCHEMA
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_RSEG |
| INNODB_LOCKS |
| INNODB_BUFFER_POOL_PAGES |
| PBXT_STATISTICS |
| INNODB_CMP |
| INNODB_RSEG |
| XTRADB_ENHANCEMENTS |
| INNODB_TRX |
| INNODB_BUFFER_POOL_PAGES_INDEX |
| INNODB_BUFFER_POOL_PAGES_BLOB |
| INNODB_LOCK_WAITS |
| INNODB_TRX |
| INNODB_CMP_RESET |
| INNODB_CMP |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM_RESET |
| INNODB_LOCKS |
| INNODB_CMPMEM |
| PBXT_STATISTICS |
+---------------------------------------+
Wildcard: inf_rmation_schema
+--------------------+
......
#
# We need big packets.
#
SET @old_global_max_allowed_packet=@@global.max_allowed_packet;
SET @@global.max_allowed_packet= 1024*1024*1024;
#
# Preparatory cleanup.
#
DROP TABLE IF EXISTS t1;
......@@ -7,10 +12,6 @@ DROP TABLE IF EXISTS t1;
#
SET timestamp=1000000000;
#
# We need big packets.
#
SET @@global.max_allowed_packet= 1024*1024*1024;
#
# Delete all existing binary logs.
#
RESET MASTER;
......@@ -71,4 +72,5 @@ FLUSH LOGS;
# Cleanup.
#
DROP TABLE t1;
SET @@global.max_allowed_packet=@old_global_max_allowed_packet;
remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out
set session transaction_prealloc_size=1024*1024*1024*1;
show processlist;
Id User Host db Command Time State Info
# root localhost test Query 0 NULL show processlist
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
TRUE
1
set session transaction_prealloc_size=1024*1024*1024*2;
show processlist;
Id User Host db Command Time State Info
# root localhost test Query 0 NULL show processlist
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
TRUE
1
set session transaction_prealloc_size=1024*1024*1024*3;
show processlist;
Id User Host db Command Time State Info
# root localhost test Query 0 NULL show processlist
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
TRUE
1
set session transaction_prealloc_size=1024*1024*1024*4;
show processlist;
Id User Host db Command Time State Info
# root localhost test Query 0 NULL show processlist
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
TRUE
1
set session transaction_prealloc_size=1024*1024*1024*5;
show processlist;
Id User Host db Command Time State Info
# root localhost test Query 0 NULL show processlist
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
TRUE
1
......@@ -23,6 +23,16 @@
# This is a big test.
--source include/big_test.inc
--echo #
--echo # We need big packets.
--echo #
connect (con1, localhost, root,,);
connection con1;
SET @old_global_max_allowed_packet=@@global.max_allowed_packet;
SET @@global.max_allowed_packet= 1024*1024*1024;
connect (con2, localhost, root,,);
connection con2;
--echo #
--echo # Preparatory cleanup.
--echo #
......@@ -35,11 +45,6 @@ DROP TABLE IF EXISTS t1;
--echo #
SET timestamp=1000000000;
--echo #
--echo # We need big packets.
--echo #
SET @@global.max_allowed_packet= 1024*1024*1024;
--echo #
--echo # Delete all existing binary logs.
--echo #
......@@ -122,9 +127,14 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--echo #
DROP TABLE t1;
connection con1;
SET @@global.max_allowed_packet=@old_global_max_allowed_packet;
--echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output
#
# NOTE: If you want to see the *huge* mysqlbinlog output, disable next line:
#
--remove_file $MYSQLTEST_VARDIR/$mysqlbinlog_output
disconnect con1
disconnect con2
......@@ -8,19 +8,20 @@
# Bug #27322 failure to allocate transaction_prealloc_size causes crash
#
set @pid_temp = (select ID from information_schema.processlist);
set session transaction_prealloc_size=1024*1024*1024*1;
--replace_column 1 #
show processlist;
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
set session transaction_prealloc_size=1024*1024*1024*2;
--replace_column 1 #
show processlist;
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
--replace_column 1 #
set session transaction_prealloc_size=1024*1024*1024*3;
--replace_column 1 #
show processlist;
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
set session transaction_prealloc_size=1024*1024*1024*4;
--replace_column 1 #
show processlist;
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
set session transaction_prealloc_size=1024*1024*1024*5;
--replace_column 1 #
show processlist;
select @pid_temp = (select ID from information_schema.processlist) as 'TRUE';
......@@ -464,3 +464,52 @@ process_flags:
err:
return (size_t) -1;
}
int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val)
{
uint length;
DBUG_ENTER("init_strvar_from_file");
if ((length=my_b_gets(f,var, max_size)))
{
char* last_p = var + length -1;
if (*last_p == '\n')
*last_p = 0; /* if we stopped on newline, kill it */
else
{
/*
If we truncated a line or stopped on last char, remove all chars
up to and including newline.
*/
int c;
while (((c=my_b_get(f)) != '\n' && c != my_b_EOF))
;
}
DBUG_RETURN(0);
}
else if (default_val)
{
strmake(var, default_val, max_size-1);
DBUG_RETURN(0);
}
DBUG_RETURN(1);
}
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
{
char buf[32];
DBUG_ENTER("init_intvar_from_file");
if (my_b_gets(f, buf, sizeof(buf)))
{
*var = atoi(buf);
DBUG_RETURN(0);
}
else if (default_val)
{
*var = default_val;
DBUG_RETURN(0);
}
DBUG_RETURN(1);
}
......@@ -9239,3 +9239,29 @@ st_print_event_info::st_print_event_info()
open_cached_file(&body_cache, NULL, NULL, 0, flags);
}
#endif
#if defined(MYSQL_SERVER)
/*
Access to the current replication position.
There is a dummy replacement for this in the embedded library that returns
FALSE; this is used by XtraDB to allow it to access replication stuff while
still being able to use the same plugin in both stand-alone and embedded.
*/
bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
const char **group_relay_log_name,
ulonglong *relay_log_pos)
{
#if defined(EMBEDDED_LIBRARY) || !defined(HAVE_REPLICATION)
return FALSE;
#else
const Relay_log_info *rli= &(active_mi->rli);
*log_file_name= rli->group_master_log_name;
*log_pos= rli->group_master_log_pos +
(rli->future_event_relay_log_pos - rli->group_relay_log_pos);
*group_relay_log_name= rli->group_relay_log_name;
*relay_log_pos= rli->future_event_relay_log_pos;
return TRUE;
#endif
}
#endif
......@@ -3915,6 +3915,10 @@ static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
}
bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
const char **group_relay_log_name,
ulonglong *relay_log_pos);
/**
@} (end of group Replication)
*/
......
......@@ -22,11 +22,6 @@
#ifdef HAVE_REPLICATION
// Defined in slave.cc
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val);
Master_info::Master_info()
:Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0), inited(0),
......
......@@ -23,11 +23,6 @@
static int count_relay_log_space(Relay_log_info* rli);
// Defined in slave.cc
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val);
Relay_log_info::Relay_log_info()
:Slave_reporting_capability("SQL"),
......
......@@ -755,57 +755,6 @@ const char *print_slave_db_safe(const char* db)
DBUG_RETURN((db ? db : ""));
}
int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
const char *default_val)
{
uint length;
DBUG_ENTER("init_strvar_from_file");
if ((length=my_b_gets(f,var, max_size)))
{
char* last_p = var + length -1;
if (*last_p == '\n')
*last_p = 0; // if we stopped on newline, kill it
else
{
/*
If we truncated a line or stopped on last char, remove all chars
up to and including newline.
*/
int c;
while (((c=my_b_get(f)) != '\n' && c != my_b_EOF))
;
}
DBUG_RETURN(0);
}
else if (default_val)
{
strmake(var, default_val, max_size-1);
DBUG_RETURN(0);
}
DBUG_RETURN(1);
}
int init_intvar_from_file(int* var, IO_CACHE* f, int default_val)
{
char buf[32];
DBUG_ENTER("init_intvar_from_file");
if (my_b_gets(f, buf, sizeof(buf)))
{
*var = atoi(buf);
DBUG_RETURN(0);
}
else if (default_val)
{
*var = default_val;
DBUG_RETURN(0);
}
DBUG_RETURN(1);
}
/*
Note that we rely on the master's version (3.23, 4.0.14 etc) instead of
relying on the binlog's version. This is not perfect: imagine an upgrade
......
......@@ -3733,8 +3733,7 @@ btr_blob_free(
mtr_commit(mtr);
//buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
buf_pool_mutex_enter();
mutex_enter(&block->mutex);
/* Only free the block if it is still allocated to
......@@ -3745,22 +3744,17 @@ btr_blob_free(
&& buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) {
if (buf_LRU_free_block(&block->page, all, NULL, TRUE)
if (buf_LRU_free_block(&block->page, all, NULL)
!= BUF_LRU_FREED
&& all && block->page.zip.data
/* Now, buf_LRU_free_block() may release mutex temporarily */
&& buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE
&& buf_block_get_space(block) == space
&& buf_block_get_page_no(block) == page_no) {
&& all && block->page.zip.data) {
/* Attempt to deallocate the uncompressed page
if the whole block cannot be deallocted. */
buf_LRU_free_block(&block->page, FALSE, NULL, TRUE);
buf_LRU_free_block(&block->page, FALSE, NULL);
}
}
//buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
buf_pool_mutex_exit();
mutex_exit(&block->mutex);
}
......
......@@ -1731,8 +1731,7 @@ btr_search_validate(void)
rec_offs_init(offsets_);
rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
buf_pool_mutex_enter();
cell_count = hash_get_n_cells(btr_search_sys->hash_index);
......@@ -1740,13 +1739,11 @@ btr_search_validate(void)
/* We release btr_search_latch every once in a while to
give other queries a chance to run. */
if ((i != 0) && ((i % chunk_size) == 0)) {
//buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
buf_pool_mutex_exit();
rw_lock_x_unlock(&btr_search_latch);
os_thread_yield();
rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
buf_pool_mutex_enter();
}
node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node;
......@@ -1853,13 +1850,11 @@ btr_search_validate(void)
/* We release btr_search_latch every once in a while to
give other queries a chance to run. */
if (i != 0) {
//buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
buf_pool_mutex_exit();
rw_lock_x_unlock(&btr_search_latch);
os_thread_yield();
rw_lock_x_lock(&btr_search_latch);
//buf_pool_mutex_enter();
rw_lock_x_lock(&page_hash_latch);
buf_pool_mutex_enter();
}
if (!ha_validate(btr_search_sys->hash_index, i, end_index)) {
......@@ -1867,8 +1862,7 @@ btr_search_validate(void)
}
}
//buf_pool_mutex_exit();
rw_lock_x_unlock(&page_hash_latch);
buf_pool_mutex_exit();
rw_lock_x_unlock(&btr_search_latch);
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);
......
......@@ -131,8 +131,7 @@ buf_buddy_alloc_zip(
{
buf_page_t* bpage;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_ad(buf_pool_mutex_own());
ut_a(i < BUF_BUDDY_SIZES);
#if defined UNIV_DEBUG && !defined UNIV_DEBUG_VALGRIND
......@@ -178,19 +177,16 @@ static
void
buf_buddy_block_free(
/*=================*/
void* buf, /* in: buffer frame to deallocate */
ibool have_page_hash_mutex)
void* buf) /* in: buffer frame to deallocate */
{
const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf);
buf_page_t* bpage;
buf_block_t* block;
//ut_ad(buf_pool_mutex_own());
ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex));
ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE));
mutex_enter(&zip_hash_mutex);
HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage,
ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY
&& bpage->in_zip_hash && !bpage->in_page_hash),
......@@ -202,14 +198,12 @@ buf_buddy_block_free(
ut_d(bpage->in_zip_hash = FALSE);
HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage);
mutex_exit(&zip_hash_mutex);
ut_d(memset(buf, 0, UNIV_PAGE_SIZE));
UNIV_MEM_INVALID(buf, UNIV_PAGE_SIZE);
block = (buf_block_t*) bpage;
mutex_enter(&block->mutex);
buf_LRU_block_free_non_file_page(block, have_page_hash_mutex);
buf_LRU_block_free_non_file_page(block);
mutex_exit(&block->mutex);
ut_ad(buf_buddy_n_frames > 0);
......@@ -225,7 +219,7 @@ buf_buddy_block_register(
buf_block_t* block) /* in: buffer frame to allocate */
{
const ulint fold = BUF_POOL_ZIP_FOLD(block);
//ut_ad(buf_pool_mutex_own());
ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex));
buf_block_set_state(block, BUF_BLOCK_MEMORY);
......@@ -236,10 +230,7 @@ buf_buddy_block_register(
ut_ad(!block->page.in_page_hash);
ut_ad(!block->page.in_zip_hash);
ut_d(block->page.in_zip_hash = TRUE);
mutex_enter(&zip_hash_mutex);
HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page);
mutex_exit(&zip_hash_mutex);
ut_d(buf_buddy_n_frames++);
}
......@@ -293,28 +284,24 @@ buf_buddy_alloc_low(
possibly NULL if lru==NULL */
ulint i, /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */
ibool* lru, /* in: pointer to a variable that will be assigned
ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
{
buf_block_t* block;
//ut_ad(buf_pool_mutex_own());
ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex));
if (i < BUF_BUDDY_SIZES) {
/* Try to allocate from the buddy system. */
mutex_enter(&zip_free_mutex);
block = buf_buddy_alloc_zip(i);
if (block) {
goto func_exit;
}
mutex_exit(&zip_free_mutex);
}
/* Try allocating from the buf_pool->free list. */
......@@ -331,31 +318,18 @@ buf_buddy_alloc_low(
}
/* Try replacing an uncompressed page in the buffer pool. */
//buf_pool_mutex_exit();
mutex_exit(&LRU_list_mutex);
if (have_page_hash_mutex) {
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
buf_pool_mutex_exit();
block = buf_LRU_get_free_block(0);
*lru = TRUE;
//buf_pool_mutex_enter();
mutex_enter(&LRU_list_mutex);
if (have_page_hash_mutex) {
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
buf_pool_mutex_enter();
alloc_big:
buf_buddy_block_register(block);
mutex_enter(&zip_free_mutex);
block = buf_buddy_alloc_from(block->frame, i, BUF_BUDDY_SIZES);
func_exit:
buf_buddy_stat[i].used++;
mutex_exit(&zip_free_mutex);
return(block);
}
......@@ -371,8 +345,7 @@ buf_buddy_relocate_block(
{
buf_page_t* b;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_pool_mutex_own());
switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_FREE:
......@@ -381,7 +354,7 @@ buf_buddy_relocate_block(
case BUF_BLOCK_FILE_PAGE:
case BUF_BLOCK_MEMORY:
case BUF_BLOCK_REMOVE_HASH:
/* ut_error; */ /* optimistic */
ut_error;
case BUF_BLOCK_ZIP_DIRTY:
/* Cannot relocate dirty pages. */
return(FALSE);
......@@ -391,17 +364,9 @@ buf_buddy_relocate_block(
}
mutex_enter(&buf_pool_zip_mutex);
mutex_enter(&zip_free_mutex);
if (!buf_page_can_relocate(bpage)) {
mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(FALSE);
}
if (bpage != buf_page_hash_get(bpage->space, bpage->offset)) {
mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(FALSE);
}
......@@ -419,7 +384,6 @@ buf_buddy_relocate_block(
}
mutex_exit(&buf_pool_zip_mutex);
mutex_exit(&zip_free_mutex);
return(TRUE);
}
......@@ -432,15 +396,13 @@ buf_buddy_relocate(
/* out: TRUE if relocated */
void* src, /* in: block to relocate */
void* dst, /* in: free block to relocate to */
ulint i, /* in: index of buf_pool->zip_free[] */
ibool have_page_hash_mutex)
ulint i) /* in: index of buf_pool->zip_free[] */
{
buf_page_t* bpage;
const ulint size = BUF_BUDDY_LOW << i;
ullint usec = ut_time_us(NULL);
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex));
ut_ad(!ut_align_offset(src, size));
ut_ad(!ut_align_offset(dst, size));
......@@ -459,17 +421,9 @@ buf_buddy_relocate(
actually is a properly initialized buf_page_t object. */
if (size >= PAGE_ZIP_MIN_SIZE) {
if (!have_page_hash_mutex)
mutex_exit(&zip_free_mutex);
/* This is a compressed page. */
mutex_t* mutex;
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
/* The src block may be split into smaller blocks,
some of which may be free. Thus, the
mach_read_from_4() calls below may attempt to read
......@@ -490,12 +444,6 @@ buf_buddy_relocate(
added to buf_pool->page_hash yet. Obviously,
it cannot be relocated. */
if (!have_page_hash_mutex) {
mutex_enter(&zip_free_mutex);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(FALSE);
}
......@@ -505,19 +453,9 @@ buf_buddy_relocate(
For the sake of simplicity, give up. */
ut_ad(page_zip_get_size(&bpage->zip) < size);
if (!have_page_hash_mutex) {
mutex_enter(&zip_free_mutex);
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(FALSE);
}
/* To keep latch order */
if (have_page_hash_mutex)
mutex_exit(&zip_free_mutex);
/* The block must have been allocated, but it may
contain uninitialized data. */
UNIV_MEM_ASSERT_W(src, size);
......@@ -525,7 +463,6 @@ buf_buddy_relocate(
mutex = buf_page_get_mutex(bpage);
mutex_enter(mutex);
mutex_enter(&zip_free_mutex);
if (buf_page_can_relocate(bpage)) {
/* Relocate the compressed page. */
......@@ -542,53 +479,17 @@ success:
buddy_stat->relocated_usec
+= ut_time_us(NULL) - usec;
}
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
return(TRUE);
}
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
mutex_exit(mutex);
} else if (i == buf_buddy_get_slot(sizeof(buf_page_t))) {
/* This must be a buf_page_t object. */
UNIV_MEM_ASSERT_RW(src, size);
mutex_exit(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
if (buf_buddy_relocate_block(src, dst)) {
mutex_enter(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
goto success;
}
mutex_enter(&zip_free_mutex);
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
}
return(FALSE);
......@@ -602,14 +503,12 @@ buf_buddy_free_low(
/*===============*/
void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */
ulint i, /* in: index of buf_pool->zip_free[] */
ibool have_page_hash_mutex)
ulint i) /* in: index of buf_pool->zip_free[] */
{
buf_page_t* bpage;
buf_page_t* buddy;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&zip_free_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(!mutex_own(&buf_pool_zip_mutex));
ut_ad(i <= BUF_BUDDY_SIZES);
ut_ad(buf_buddy_stat[i].used > 0);
......@@ -620,7 +519,7 @@ recombine:
ut_d(((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE);
if (i == BUF_BUDDY_SIZES) {
buf_buddy_block_free(buf, have_page_hash_mutex);
buf_buddy_block_free(buf);
return;
}
......@@ -678,7 +577,7 @@ buddy_nonfree:
#endif /* UNIV_DEBUG_VALGRIND */
/* The buddy is not free. Is there a free block of this size? */
bpage = UT_LIST_GET_LAST(buf_pool->zip_free[i]);
bpage = UT_LIST_GET_FIRST(buf_pool->zip_free[i]);
if (bpage) {
/* Remove the block from the free list, because a successful
......@@ -688,7 +587,7 @@ buddy_nonfree:
buf_buddy_remove_from_free(bpage, i);
/* Try to relocate the buddy of buf to the free block. */
if (buf_buddy_relocate(buddy, bpage, i, have_page_hash_mutex)) {
if (buf_buddy_relocate(buddy, bpage, i)) {
ut_d(buddy->state = BUF_BLOCK_ZIP_FREE);
goto buddy_free2;
......@@ -716,7 +615,7 @@ buddy_nonfree:
}
#endif /* UNIV_DEBUG && !UNIV_DEBUG_VALGRIND */
if (buf_buddy_relocate(buddy, buf, i, have_page_hash_mutex)) {
if (buf_buddy_relocate(buddy, buf, i)) {
buf = bpage;
UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i);
......
This diff is collapsed.
......@@ -61,8 +61,7 @@ buf_flush_insert_into_flush_list(
/*=============================*/
buf_block_t* block) /* in/out: block which is modified */
{
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL)
|| (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification
<= block->page.oldest_modification));
......@@ -93,8 +92,7 @@ buf_flush_insert_sorted_into_flush_list(
buf_page_t* prev_b;
buf_page_t* b;
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
ut_ad(block->page.in_LRU_list);
......@@ -137,7 +135,7 @@ buf_flush_ready_for_replace(
{
//ut_ad(buf_pool_mutex_own());
//ut_ad(mutex_own(buf_page_get_mutex(bpage)));
//ut_ad(bpage->in_LRU_list);
//ut_ad(bpage->in_LRU_list); /* optimistic use */
if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) {
......@@ -172,7 +170,7 @@ buf_flush_ready_for_flush(
enum buf_flush flush_type)/* in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */
{
ut_a(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own()); /*optimistic...*/
ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST);
......@@ -205,8 +203,7 @@ buf_flush_remove(
/*=============*/
buf_page_t* bpage) /* in: pointer to the block in question */
{
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(bpage->in_flush_list);
ut_d(bpage->in_flush_list = FALSE);
......@@ -765,19 +762,12 @@ buf_flush_page(
ibool is_uncompressed;
ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST);
//ut_ad(buf_pool_mutex_own());
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)
|| rw_lock_own(&page_hash_latch, RW_LOCK_SHARED));
#endif
ut_ad(buf_pool_mutex_own());
ut_ad(buf_page_in_file(bpage));
block_mutex = buf_page_get_mutex(bpage);
ut_ad(mutex_own(block_mutex));
mutex_enter(&buf_pool_mutex);
rw_lock_s_unlock(&page_hash_latch);
ut_ad(buf_flush_ready_for_flush(bpage, flush_type));
buf_page_set_io_fix(bpage, BUF_IO_WRITE);
......@@ -808,8 +798,7 @@ buf_flush_page(
}
mutex_exit(block_mutex);
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
/* Even though bpage is not protected by any mutex at
this point, it is safe to access bpage, because it is
......@@ -846,8 +835,7 @@ buf_flush_page(
immediately. */
mutex_exit(block_mutex);
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
break;
default:
......@@ -911,8 +899,7 @@ buf_flush_try_neighbors(
high = fil_space_get_size(space);
}
//buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
buf_pool_mutex_enter();
for (i = low; i < high; i++) {
......@@ -949,16 +936,14 @@ buf_flush_try_neighbors(
ut_ad(!mutex_own(block_mutex));
count++;
//buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
buf_pool_mutex_enter();
} else {
mutex_exit(block_mutex);
}
}
}
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
return(count);
}
......@@ -1002,29 +987,20 @@ buf_flush_batch(
ut_ad((flush_type != BUF_FLUSH_LIST)
|| sync_thread_levels_empty_gen(TRUE));
#endif /* UNIV_SYNC_DEBUG */
//buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
buf_pool_mutex_enter();
if ((buf_pool->n_flush[flush_type] > 0)
|| (buf_pool->init_flush[flush_type] == TRUE)) {
/* There is already a flush batch of the same type running */
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
return(ULINT_UNDEFINED);
}
buf_pool->init_flush[flush_type] = TRUE;
mutex_exit(&buf_pool_mutex);
if (flush_type == BUF_FLUSH_LRU) {
mutex_enter(&LRU_list_mutex);
}
mutex_enter(&flush_list_mutex);
for (;;) {
flush_next:
/* If we have flushed enough, leave the loop */
......@@ -1071,11 +1047,7 @@ flush_next:
space = buf_page_get_space(bpage);
offset = buf_page_get_page_no(bpage);
//buf_pool_mutex_exit();
if (flush_type == BUF_FLUSH_LRU) {
mutex_exit(&LRU_list_mutex);
}
mutex_exit(&flush_list_mutex);
buf_pool_mutex_exit();
old_page_count = page_count;
......@@ -1085,8 +1057,7 @@ flush_next:
space, offset, flush_type);
} else {
/* Try to flush the page only */
//buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
buf_pool_mutex_enter();
mutex_t* block_mutex = buf_page_get_mutex(bpage);
mutex_enter(block_mutex);
......@@ -1102,11 +1073,7 @@ flush_next:
flush_type, offset,
page_count - old_page_count); */
//buf_pool_mutex_enter();
if (flush_type == BUF_FLUSH_LRU) {
mutex_enter(&LRU_list_mutex);
}
mutex_enter(&flush_list_mutex);
buf_pool_mutex_enter();
goto flush_next;
} else if (flush_type == BUF_FLUSH_LRU) {
......@@ -1124,13 +1091,6 @@ flush_next:
break;
}
if (flush_type == BUF_FLUSH_LRU) {
mutex_exit(&LRU_list_mutex);
}
mutex_exit(&flush_list_mutex);
mutex_enter(&buf_pool_mutex);
buf_pool->init_flush[flush_type] = FALSE;
if (buf_pool->n_flush[flush_type] == 0) {
......@@ -1140,8 +1100,7 @@ flush_next:
os_event_set(buf_pool->no_flush[flush_type]);
}
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
buf_flush_buffered_writes();
......@@ -1195,7 +1154,7 @@ buf_flush_LRU_recommendation(void)
//buf_pool_mutex_enter();
if (have_LRU_mutex)
mutex_enter(&LRU_list_mutex);
buf_pool_mutex_enter();
n_replaceable = UT_LIST_GET_LEN(buf_pool->free);
......@@ -1229,7 +1188,7 @@ buf_flush_LRU_recommendation(void)
//buf_pool_mutex_exit();
if (have_LRU_mutex)
mutex_exit(&LRU_list_mutex);
buf_pool_mutex_exit();
if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) {
......@@ -1307,13 +1266,11 @@ buf_flush_validate(void)
{
ibool ret;
//buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
buf_pool_mutex_enter();
ret = buf_flush_validate_low();
//buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
buf_pool_mutex_exit();
return(ret);
}
......
This diff is collapsed.
......@@ -246,22 +246,18 @@ buf_read_ahead_random(
LRU_recent_limit = buf_LRU_get_recent_limit();
//buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
buf_pool_mutex_enter();
if (buf_pool->n_pend_reads
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
return(0);
}
mutex_exit(&buf_pool_mutex);
/* Count how many blocks in the area have been recently accessed,
that is, reside near the start of the LRU list. */
rw_lock_s_lock(&page_hash_latch);
for (i = low; i < high; i++) {
const buf_page_t* bpage = buf_page_hash_get(space, i);
......@@ -273,15 +269,13 @@ buf_read_ahead_random(
if (recent_blocks >= BUF_READ_AHEAD_RANDOM_THRESHOLD) {
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
goto read_ahead;
}
}
}
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
/* Do nothing */
return(0);
......@@ -475,12 +469,10 @@ buf_read_ahead_linear(
tablespace_version = fil_space_get_version(space);
//buf_pool_mutex_enter();
mutex_enter(&buf_pool_mutex);
buf_pool_mutex_enter();
if (high > fil_space_get_size(space)) {
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
/* The area is not whole, return */
return(0);
......@@ -488,12 +480,10 @@ buf_read_ahead_linear(
if (buf_pool->n_pend_reads
> buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) {
//buf_pool_mutex_exit();
mutex_exit(&buf_pool_mutex);
buf_pool_mutex_exit();
return(0);
}
mutex_exit(&buf_pool_mutex);
/* Check that almost all pages in the area have been accessed; if
offset == low, the accesses must be in a descending order, otherwise,
......@@ -507,7 +497,6 @@ buf_read_ahead_linear(
fail_count = 0;
rw_lock_s_lock(&page_hash_latch);
for (i = low; i < high; i++) {
bpage = buf_page_hash_get(space, i);
......@@ -531,8 +520,7 @@ buf_read_ahead_linear(
* LINEAR_AREA_THRESHOLD_COEF) {
/* Too many failures: return */
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
return(0);
}
......@@ -543,8 +531,7 @@ buf_read_ahead_linear(
bpage = buf_page_hash_get(space, offset);
if (bpage == NULL) {
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
return(0);
}
......@@ -570,8 +557,7 @@ buf_read_ahead_linear(
pred_offset = fil_page_get_prev(frame);
succ_offset = fil_page_get_next(frame);
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
if ((offset == low) && (succ_offset == offset + 1)) {
......
......@@ -35,7 +35,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#pragma implementation // gcc: Class implementation
#endif
#define MYSQL_SERVER
#include <mysql_priv.h>
#ifdef MYSQL_SERVER
#include <log_event.h>
#endif /* MYSQL_SERVER */
#include <m_ctype.h>
#include <mysys_err.h>
......@@ -78,6 +83,14 @@ extern "C" {
#include "i_s.h"
#include "handler0vars.h"
#ifdef MYSQL_SERVER
// Defined in trx0sys.c
extern char trx_sys_mysql_master_log_name[];
extern ib_int64_t trx_sys_mysql_master_log_pos;
extern char trx_sys_mysql_relay_log_name[];
extern ib_int64_t trx_sys_mysql_relay_log_pos;
#endif /* MYSQL_SERVER */
#ifndef MYSQL_SERVER
/* This is needed because of Bug #3596. Let us hope that pthread_mutex_t
is defined the same in both builds: the MySQL server and the InnoDB plugin. */
......@@ -176,6 +189,7 @@ static my_bool innobase_use_doublewrite = TRUE;
static my_bool innobase_use_checksums = TRUE;
static my_bool innobase_extra_undoslots = FALSE;
static my_bool innobase_locks_unsafe_for_binlog = FALSE;
static my_bool innobase_overwrite_relay_log_info = FALSE;
static my_bool innobase_rollback_on_timeout = FALSE;
static my_bool innobase_create_status_file = FALSE;
static my_bool innobase_stats_on_metadata = TRUE;
......@@ -1920,6 +1934,89 @@ innobase_init(
}
#endif /* UNIV_DEBUG */
#ifndef MYSQL_SERVER
innodb_overwrite_relay_log_info = FALSE;
#endif
#ifdef HAVE_REPLICATION
#ifdef MYSQL_SERVER
/* read master log position from relay-log.info if exists */
char fname[FN_REFLEN+128];
int pos;
int info_fd;
IO_CACHE info_file;
fname[0] = '\0';
if(innobase_overwrite_relay_log_info) {
fprintf(stderr,
"InnoDB: Warning: innodb_overwrite_relay_log_info is enabled."
" Updates in other storage engines may have problem with consistency.\n");
bzero((char*) &info_file, sizeof(info_file));
fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32);
int error=0;
if (!access(fname,F_OK)) {
/* exist */
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) {
error=1;
} else if (init_io_cache(&info_file, info_fd, IO_SIZE*2,
READ_CACHE, 0L, 0, MYF(MY_WME))) {
error=1;
}
if (error) {
relay_info_error:
if (info_fd >= 0)
my_close(info_fd, MYF(0));
fname[0] = '\0';
goto skip_relay;
}
} else {
fname[0] = '\0';
goto skip_relay;
}
if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") || /* dummy (it is relay-log) */
init_intvar_from_file(&pos, &info_file, BIN_LOG_HEADER_SIZE)) {
end_io_cache(&info_file);
error=1;
goto relay_info_error;
}
fprintf(stderr,
"InnoDB: relay-log.info is detected.\n"
"InnoDB: relay log: position %u, file name %s\n",
pos, fname);
strncpy(trx_sys_mysql_relay_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
trx_sys_mysql_relay_log_pos = (ib_int64_t) pos;
if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") ||
init_intvar_from_file(&pos, &info_file, 0)) {
end_io_cache(&info_file);
error=1;
goto relay_info_error;
}
fprintf(stderr,
"InnoDB: master log: position %u, file name %s\n",
pos, fname);
strncpy(trx_sys_mysql_master_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
trx_sys_mysql_master_log_pos = (ib_int64_t) pos;
end_io_cache(&info_file);
if (info_fd >= 0)
my_close(info_fd, MYF(0));
}
skip_relay:
#endif /* MYSQL_SERVER */
#endif /* HAVE_REPLICATION */
/* Check that values don't overflow on 32-bit systems. */
if (sizeof(ulint) == 4) {
if (innobase_buffer_pool_size > UINT_MAX32) {
......@@ -2003,6 +2100,77 @@ mem_free_and_error:
goto error;
}
#ifdef HAVE_REPLICATION
#ifdef MYSQL_SERVER
if(innobase_overwrite_relay_log_info) {
/* If InnoDB progressed from relay-log.info, overwrite it */
if (fname[0] == '\0') {
fprintf(stderr,
"InnoDB: something wrong with relay-info.log. InnoDB will not overwrite it.\n");
} else if (0 != strcmp(fname, trx_sys_mysql_master_log_name)
|| pos != trx_sys_mysql_master_log_pos) {
/* Overwrite relay-log.info */
bzero((char*) &info_file, sizeof(info_file));
fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32);
int error = 0;
if (!access(fname,F_OK)) {
/* exist */
if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) {
error = 1;
} else if (init_io_cache(&info_file, info_fd, IO_SIZE*2,
WRITE_CACHE, 0L, 0, MYF(MY_WME))) {
error = 1;
}
if (error) {
if (info_fd >= 0)
my_close(info_fd, MYF(0));
goto skip_overwrite;
}
} else {
error = 1;
goto skip_overwrite;
}
char buff[FN_REFLEN*2+22*2+4], *pos;
my_b_seek(&info_file, 0L);
pos=strmov(buff, trx_sys_mysql_relay_log_name);
*pos++='\n';
pos=longlong2str(trx_sys_mysql_relay_log_pos, pos, 10);
*pos++='\n';
pos=strmov(pos, trx_sys_mysql_master_log_name);
*pos++='\n';
pos=longlong2str(trx_sys_mysql_master_log_pos, pos, 10);
*pos='\n';
if (my_b_write(&info_file, (uchar*) buff, (size_t) (pos-buff)+1))
error = 1;
if (flush_io_cache(&info_file))
error = 1;
end_io_cache(&info_file);
if (info_fd >= 0)
my_close(info_fd, MYF(0));
skip_overwrite:
if (error) {
fprintf(stderr,
"InnoDB: ERROR: error occured during overwriting relay-log.info.\n");
} else {
fprintf(stderr,
"InnoDB: relay-log.info was overwritten.\n");
}
} else {
fprintf(stderr,
"InnoDB: InnoDB and relay-log.info are synchronized. InnoDB will not overwrite it.\n");
}
}
#endif /* MYSQL_SERVER */
#endif /* HAVE_REPLICATION */
srv_extra_undoslots = (ibool) innobase_extra_undoslots;
/* -------------- Log files ---------------------------*/
......@@ -2270,6 +2438,28 @@ innobase_commit_low(
return;
}
#ifdef HAVE_REPLICATION
#ifdef MYSQL_SERVER
THD *thd=current_thd;
if (thd && thd->slave_thread) {
/* Update the replication position info inside InnoDB.
In embedded server, does nothing. */
const char *log_file_name, *group_relay_log_name;
ulonglong log_pos, relay_log_pos;
bool res = rpl_get_position_info(&log_file_name, &log_pos,
&group_relay_log_name,
&relay_log_pos);
if (res) {
trx->mysql_master_log_file_name = log_file_name;
trx->mysql_master_log_pos = (ib_int64_t)log_pos;
trx->mysql_relay_log_file_name = group_relay_log_name;
trx->mysql_relay_log_pos = (ib_int64_t)relay_log_pos;
}
}
#endif /* MYSQL_SERVER */
#endif /* HAVE_REPLICATION */
trx_commit_for_mysql(trx);
}
......@@ -9509,6 +9699,12 @@ static MYSQL_SYSVAR_BOOL(extra_undoslots, innobase_extra_undoslots,
"don't use the datafile for normal mysqld or ibbackup! ####",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(overwrite_relay_log_info, innobase_overwrite_relay_log_info,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"During InnoDB crash recovery on slave overwrite relay-log.info "
"to align master log file position if information in InnoDB and relay-log.info is different.",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Enable InnoDB doublewrite buffer (enabled by default). "
......@@ -9851,6 +10047,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(max_purge_lag),
MYSQL_SYSVAR(mirrored_log_groups),
MYSQL_SYSVAR(open_files),
MYSQL_SYSVAR(overwrite_relay_log_info),
MYSQL_SYSVAR(rollback_on_timeout),
MYSQL_SYSVAR(stats_on_metadata),
MYSQL_SYSVAR(stats_sample_pages),
......
......@@ -2282,8 +2282,7 @@ i_s_cmpmem_fill_low(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name);
//buf_pool_mutex_enter();
mutex_enter(&zip_free_mutex);
buf_pool_mutex_enter();
for (uint x = 0; x <= BUF_BUDDY_SIZES; x++) {
buf_buddy_stat_t* buddy_stat = &buf_buddy_stat[x];
......@@ -2309,8 +2308,7 @@ i_s_cmpmem_fill_low(
}
}
//buf_pool_mutex_exit();
mutex_exit(&zip_free_mutex);
buf_pool_mutex_exit();
DBUG_RETURN(status);
}
......
......@@ -26,11 +26,10 @@ struct innodb_enhancement {
{"xtradb_show_enhancements","I_S.XTRADB_ENHANCEMENTS","","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_show_status","Improvements to SHOW INNODB STATUS","Memory information and lock info fixes","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_rw_lock","InnoDB RW-lock fixes","Useful for 8+ cores SMP systems","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_split_buf_pool_mutex","More fix of buffer_pool mutex","Spliting buf_pool_mutex and optimizing based on innodb_opt_lru_count","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"},
{"innodb_overwrite_relay_log_info","overwrite relay-log.info when slave recovery","Building as plugin, it is not used.","http://www.percona.com/docs/wiki/percona-xtradb:innodb_overwrite_relay_log_info"},
{NULL, NULL, NULL, NULL}
};
......@@ -49,11 +49,10 @@ buf_buddy_alloc(
/* out: allocated block,
possibly NULL if lru == NULL */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool* lru, /* in: pointer to a variable that will be assigned
ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
__attribute__((malloc));
/**************************************************************************
......@@ -64,8 +63,7 @@ buf_buddy_free(
/*===========*/
void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool have_page_hash_mutex)
ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
__attribute__((nonnull));
/** Statistics of buddy blocks of a given size. */
......
......@@ -44,11 +44,10 @@ buf_buddy_alloc_low(
possibly NULL if lru==NULL */
ulint i, /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */
ibool* lru, /* in: pointer to a variable that will be assigned
ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
__attribute__((malloc));
/**************************************************************************
......@@ -59,9 +58,8 @@ buf_buddy_free_low(
/*===============*/
void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */
ulint i, /* in: index of buf_pool->zip_free[],
ulint i) /* in: index of buf_pool->zip_free[],
or BUF_BUDDY_SIZES */
ibool have_page_hash_mutex)
__attribute__((nonnull));
/**************************************************************************
......@@ -100,15 +98,14 @@ buf_buddy_alloc(
/* out: allocated block,
possibly NULL if lru == NULL */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool* lru, /* in: pointer to a variable that will be assigned
ibool* lru) /* in: pointer to a variable that will be assigned
TRUE if storage was allocated from the LRU list
and buf_pool_mutex was temporarily released,
or NULL if the LRU list should not be used */
ibool have_page_hash_mutex)
{
//ut_ad(buf_pool_mutex_own());
ut_ad(buf_pool_mutex_own());
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru, have_page_hash_mutex));
return(buf_buddy_alloc_low(buf_buddy_get_slot(size), lru));
}
/**************************************************************************
......@@ -119,26 +116,11 @@ buf_buddy_free(
/*===========*/
void* buf, /* in: block to be freed, must not be
pointed to by the buffer pool */
ulint size, /* in: block size, up to UNIV_PAGE_SIZE */
ibool have_page_hash_mutex)
ulint size) /* in: block size, up to UNIV_PAGE_SIZE */
{
//ut_ad(buf_pool_mutex_own());
if (!have_page_hash_mutex) {
mutex_enter(&LRU_list_mutex);
mutex_enter(&flush_list_mutex);
rw_lock_x_lock(&page_hash_latch);
}
mutex_enter(&zip_free_mutex);
buf_buddy_free_low(buf, buf_buddy_get_slot(size), TRUE);
mutex_exit(&zip_free_mutex);
ut_ad(buf_pool_mutex_own());
if (!have_page_hash_mutex) {
mutex_exit(&LRU_list_mutex);
mutex_exit(&flush_list_mutex);
rw_lock_x_unlock(&page_hash_latch);
}
buf_buddy_free_low(buf, buf_buddy_get_slot(size));
}
#ifdef UNIV_MATERIALIZE
......
......@@ -1104,11 +1104,11 @@ struct buf_block_struct{
a block is in the unzip_LRU list
if page.state == BUF_BLOCK_FILE_PAGE
and page.zip.data != NULL */
//#ifdef UNIV_DEBUG
#ifdef UNIV_DEBUG
ibool in_unzip_LRU_list;/* TRUE if the page is in the
decompressed LRU list;
used in debugging */
//#endif /* UNIV_DEBUG */
#endif /* UNIV_DEBUG */
byte* frame; /* pointer to buffer frame which
is of size UNIV_PAGE_SIZE, and
aligned to an address divisible by
......@@ -1316,12 +1316,6 @@ struct buf_pool_struct{
/* mutex protecting the buffer pool struct and control blocks, except the
read-write lock in them */
extern mutex_t buf_pool_mutex;
extern mutex_t LRU_list_mutex;
extern mutex_t flush_list_mutex;
extern rw_lock_t page_hash_latch;
extern mutex_t free_list_mutex;
extern mutex_t zip_free_mutex;
extern mutex_t zip_hash_mutex;
/* mutex protecting the control blocks of compressed-only pages
(of type buf_page_t, not buf_block_t) */
extern mutex_t buf_pool_zip_mutex;
......
......@@ -100,8 +100,7 @@ buf_pool_get_oldest_modification(void)
buf_page_t* bpage;
ib_uint64_t lsn;
//buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
buf_pool_mutex_enter();
bpage = UT_LIST_GET_LAST(buf_pool->flush_list);
......@@ -112,8 +111,7 @@ buf_pool_get_oldest_modification(void)
lsn = bpage->oldest_modification;
}
//buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
buf_pool_mutex_exit();
/* The returned answer may be out of date: the flush_list can
change after the mutex has been released. */
......@@ -130,8 +128,7 @@ buf_pool_clock_tic(void)
/*====================*/
/* out: new clock value */
{
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_ad(buf_pool_mutex_own());
buf_pool->ulint_clock++;
......@@ -249,7 +246,7 @@ buf_page_in_file(
case BUF_BLOCK_ZIP_FREE:
/* This is a free page in buf_pool->zip_free[].
Such pages should only be accessed by the buddy allocator. */
/* ut_error; */ /* optimistic */
ut_error;
break;
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY:
......@@ -308,7 +305,7 @@ buf_page_get_mutex(
{
switch (buf_page_get_state(bpage)) {
case BUF_BLOCK_ZIP_FREE:
/* ut_error; */ /* optimistic */
ut_error;
return(NULL);
case BUF_BLOCK_ZIP_PAGE:
case BUF_BLOCK_ZIP_DIRTY:
......@@ -413,7 +410,7 @@ buf_page_set_io_fix(
buf_page_t* bpage, /* in/out: control block */
enum buf_io_fix io_fix) /* in: io_fix state */
{
//ut_ad(buf_pool_mutex_own());
ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
bpage->io_fix = io_fix;
......@@ -441,13 +438,12 @@ buf_page_can_relocate(
/*==================*/
const buf_page_t* bpage) /* control block being relocated */
{
//ut_ad(buf_pool_mutex_own());
/* optimistic */
//ut_ad(mutex_own(buf_page_get_mutex(bpage)));
//ut_ad(buf_page_in_file(bpage));
//ut_ad(bpage->in_LRU_list);
ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(buf_page_get_mutex(bpage)));
ut_ad(buf_page_in_file(bpage));
ut_ad(bpage->in_LRU_list);
return(bpage->in_LRU_list && bpage->io_fix == BUF_IO_NONE
return(buf_page_get_io_fix(bpage) == BUF_IO_NONE
&& bpage->buf_fix_count == 0);
}
......@@ -476,8 +472,7 @@ buf_page_set_old(
ibool old) /* in: old */
{
ut_a(buf_page_in_file(bpage));
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&LRU_list_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(bpage->in_LRU_list);
#ifdef UNIV_LRU_DEBUG
......@@ -733,17 +728,17 @@ buf_block_free(
/*===========*/
buf_block_t* block) /* in, own: block to be freed */
{
//buf_pool_mutex_enter();
buf_pool_mutex_enter();
mutex_enter(&block->mutex);
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
buf_LRU_block_free_non_file_page(block, FALSE);
buf_LRU_block_free_non_file_page(block);
mutex_exit(&block->mutex);
//buf_pool_mutex_exit();
buf_pool_mutex_exit();
}
/*************************************************************************
......@@ -788,17 +783,14 @@ buf_page_io_query(
buf_page_t* bpage) /* in: buf_pool block, must be bufferfixed */
{
ibool io_fixed;
mutex_t* block_mutex = buf_page_get_mutex(bpage);
//buf_pool_mutex_enter();
mutex_enter(block_mutex);
buf_pool_mutex_enter();
ut_ad(buf_page_in_file(bpage));
ut_ad(bpage->buf_fix_count > 0);
io_fixed = buf_page_get_io_fix(bpage) != BUF_IO_NONE;
//buf_pool_mutex_exit();
mutex_exit(block_mutex);
buf_pool_mutex_exit();
return(io_fixed);
}
......@@ -925,11 +917,7 @@ buf_page_hash_get(
ulint fold;
ut_ad(buf_pool);
//ut_ad(buf_pool_mutex_own());
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)
|| rw_lock_own(&page_hash_latch, RW_LOCK_SHARED));
#endif
ut_ad(buf_pool_mutex_own());
/* Look for the page in the hash table */
......@@ -978,13 +966,11 @@ buf_page_peek(
{
const buf_page_t* bpage;
//buf_pool_mutex_enter();
rw_lock_s_lock(&page_hash_latch);
buf_pool_mutex_enter();
bpage = buf_page_hash_get(space, offset);
//buf_pool_mutex_exit();
rw_lock_s_unlock(&page_hash_latch);
buf_pool_mutex_exit();
return(bpage != NULL);
}
......@@ -1047,17 +1033,12 @@ buf_page_release(
ut_a(block->page.buf_fix_count > 0);
if (rw_latch == RW_X_LATCH && mtr->modifications) {
//buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
mutex_enter(&block->mutex);
ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
buf_pool_mutex_enter();
buf_flush_note_modification(block, mtr);
//buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
buf_pool_mutex_exit();
}
else {
mutex_enter(&block->mutex);
}
#ifdef UNIV_SYNC_DEBUG
rw_lock_s_unlock(&(block->debug_latch));
......
......@@ -59,8 +59,7 @@ buf_flush_note_modification(
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
//ut_ad(buf_pool_mutex_own());
ut_ad(mutex_own(&flush_list_mutex));
ut_ad(buf_pool_mutex_own());
ut_ad(mtr->start_lsn != 0);
ut_ad(mtr->modifications);
......@@ -100,8 +99,7 @@ buf_flush_recv_note_modification(
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */
//buf_pool_mutex_enter();
mutex_enter(&flush_list_mutex);
buf_pool_mutex_enter();
ut_ad(block->page.newest_modification <= end_lsn);
......@@ -118,6 +116,5 @@ buf_flush_recv_note_modification(
ut_ad(block->page.oldest_modification <= start_lsn);
}
//buf_pool_mutex_exit();
mutex_exit(&flush_list_mutex);
buf_pool_mutex_exit();
}
......@@ -122,11 +122,10 @@ buf_LRU_free_block(
buf_page_t* bpage, /* in: block to be freed */
ibool zip, /* in: TRUE if should remove also the
compressed page of an uncompressed page */
ibool* buf_pool_mutex_released,
ibool* buf_pool_mutex_released);
/* in: pointer to a variable that will
be assigned TRUE if buf_pool_mutex
was temporarily released, or NULL */
ibool have_LRU_mutex);
/**********************************************************************
Try to free a replaceable block. */
UNIV_INTERN
......@@ -170,8 +169,7 @@ UNIV_INTERN
void
buf_LRU_block_free_non_file_page(
/*=============================*/
buf_block_t* block, /* in: block, must not contain a file page */
ibool have_page_hash_mutex);
buf_block_t* block); /* in: block, must not contain a file page */
/**********************************************************************
Adds a block to the LRU list. */
UNIV_INTERN
......
......@@ -357,31 +357,11 @@ rw_lock_get_x_lock_count(
rw_lock_t* lock); /* in: rw-lock */
/************************************************************************
Accessor functions for rw lock. */
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
UNIV_INLINE
ulint
rw_lock_get_s_waiters(
/*==================*/
rw_lock_t* lock);
UNIV_INLINE
ulint
rw_lock_get_x_waiters(
/*==================*/
rw_lock_t* lock);
UNIV_INLINE
ulint
rw_lock_get_wx_waiters(
/*================*/
rw_lock_t* lock);
#else /* !INNODB_RW_LOCKS_USE_ATOMICS */
UNIV_INLINE
ulint
rw_lock_get_waiters(
/*==================*/
/*================*/
rw_lock_t* lock);
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
UNIV_INLINE
ulint
rw_lock_get_writer(
......@@ -498,16 +478,6 @@ rw_lock_debug_print(
rw_lock_debug_t* info); /* in: debug struct */
#endif /* UNIV_SYNC_DEBUG */
/*
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
#error INNODB_RW_LOCKS_USE_ATOMICS is not defined. Do you use enough new GCC or compatibles?
#error Or do you use exact options for CFLAGS?
#error e.g. (for x86_32): "-m32 -march=i586 -mtune=i686"
#error e.g. (for Sparc_64): "-m64 -mcpu=v9"
#error Otherwise, this build may be slower than normal version.
#endif
*/
/* NOTE! The structure appears here only for the compiler to know its size.
Do not use its fields directly! The structure used in the spin lock
implementation of a read-write lock. Several threads may have a shared lock
......@@ -519,16 +489,7 @@ no new readers will be let in while the thread waits for readers to exit. */
struct rw_lock_struct {
volatile lint lock_word;
/* Holds the state of the lock. */
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
volatile ulint s_waiters; /* 1: there are waiters (s_lock) */
volatile ulint x_waiters; /* 1: there are waiters (x_lock) */
volatile ulint wait_ex_waiters; /* 1: there are waiters (wait_ex) */
volatile ulint reader_count; /* Number of readers who have locked this
lock in the shared mode */
volatile ulint writer;
#else
volatile ulint waiters;/* 1: there are waiters */
#endif
volatile ibool recursive;/* Default value FALSE which means the lock
is non-recursive. The value is typically set
to TRUE making normal rw_locks recursive. In
......@@ -545,16 +506,7 @@ struct rw_lock_struct {
/* Thread id of writer thread. Is only
guaranteed to have sane and non-stale
value iff recursive flag is set. */
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
volatile ulint writer_count; /* Number of times the same thread has
recursively locked the lock in the exclusive
mode */
/* Used by sync0arr.c for thread queueing */
os_event_t s_event; /* Used for s_lock */
os_event_t x_event; /* Used for x_lock */
#else
os_event_t event; /* Used by sync0arr.c for thread queueing */
#endif
os_event_t wait_ex_event;
/* Event for next-writer to wait on. A thread
must decrement lock_word before waiting. */
......@@ -576,7 +528,7 @@ struct rw_lock_struct {
/* last s-lock file/line is not guaranteed to be correct */
const char* last_s_file_name;/* File name where last s-locked */
const char* last_x_file_name;/* File name where last x-locked */
volatile ibool writer_is_wait_ex;
ibool writer_is_wait_ex;
/* This is TRUE if the writer field is
RW_LOCK_WAIT_EX; this field is located far
from the memory update hotspot fields which
......
This diff is collapsed.
......@@ -49,6 +49,9 @@ or there was no master log position info inside InnoDB. */
extern char trx_sys_mysql_master_log_name[];
extern ib_int64_t trx_sys_mysql_master_log_pos;
extern char trx_sys_mysql_relay_log_name[];
extern ib_int64_t trx_sys_mysql_relay_log_pos;
/* If this MySQL server uses binary logging, after InnoDB has been inited
and if it has done a crash recovery, we store the binlog file name and position
here. If .._pos is -1, it means there was no binlog position info inside
......@@ -290,7 +293,7 @@ UNIV_INTERN
void
trx_sys_update_mysql_binlog_offset(
/*===============================*/
const char* file_name,/* in: MySQL log file name */
const char* file_name_in,/* in: MySQL log file name */
ib_int64_t offset, /* in: position in that log file */
ulint field, /* in: offset of the MySQL log info field in
the trx sys header */
......@@ -421,6 +424,7 @@ therefore 256; each slot is currently 8 bytes in size */
#define TRX_SYS_N_RSEGS 256
#define TRX_SYS_MYSQL_LOG_NAME_LEN 512
#define TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN 480 /* (500 - 12) is dead line. */
#define TRX_SYS_MYSQL_LOG_MAGIC_N 873422344
#if UNIV_PAGE_SIZE < 4096
......@@ -429,6 +433,7 @@ therefore 256; each slot is currently 8 bytes in size */
/* The offset of the MySQL replication info in the trx system header;
this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */
#define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000)
#define TRX_SYS_MYSQL_RELAY_LOG_INFO (UNIV_PAGE_SIZE - 1500)
/* The offset of the MySQL binlog offset info in the trx system header */
#define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000)
......
......@@ -579,6 +579,21 @@ struct trx_struct{
ib_int64_t mysql_log_offset;/* if MySQL binlog is used, this field
contains the end offset of the binlog
entry */
const char* mysql_master_log_file_name;
/* if the database server is a MySQL
replication slave, we have here the
master binlog name up to which
replication has processed; otherwise
this is a pointer to a null
character */
ib_int64_t mysql_master_log_pos;
/* if the database server is a MySQL
replication slave, this is the
position in the log file up to which
replication has processed */
const char* mysql_relay_log_file_name;
ib_int64_t mysql_relay_log_pos;
os_thread_id_t mysql_thread_id;/* id of the MySQL thread associated
with this transaction object */
ulint mysql_process_no;/* since in Linux, 'top' reports
......
......@@ -35,7 +35,7 @@ Created 1/20/1994 Heikki Tuuri
#define INNODB_VERSION_MAJOR 1
#define INNODB_VERSION_MINOR 0
#define INNODB_VERSION_BUGFIX 3
#define PERCONA_INNODB_VERSION 3
#define PERCONA_INNODB_VERSION 5a
/* The following is the InnoDB version as shown in
SELECT plugin_version FROM information_schema.plugins;
......
......@@ -12,8 +12,3 @@ If by any chance Makefile.in and ./configure are regenerated and thus
the hack from Makefile.in wiped away then the "real" check from plug.in
will take over.
*/
/* This is temprary fix for http://bugs.mysql.com/43740 */
/* force to enable */
#ifdef HAVE_GCC_ATOMIC_BUILTINS
#define HAVE_ATOMIC_PTHREAD_T
#endif
......@@ -331,15 +331,8 @@ sync_cell_get_event(
return(((mutex_t *) cell->wait_object)->event);
} else if (type == RW_LOCK_WAIT_EX) {
return(((rw_lock_t *) cell->wait_object)->wait_ex_event);
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
} else if (type == RW_LOCK_SHARED) {
return(((rw_lock_t *) cell->wait_object)->s_event);
} else { /* RW_LOCK_EX */
return(((rw_lock_t *) cell->wait_object)->x_event);
#else
} else { /* RW_LOCK_SHARED and RW_LOCK_EX wait on the same event */
return(((rw_lock_t *) cell->wait_object)->event);
#endif
}
}
......@@ -483,7 +476,7 @@ sync_array_cell_print(
fprintf(file,
"--Thread %lu has waited at %s line %lu"
" for %.2f seconds the semaphore:\n",
" for %#.5g seconds the semaphore:\n",
(ulong) os_thread_pf(cell->thread), cell->file,
(ulong) cell->line,
difftime(time(NULL), cell->reservation_time));
......@@ -510,7 +503,7 @@ sync_array_cell_print(
|| type == RW_LOCK_WAIT_EX
|| type == RW_LOCK_SHARED) {
fputs(type == RW_LOCK_SHARED ? "S-lock on" : "X-lock on", file);
fputs(type == RW_LOCK_EX ? "X-lock on" : "S-lock on", file);
rwlock = cell->old_wait_rw_lock;
......@@ -530,21 +523,12 @@ sync_array_cell_print(
}
fprintf(file,
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
"number of readers %lu, s_waiters flag %lu, x_waiters flag %lu, "
#else
"number of readers %lu, waiters flag %lu, "
#endif
"lock_word: %lx\n"
"Last time read locked in file %s line %lu\n"
"Last time write locked in file %s line %lu\n",
(ulong) rw_lock_get_reader_count(rwlock),
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
(ulong) rwlock->s_waiters,
(ulong) (rwlock->x_waiters || rwlock->wait_ex_waiters),
#else
(ulong) rwlock->waiters,
#endif
rwlock->lock_word,
rwlock->last_s_file_name,
(ulong) rwlock->last_s_line,
......
This diff is collapsed.
......@@ -69,9 +69,12 @@ file name and position here. We have successfully got the updates to InnoDB
up to this position. If .._pos is -1, it means no crash recovery was needed,
or there was no master log position info inside InnoDB. */
UNIV_INTERN char trx_sys_mysql_master_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN];
UNIV_INTERN char trx_sys_mysql_master_log_name[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN];
UNIV_INTERN ib_int64_t trx_sys_mysql_master_log_pos = -1;
UNIV_INTERN char trx_sys_mysql_relay_log_name[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN];
UNIV_INTERN ib_int64_t trx_sys_mysql_relay_log_pos = -1;
/* If this MySQL server uses binary logging, after InnoDB has been inited
and if it has done a crash recovery, we store the binlog file name and position
here. If .._pos is -1, it means there was no binlog position info inside
......@@ -661,19 +664,24 @@ UNIV_INTERN
void
trx_sys_update_mysql_binlog_offset(
/*===============================*/
const char* file_name,/* in: MySQL log file name */
const char* file_name_in,/* in: MySQL log file name */
ib_int64_t offset, /* in: position in that log file */
ulint field, /* in: offset of the MySQL log info field in
the trx sys header */
mtr_t* mtr) /* in: mtr */
{
trx_sysf_t* sys_header;
const char* file_name;
if (ut_strlen(file_name) >= TRX_SYS_MYSQL_LOG_NAME_LEN) {
if (ut_strlen(file_name_in) >= TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN) {
/* We cannot fit the name to the 512 bytes we have reserved */
/* -> To store relay log file information, file_name must fit to the 480 bytes */
return;
file_name = "";
}
else {
file_name = file_name_in;
}
sys_header = trx_sysf_get(mtr);
......@@ -834,13 +842,26 @@ trx_sys_print_mysql_master_log_pos(void)
+ TRX_SYS_MYSQL_LOG_OFFSET_LOW),
sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO
+ TRX_SYS_MYSQL_LOG_NAME);
fprintf(stderr,
"InnoDB: and relay log file\n"
"InnoDB: position %lu %lu, file name %s\n",
(ulong) mach_read_from_4(sys_header
+ TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_HIGH),
(ulong) mach_read_from_4(sys_header
+ TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_LOW),
sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_NAME);
/* Copy the master log position info to global variables we can
use in ha_innobase.cc to initialize glob_mi to right values */
ut_memcpy(trx_sys_mysql_master_log_name,
sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO
+ TRX_SYS_MYSQL_LOG_NAME,
TRX_SYS_MYSQL_LOG_NAME_LEN);
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
trx_sys_mysql_master_log_pos
= (((ib_int64_t) mach_read_from_4(
......@@ -849,6 +870,19 @@ trx_sys_print_mysql_master_log_pos(void)
+ ((ib_int64_t) mach_read_from_4(
sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_LOW));
ut_memcpy(trx_sys_mysql_relay_log_name,
sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_NAME,
TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN);
trx_sys_mysql_relay_log_pos
= (((ib_int64_t) mach_read_from_4(
sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) << 32)
+ ((ib_int64_t) mach_read_from_4(
sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO
+ TRX_SYS_MYSQL_LOG_OFFSET_LOW));
mtr_commit(&mtr);
}
......
......@@ -127,6 +127,10 @@ trx_create(
trx->mysql_log_file_name = NULL;
trx->mysql_log_offset = 0;
trx->mysql_master_log_file_name = "";
trx->mysql_master_log_pos = 0;
trx->mysql_relay_log_file_name = "";
trx->mysql_relay_log_pos = 0;
mutex_create(&trx->undo_mutex, SYNC_TRX_UNDO);
......@@ -792,6 +796,19 @@ trx_commit_off_kernel(
trx->mysql_log_file_name = NULL;
}
if (trx->mysql_master_log_file_name[0] != '\0') {
/* This database server is a MySQL replication slave */
trx_sys_update_mysql_binlog_offset(
trx->mysql_relay_log_file_name,
trx->mysql_relay_log_pos,
TRX_SYS_MYSQL_RELAY_LOG_INFO, &mtr);
trx_sys_update_mysql_binlog_offset(
trx->mysql_master_log_file_name,
trx->mysql_master_log_pos,
TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr);
trx->mysql_master_log_file_name = "";
}
/* The following call commits the mini-transaction, making the
whole transaction committed in the file-based world, at this
log sequence number. The transaction becomes 'durable' when
......
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