Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
33cb10d4
Commit
33cb10d4
authored
Nov 12, 2019
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.3 into 10.4
parents
e5f99a0c
5098d708
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
543 additions
and
498 deletions
+543
-498
mysql-test/main/selectivity.result
mysql-test/main/selectivity.result
+56
-0
mysql-test/main/selectivity.test
mysql-test/main/selectivity.test
+32
-0
mysql-test/main/selectivity_innodb.result
mysql-test/main/selectivity_innodb.result
+56
-0
mysql-test/suite/binlog_encryption/rpl_corruption.result
mysql-test/suite/binlog_encryption/rpl_corruption.result
+2
-2
mysql-test/suite/rpl/include/rpl_corruption.inc
mysql-test/suite/rpl/include/rpl_corruption.inc
+4
-4
mysql-test/suite/rpl/r/rpl_corruption.result
mysql-test/suite/rpl/r/rpl_corruption.result
+2
-2
mysql-test/suite/rpl/r/rpl_semi_sync_gtid_reconnect.result
mysql-test/suite/rpl/r/rpl_semi_sync_gtid_reconnect.result
+40
-0
mysql-test/suite/rpl/t/rpl_semi_sync_gtid_reconnect.test
mysql-test/suite/rpl/t/rpl_semi_sync_gtid_reconnect.test
+74
-0
scripts/wsrep_sst_mariabackup.sh
scripts/wsrep_sst_mariabackup.sh
+7
-0
sql/sql_repl.cc
sql/sql_repl.cc
+4
-1
sql/sql_select.cc
sql/sql_select.cc
+0
-4
sql/table.cc
sql/table.cc
+20
-0
sql/table.h
sql/table.h
+1
-0
storage/innobase/include/mtr0mtr.h
storage/innobase/include/mtr0mtr.h
+79
-157
storage/innobase/include/mtr0mtr.ic
storage/innobase/include/mtr0mtr.ic
+20
-35
storage/innobase/include/mtr0types.h
storage/innobase/include/mtr0types.h
+6
-11
storage/innobase/log/log0recv.cc
storage/innobase/log/log0recv.cc
+16
-24
storage/innobase/mtr/mtr0mtr.cc
storage/innobase/mtr/mtr0mtr.cc
+124
-258
No files found.
mysql-test/main/selectivity.result
View file @
33cb10d4
...
...
@@ -1810,5 +1810,61 @@ b a a b
9 9 10 10
set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
drop table t1,t2,t3;
#
# MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
#
create table t1 (id int, a int, PRIMARY KEY(id), key(a));
insert into t1 select seq,seq from seq_1_to_100;
create table t2 (id int, a int, b int, PRIMARY KEY(id), key(a), key(b));
insert into t2 select seq,seq,seq from seq_1_to_100;
set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id a
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
1 SIMPLE B ref a a 5 const 1
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
mysql-test/main/selectivity.test
View file @
33cb10d4
...
...
@@ -1235,6 +1235,38 @@ set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
drop
table
t1
,
t2
,
t3
;
--
echo
#
--
echo
# MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
--
echo
#
create
table
t1
(
id
int
,
a
int
,
PRIMARY
KEY
(
id
),
key
(
a
));
insert
into
t1
select
seq
,
seq
from
seq_1_to_100
;
create
table
t2
(
id
int
,
a
int
,
b
int
,
PRIMARY
KEY
(
id
),
key
(
a
),
key
(
b
));
insert
into
t2
select
seq
,
seq
,
seq
from
seq_1_to_100
;
set
optimizer_switch
=
'exists_to_in=off'
;
set
optimizer_use_condition_selectivity
=
2
;
let
$query
=
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
*
FROM
t1
A
INNER
JOIN
t2
ON
t2
.
a
=
A
.
id
WHERE
A
.
a
=
t1
.
a
AND
t2
.
b
<
20
);
eval
$query
;
eval
explain
$query
;
EXPLAIN
SELECT
*
FROM
t1
A
,
t1
B
WHERE
A
.
a
=
B
.
a
and
A
.
id
=
65
;
eval
explain
$query
;
set
optimizer_switch
=
@
save_optimizer_switch
;
set
optimizer_use_condition_selectivity
=
@
save_optimizer_use_condition_selectivity
;
drop
table
t1
,
t2
;
--
echo
# End of 10.1 tests
#
...
...
mysql-test/main/selectivity_innodb.result
View file @
33cb10d4
...
...
@@ -1820,6 +1820,62 @@ b a a b
9 9 10 10
set optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
drop table t1,t2,t3;
#
# MDEV-20519: Query plan regression with optimizer_use_condition_selectivity=4
#
create table t1 (id int, a int, PRIMARY KEY(id), key(a));
insert into t1 select seq,seq from seq_1_to_100;
create table t2 (id int, a int, b int, PRIMARY KEY(id), key(a), key(b));
insert into t2 select seq,seq,seq from seq_1_to_100;
set optimizer_switch='exists_to_in=off';
set optimizer_use_condition_selectivity=2;
SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id a
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
EXPLAIN SELECT * FROM t1 A, t1 B WHERE A.a = B.a and A.id = 65;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A const PRIMARY,a PRIMARY 4 const 1
1 SIMPLE B ref a a 5 const 1 Using index
explain SELECT * FROM t1
WHERE
EXISTS (SELECT * FROM t1 A INNER JOIN t2 ON t2.a = A.id
WHERE A.a=t1.a AND t2.b < 20);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index NULL a 5 NULL 100 Using where; Using index
2 DEPENDENT SUBQUERY A ref PRIMARY,a a 5 test.t1.a 1 Using index
2 DEPENDENT SUBQUERY t2 ref a,b a 5 test.A.id 1 Using where
set optimizer_switch= @save_optimizer_switch;
set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
drop table t1,t2;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
...
...
mysql-test/suite/binlog_encryption/rpl_corruption.result
View file @
33cb10d4
...
...
@@ -30,7 +30,7 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
connection slave;
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1
91
3]
include/wait_for_slave_io_error.inc [errno=1595,1
74
3]
connection master;
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
SET GLOBAL debug_dbug= "";
...
...
@@ -39,7 +39,7 @@ SET GLOBAL master_verify_checksum=1;
connection slave;
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1
91
3]
include/wait_for_slave_io_error.inc [errno=1595,1
74
3]
SET GLOBAL debug_dbug="-d,corrupt_queue_event";
# 6. Slave. Corruption in relay log
SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char";
...
...
mysql-test/suite/rpl/include/rpl_corruption.inc
View file @
33cb10d4
...
...
@@ -122,11 +122,11 @@ SET GLOBAL master_verify_checksum=0;
SET
GLOBAL
debug_dbug
=
"+d,corrupt_read_log_event2_set"
;
--
connection
slave
START
SLAVE
IO_THREAD
;
# When the checksum error is detected, the slave sets error code 1
91
3
# When the checksum error is detected, the slave sets error code 1
74
3
# (ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE) in queue_event(), then immediately
# sets error 1595 (ER_SLAVE_RELAY_LOG_WRITE_FAILURE) in handle_slave_io().
# So we usually get 1595, but it is occasionally possible to get 1
91
3.
let
$slave_io_errno
=
1595
,
1
913
;
# So we usually get 1595, but it is occasionally possible to get 1
74
3.
let
$slave_io_errno
=
1595
,
1
743
;
# ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--
source
include
/
wait_for_slave_io_error
.
inc
--
connection
master
SET
GLOBAL
debug_dbug
=
"-d,corrupt_read_log_event2_set"
;
...
...
@@ -138,7 +138,7 @@ SET GLOBAL master_verify_checksum=1;
--
connection
slave
SET
GLOBAL
debug_dbug
=
"+d,corrupt_queue_event"
;
START
SLAVE
IO_THREAD
;
let
$slave_io_errno
=
1595
,
1
913
;
let
$slave_io_errno
=
1595
,
1
743
;
# ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE
--
source
include
/
wait_for_slave_io_error
.
inc
SET
GLOBAL
debug_dbug
=
"-d,corrupt_queue_event"
;
...
...
mysql-test/suite/rpl/r/rpl_corruption.result
View file @
33cb10d4
...
...
@@ -30,7 +30,7 @@ SET GLOBAL master_verify_checksum=0;
SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set";
connection slave;
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1
91
3]
include/wait_for_slave_io_error.inc [errno=1595,1
74
3]
connection master;
SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set";
SET GLOBAL debug_dbug= "";
...
...
@@ -39,7 +39,7 @@ SET GLOBAL master_verify_checksum=1;
connection slave;
SET GLOBAL debug_dbug="+d,corrupt_queue_event";
START SLAVE IO_THREAD;
include/wait_for_slave_io_error.inc [errno=1595,1
91
3]
include/wait_for_slave_io_error.inc [errno=1595,1
74
3]
SET GLOBAL debug_dbug="-d,corrupt_queue_event";
# 6. Slave. Corruption in relay log
SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char";
...
...
mysql-test/suite/rpl/r/rpl_semi_sync_gtid_reconnect.result
0 → 100644
View file @
33cb10d4
include/master-slave.inc
[connection master]
connection master;
RESET MASTER;
SET @@GLOBAL.rpl_semi_sync_master_enabled = 1;
connection slave;
include/stop_slave.inc
SET @@GLOBAL. rpl_semi_sync_slave_enabled = 1;
include/start_slave.inc
connection master;
CREATE TABLE t1 (a INT);
INSERT INTO t1 SET a = 1;
include/save_master_gtid.inc
FLUSH LOGS;
INSERT INTO t1 SET a = 2;
connection slave;
connection slave;
include/stop_slave_sql.inc
connection master;
INSERT INTO t1 SET a = 3;
include/sync_slave_io_with_master.inc
connection slave;
include/stop_slave_io.inc
connection master;
RESET MASTER;
SET @@global.gtid_binlog_state = '0-1-2';
connection slave;
CHANGE MASTER TO MASTER_USE_GTID = slave_pos;
SET @@global.gtid_slave_pos = '0-1-2';
include/start_slave.inc
connection master;
INSERT INTO t1 SET a = 4;
connection master;
DROP TABLE t1;
SET @@GLOBAL. rpl_semi_sync_master_enabled = 0;
connection slave;
include/stop_slave.inc
SET @@GLOBAL. rpl_semi_sync_slave_enabled = 0;
include/start_slave.inc
include/rpl_end.inc
mysql-test/suite/rpl/t/rpl_semi_sync_gtid_reconnect.test
0 → 100644
View file @
33cb10d4
source
include
/
not_embedded
.
inc
;
source
include
/
have_binlog_format_mixed
.
inc
;
source
include
/
master
-
slave
.
inc
;
#
# Semisync initialization
#
--
connection
master
RESET
MASTER
;
--
let
$sav_enabled_master
=
`SELECT @@GLOBAL.rpl_semi_sync_master_enabled`
SET
@@
GLOBAL
.
rpl_semi_sync_master_enabled
=
1
;
--
connection
slave
source
include
/
stop_slave
.
inc
;
--
let
$sav_enabled_slave
=
`SELECT @@GLOBAL.rpl_semi_sync_slave_enabled`
SET
@@
GLOBAL
.
rpl_semi_sync_slave_enabled
=
1
;
source
include
/
start_slave
.
inc
;
# Prove fixes to
# MDEV-19376 Assert (!m_active_tranxs->is_tranx_end_pos(trx_wait_binlog_name...)
#
#
# Run few queries to replicate/execute on slave.
# Stop the slave applier.
# Replicate/not-executed few more.
# Restart the slave.
#
--
connection
master
CREATE
TABLE
t1
(
a
INT
);
INSERT
INTO
t1
SET
a
=
1
;
--
source
include
/
save_master_gtid
.
inc
--
let
$resume_gtid
=
$master_pos
FLUSH
LOGS
;
INSERT
INTO
t1
SET
a
=
2
;
--
sync_slave_with_master
--
connection
slave
--
source
include
/
stop_slave_sql
.
inc
--
connection
master
INSERT
INTO
t1
SET
a
=
3
;
# the sync connection is 'slave' by default
--
source
include
/
sync_slave_io_with_master
.
inc
--
connection
slave
--
source
include
/
stop_slave_io
.
inc
--
connection
master
RESET
MASTER
;
--
eval
SET
@@
global
.
gtid_binlog_state
=
'$resume_gtid'
# The resume gtid is set up to point to the very first binlog file
--
connection
slave
CHANGE
MASTER
TO
MASTER_USE_GTID
=
slave_pos
;
--
eval
SET
@@
global
.
gtid_slave_pos
=
'$resume_gtid'
# Yet the slave io first submits the last received binlog file name:pos.
--
source
include
/
start_slave
.
inc
# Here goes the cracker.
--
connection
master
INSERT
INTO
t1
SET
a
=
4
;
#
# Clean up
#
--
connection
master
DROP
TABLE
t1
;
--
eval
SET
@@
GLOBAL
.
rpl_semi_sync_master_enabled
=
$sav_enabled_master
--
sync_slave_with_master
source
include
/
stop_slave
.
inc
;
--
eval
SET
@@
GLOBAL
.
rpl_semi_sync_slave_enabled
=
$sav_enabled_slave
source
include
/
start_slave
.
inc
;
--
source
include
/
rpl_end
.
inc
scripts/wsrep_sst_mariabackup.sh
View file @
33cb10d4
...
...
@@ -83,7 +83,14 @@ fi
pcmd
=
"pv
$pvopts
"
declare
-a
RC
set
+e
INNOBACKUPEX_BIN
=
$(
which mariabackup
)
if
test
-z
$INNOBACKUPEX_BIN
then
wsrep_log_error
'mariabackup binary not found in $PATH'
exit
42
fi
set
-e
XBSTREAM_BIN
=
mbstream
XBCRYPT_BIN
=
xbcrypt
# Not available in MariaBackup
...
...
sql/sql_repl.cc
View file @
33cb10d4
...
...
@@ -2824,7 +2824,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
/* Check if the dump thread is created by a slave with semisync enabled. */
thd
->
semi_sync_slave
=
is_semi_sync_slave
();
if
(
repl_semisync_master
.
dump_start
(
thd
,
log_ident
,
pos
))
DBUG_ASSERT
(
pos
==
linfo
.
pos
);
if
(
repl_semisync_master
.
dump_start
(
thd
,
linfo
.
log_file_name
,
linfo
.
pos
))
{
info
->
errmsg
=
"Failed to run hook 'transmit_start'"
;
info
->
error
=
ER_UNKNOWN_ERROR
;
...
...
sql/sql_select.cc
View file @
33cb10d4
...
...
@@ -9087,7 +9087,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
something went wrong.
*/
sel
/=
(
double
)
table
->
quick_rows
[
key
]
/
(
double
)
table
->
stat_records
();
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller
(
sel
,
1.0
);
used_range_selectivity
=
true
;
}
...
...
@@ -9136,7 +9135,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if
(
table
->
field
[
fldno
]
->
cond_selectivity
>
0
)
{
sel
/=
table
->
field
[
fldno
]
->
cond_selectivity
;
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller
(
sel
,
1.0
);
}
/*
...
...
@@ -9194,7 +9192,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
if
(
field
->
cond_selectivity
>
0
)
{
sel
/=
field
->
cond_selectivity
;
// MDEV-20595 FIXME: DBUG_ASSERT(sel > 0 && sel <= 2.0);
set_if_smaller
(
sel
,
1.0
);
}
break
;
...
...
@@ -9206,7 +9203,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
sel
*=
table_multi_eq_cond_selectivity
(
join
,
idx
,
s
,
rem_tables
,
keyparts
,
ref_keyuse_steps
);
DBUG_ASSERT
(
0.0
<
sel
&&
sel
<=
1.0
);
return
sel
;
}
...
...
sql/table.cc
View file @
33cb10d4
...
...
@@ -5109,6 +5109,8 @@ void TABLE::init(THD *thd, TABLE_LIST *tl)
update_handler
=
NULL
;
check_unique_buf
=
NULL
;
vers_write
=
s
->
versioned
;
quick_condition_rows
=
0
;
initialize_quick_structures
();
#ifdef HAVE_REPLICATION
/* used in RBR Triggers */
master_had_triggers
=
0
;
...
...
@@ -9608,3 +9610,21 @@ bool TABLE::export_structure(THD *thd, Row_definition_list *defs)
}
return
false
;
}
/*
@brief
Initialize all the quick structures that are used to stored the
estimates when the range optimizer is run.
@details
This is specifically needed when we read the TABLE structure from the
table cache. There can be some garbage data from previous queries
that need to be reset here.
*/
void
TABLE
::
initialize_quick_structures
()
{
bzero
(
quick_rows
,
sizeof
(
quick_rows
));
bzero
(
quick_key_parts
,
sizeof
(
quick_key_parts
));
bzero
(
quick_costs
,
sizeof
(
quick_costs
));
bzero
(
quick_n_ranges
,
sizeof
(
quick_n_ranges
));
}
sql/table.h
View file @
33cb10d4
...
...
@@ -1518,6 +1518,7 @@ struct TABLE
bool
is_filled_at_execution
();
bool
update_const_key_parts
(
COND
*
conds
);
void
initialize_quick_structures
();
my_ptrdiff_t
default_values_offset
()
const
{
return
(
my_ptrdiff_t
)
(
s
->
default_values
-
record
[
0
]);
}
...
...
storage/innobase/include/mtr0mtr.h
View file @
33cb10d4
...
...
@@ -130,62 +130,7 @@ struct mtr_memo_slot_t {
/** Mini-transaction handle and buffer */
struct
mtr_t
{
/** State variables of the mtr */
struct
Impl
{
/** memo stack for locks etc. */
mtr_buf_t
m_memo
;
/** mini-transaction log */
mtr_buf_t
m_log
;
/** true if mtr has made at least one buffer pool page dirty */
bool
m_made_dirty
;
/** true if inside ibuf changes */
bool
m_inside_ibuf
;
/** true if the mini-transaction modified buffer pool pages */
bool
m_modifications
;
/** Count of how many page initial log records have been
written to the mtr log */
ib_uint32_t
m_n_log_recs
;
/** specifies which operations should be logged; default
value MTR_LOG_ALL */
mtr_log_t
m_log_mode
;
#ifdef UNIV_DEBUG
/** Persistent user tablespace associated with the
mini-transaction, or 0 (TRX_SYS_SPACE) if none yet */
ulint
m_user_space_id
;
#endif
/* UNIV_DEBUG */
/** User tablespace that is being modified by the
mini-transaction */
fil_space_t
*
m_user_space
;
/** State of the transaction */
mtr_state_t
m_state
;
/** Flush Observer */
FlushObserver
*
m_flush_observer
;
#ifdef UNIV_DEBUG
/** For checking corruption. */
ulint
m_magic_n
;
#endif
/* UNIV_DEBUG */
/** Owning mini-transaction */
mtr_t
*
m_mtr
;
};
mtr_t
()
{
m_impl
.
m_state
=
MTR_STATE_INIT
;
}
~
mtr_t
()
{
}
mtr_t
()
:
m_state
(
MTR_STATE_INIT
)
{}
/** Start a mini-transaction. */
void
start
();
...
...
@@ -207,14 +152,7 @@ struct mtr_t {
/** Return current size of the buffer.
@return savepoint */
ulint
get_savepoint
()
const
MY_ATTRIBUTE
((
warn_unused_result
))
{
ut_ad
(
is_active
());
ut_ad
(
m_impl
.
m_magic_n
==
MTR_MAGIC_N
);
return
(
m_impl
.
m_memo
.
size
());
}
ulint
get_savepoint
()
const
{
ut_ad
(
is_active
());
return
m_memo
.
size
();}
/** Release the (index tree) s-latch stored in an mtr memo after a
savepoint.
...
...
@@ -251,11 +189,11 @@ struct mtr_t {
the same set of tablespaces as this one */
void
set_spaces
(
const
mtr_t
&
mtr
)
{
ut_ad
(
!
m_
impl
.
m_
user_space_id
);
ut_ad
(
!
m_
impl
.
m_
user_space
);
ut_ad
(
!
m_user_space_id
);
ut_ad
(
!
m_user_space
);
ut_d
(
m_
impl
.
m_user_space_id
=
mtr
.
m_impl
.
m_user_space_id
);
m_
impl
.
m_user_space
=
mtr
.
m_impl
.
m_user_space
;
ut_d
(
m_
user_space_id
=
mtr
.
m_user_space_id
);
m_
user_space
=
mtr
.
m_user_space
;
}
/** Set the tablespace associated with the mini-transaction
...
...
@@ -264,16 +202,16 @@ struct mtr_t {
@return the tablespace */
fil_space_t
*
set_named_space_id
(
ulint
space_id
)
{
ut_ad
(
!
m_
impl
.
m_
user_space_id
);
ut_d
(
m_
impl
.
m_
user_space_id
=
space_id
);
ut_ad
(
!
m_user_space_id
);
ut_d
(
m_user_space_id
=
space_id
);
if
(
!
space_id
)
{
return
fil_system
.
sys_space
;
}
else
{
ut_ad
(
m_
impl
.
m_
user_space_id
==
space_id
);
ut_ad
(
!
m_
impl
.
m_
user_space
);
m_
impl
.
m_
user_space
=
fil_space_get
(
space_id
);
ut_ad
(
m_
impl
.
m_
user_space
);
return
m_
impl
.
m_
user_space
;
ut_ad
(
m_user_space_id
==
space_id
);
ut_ad
(
!
m_user_space
);
m_user_space
=
fil_space_get
(
space_id
);
ut_ad
(
m_user_space
);
return
m_user_space
;
}
}
...
...
@@ -282,10 +220,10 @@ struct mtr_t {
@param[in] space user or system tablespace */
void
set_named_space
(
fil_space_t
*
space
)
{
ut_ad
(
!
m_
impl
.
m_
user_space_id
);
ut_d
(
m_
impl
.
m_
user_space_id
=
space
->
id
);
ut_ad
(
!
m_user_space_id
);
ut_d
(
m_user_space_id
=
space
->
id
);
if
(
space
->
id
)
{
m_
impl
.
m_
user_space
=
space
;
m_user_space
=
space
;
}
}
...
...
@@ -345,18 +283,12 @@ struct mtr_t {
void
release_page
(
const
void
*
ptr
,
mtr_memo_type_t
type
);
/** Note that the mini-transaction has modified data. */
void
set_modified
()
{
m_impl
.
m_modifications
=
true
;
}
void
set_modified
()
{
m_modifications
=
true
;
}
/** Set the state to not-modified. This will not log the
changes. This is only used during redo log apply, to avoid
logging the changes. */
void
discard_modifications
()
{
m_impl
.
m_modifications
=
false
;
}
void
discard_modifications
()
{
m_modifications
=
false
;
}
/** Get the LSN of commit().
@return the commit LSN
...
...
@@ -368,45 +300,28 @@ struct mtr_t {
}
/** Note that we are inside the change buffer code. */
void
enter_ibuf
()
{
m_impl
.
m_inside_ibuf
=
true
;
}
void
enter_ibuf
()
{
m_inside_ibuf
=
true
;
}
/** Note that we have exited from the change buffer code. */
void
exit_ibuf
()
{
m_impl
.
m_inside_ibuf
=
false
;
}
void
exit_ibuf
()
{
m_inside_ibuf
=
false
;
}
/** @return true if we are inside the change buffer code */
bool
is_inside_ibuf
()
const
{
return
(
m_impl
.
m_inside_ibuf
);
}
bool
is_inside_ibuf
()
const
{
return
m_inside_ibuf
;
}
/*
@return true if the mini-transaction is active */
bool
is_active
()
const
{
return
(
m_impl
.
m_state
==
MTR_STATE_ACTIVE
);
}
bool
is_active
()
const
{
return
m_state
==
MTR_STATE_ACTIVE
;
}
/** Get flush observer
@return flush observer */
FlushObserver
*
get_flush_observer
()
const
{
return
(
m_impl
.
m_flush_observer
);
}
FlushObserver
*
get_flush_observer
()
const
{
return
m_flush_observer
;
}
/** Set flush observer
@param[in] observer flush observer */
void
set_flush_observer
(
FlushObserver
*
observer
)
{
ut_ad
(
observer
==
NULL
||
m_impl
.
m_log_mode
==
MTR_LOG_NO_REDO
);
m_impl
.
m_flush_observer
=
observer
;
ut_ad
(
observer
==
NULL
||
m_log_mode
==
MTR_LOG_NO_REDO
);
m_flush_observer
=
observer
;
}
#ifdef UNIV_DEBUG
...
...
@@ -446,65 +361,31 @@ struct mtr_t {
void
print
()
const
;
/** @return true if the mini-transaction has committed */
bool
has_committed
()
const
{
return
(
m_impl
.
m_state
==
MTR_STATE_COMMITTED
);
}
/** @return true if the mini-transaction is committing */
bool
is_committing
()
const
{
return
(
m_impl
.
m_state
==
MTR_STATE_COMMITTING
);
}
bool
has_committed
()
const
{
return
m_state
==
MTR_STATE_COMMITTED
;
}
/** @return true if mini-transaction contains modifications. */
bool
has_modifications
()
const
{
return
(
m_impl
.
m_modifications
);
}
bool
has_modifications
()
const
{
return
m_modifications
;
}
/** @return the memo stack */
const
mtr_buf_t
*
get_memo
()
const
{
return
(
&
m_impl
.
m_memo
);
}
const
mtr_buf_t
*
get_memo
()
const
{
return
&
m_memo
;
}
/** @return the memo stack */
mtr_buf_t
*
get_memo
()
{
return
(
&
m_impl
.
m_memo
);
}
mtr_buf_t
*
get_memo
()
{
return
&
m_memo
;
}
#endif
/* UNIV_DEBUG */
/** @return true if a record was added to the mini-transaction */
bool
is_dirty
()
const
{
return
(
m_impl
.
m_made_dirty
);
}
bool
is_dirty
()
const
{
return
m_made_dirty
;
}
/** Note that a record has been added to the log */
void
added_rec
()
{
++
m_impl
.
m_n_log_recs
;
}
void
added_rec
()
{
++
m_n_log_recs
;
}
/** Get the buffered redo log of this mini-transaction.
@return redo log */
const
mtr_buf_t
*
get_log
()
const
{
ut_ad
(
m_impl
.
m_magic_n
==
MTR_MAGIC_N
);
return
(
&
m_impl
.
m_log
);
}
const
mtr_buf_t
*
get_log
()
const
{
return
&
m_log
;
}
/** Get the buffered redo log of this mini-transaction.
@return redo log */
mtr_buf_t
*
get_log
()
{
ut_ad
(
m_impl
.
m_magic_n
==
MTR_MAGIC_N
);
return
(
&
m_impl
.
m_log
);
}
mtr_buf_t
*
get_log
()
{
return
&
m_log
;
}
/** Push an object to an mtr memo stack.
@param object object
...
...
@@ -518,15 +399,56 @@ struct mtr_t {
MY_ATTRIBUTE
((
warn_unused_result
));
private:
class
Command
;
/** Prepare to write the mini-transaction log to the redo log buffer.
@return number of bytes to write in finish_write() */
inline
ulint
prepare_write
();
friend
class
Command
;
/** Append the redo log records to the redo log buffer.
@param[in] len number of bytes to write
@return start_lsn */
inline
lsn_t
finish_write
(
ulint
len
);
private:
Impl
m_impl
;
/** Release the resources */
inline
void
release_resources
();
/** memo stack for locks etc. */
mtr_buf_t
m_memo
;
/** mini-transaction log */
mtr_buf_t
m_log
;
/** true if mtr has made at least one buffer pool page dirty */
bool
m_made_dirty
;
/** true if inside ibuf changes */
bool
m_inside_ibuf
;
/** true if the mini-transaction modified buffer pool pages */
bool
m_modifications
;
/** Count of how many page initial log records have been
written to the mtr log */
ib_uint32_t
m_n_log_recs
;
/** specifies which operations should be logged; default
value MTR_LOG_ALL */
mtr_log_t
m_log_mode
;
#ifdef UNIV_DEBUG
/** Persistent user tablespace associated with the
mini-transaction, or 0 (TRX_SYS_SPACE) if none yet */
ulint
m_user_space_id
;
#endif
/* UNIV_DEBUG */
/** User tablespace that is being modified by the mini-transaction */
fil_space_t
*
m_user_space
;
/** State of the transaction */
mtr_state_t
m_state
;
/** Flush Observer */
FlushObserver
*
m_flush_observer
;
/** LSN at commit time */
volatile
lsn_t
m_commit_lsn
;
lsn_t
m_commit_lsn
;
};
#include "mtr0mtr.ic"
...
...
storage/innobase/include/mtr0mtr.ic
View file @
33cb10d4
...
...
@@ -49,7 +49,6 @@ mtr_t::memo_push(void* object, mtr_memo_type_t type)
ut_ad(object != NULL);
ut_ad(type >= MTR_MEMO_PAGE_S_FIX);
ut_ad(type <= MTR_MEMO_SX_LOCK);
ut_ad(m_impl.m_magic_n == MTR_MAGIC_N);
ut_ad(ut_is_2pow(type));
/* If this mtr has x-fixed a clean page then we set
...
...
@@ -58,15 +57,13 @@ mtr_t::memo_push(void* object, mtr_memo_type_t type)
can insert the dirtied page to the flush list. */
if ((type == MTR_MEMO_PAGE_X_FIX || type == MTR_MEMO_PAGE_SX_FIX)
&& !m_
impl.m_
made_dirty) {
&& !m_made_dirty) {
m_
impl.m_
made_dirty = is_block_dirtied(
m_made_dirty = is_block_dirtied(
reinterpret_cast<const buf_block_t*>(object));
}
mtr_memo_slot_t* slot;
slot = m_impl.m_memo.push<mtr_memo_slot_t*>(sizeof(*slot));
mtr_memo_slot_t* slot = m_memo.push<mtr_memo_slot_t*>(sizeof(*slot));
slot->type = type;
slot->object = object;
...
...
@@ -81,11 +78,9 @@ mtr_t::release_s_latch_at_savepoint(
rw_lock_t* lock)
{
ut_ad(is_active());
ut_ad(m_impl.m_magic_n == MTR_MAGIC_N);
ut_ad(m_impl.m_memo.size() > savepoint);
ut_ad(m_memo.size() > savepoint);
mtr_memo_slot_t* slot = m_
impl.m_
memo.at<mtr_memo_slot_t*>(savepoint);
mtr_memo_slot_t* slot = m_memo.at<mtr_memo_slot_t*>(savepoint);
ut_ad(slot->object == lock);
ut_ad(slot->type == MTR_MEMO_S_LOCK);
...
...
@@ -104,8 +99,7 @@ mtr_t::sx_latch_at_savepoint(
buf_block_t* block)
{
ut_ad(is_active());
ut_ad(m_impl.m_magic_n == MTR_MAGIC_N);
ut_ad(m_impl.m_memo.size() > savepoint);
ut_ad(m_memo.size() > savepoint);
ut_ad(!memo_contains_flagged(
block,
...
...
@@ -113,9 +107,7 @@ mtr_t::sx_latch_at_savepoint(
| MTR_MEMO_PAGE_X_FIX
| MTR_MEMO_PAGE_SX_FIX));
mtr_memo_slot_t* slot;
slot = m_impl.m_memo.at<mtr_memo_slot_t*>(savepoint);
mtr_memo_slot_t* slot = m_memo.at<mtr_memo_slot_t*>(savepoint);
ut_ad(slot->object == block);
...
...
@@ -124,8 +116,8 @@ mtr_t::sx_latch_at_savepoint(
rw_lock_sx_lock(&block->lock);
if (!m_
impl.m_
made_dirty) {
m_
impl.m_
made_dirty = is_block_dirtied(block);
if (!m_made_dirty) {
m_made_dirty = is_block_dirtied(block);
}
slot->type = MTR_MEMO_PAGE_SX_FIX;
...
...
@@ -140,8 +132,7 @@ mtr_t::x_latch_at_savepoint(
buf_block_t* block)
{
ut_ad(is_active());
ut_ad(m_impl.m_magic_n == MTR_MAGIC_N);
ut_ad(m_impl.m_memo.size() > savepoint);
ut_ad(m_memo.size() > savepoint);
ut_ad(!memo_contains_flagged(
block,
...
...
@@ -149,9 +140,7 @@ mtr_t::x_latch_at_savepoint(
| MTR_MEMO_PAGE_X_FIX
| MTR_MEMO_PAGE_SX_FIX));
mtr_memo_slot_t* slot;
slot = m_impl.m_memo.at<mtr_memo_slot_t*>(savepoint);
mtr_memo_slot_t* slot = m_memo.at<mtr_memo_slot_t*>(savepoint);
ut_ad(slot->object == block);
...
...
@@ -160,8 +149,8 @@ mtr_t::x_latch_at_savepoint(
rw_lock_x_lock(&block->lock);
if (!m_
impl.m_
made_dirty) {
m_
impl.m_
made_dirty = is_block_dirtied(block);
if (!m_made_dirty) {
m_made_dirty = is_block_dirtied(block);
}
slot->type = MTR_MEMO_PAGE_X_FIX;
...
...
@@ -176,11 +165,8 @@ mtr_t::release_block_at_savepoint(
buf_block_t* block)
{
ut_ad(is_active());
ut_ad(m_impl.m_magic_n == MTR_MAGIC_N);
mtr_memo_slot_t* slot;
slot = m_impl.
m_memo.at<mtr_memo_slot_t*>(savepoint);
mtr_memo_slot_t* slot =
m_memo.at<mtr_memo_slot_t*>(savepoint);
ut_a(slot->object == block);
...
...
@@ -198,10 +184,10 @@ Gets the logging mode of a mini-transaction.
mtr_log_t
mtr_t::get_log_mode() const
{
ut_ad(m_
impl.m_
log_mode >= MTR_LOG_ALL);
ut_ad(m_
impl.m_
log_mode <= MTR_LOG_SHORT_INSERTS);
ut_ad(m_log_mode >= MTR_LOG_ALL);
ut_ad(m_log_mode <= MTR_LOG_SHORT_INSERTS);
return
(m_impl.m_log_mode)
;
return
m_log_mode
;
}
/**
...
...
@@ -214,7 +200,7 @@ mtr_t::set_log_mode(mtr_log_t mode)
ut_ad(mode >= MTR_LOG_ALL);
ut_ad(mode <= MTR_LOG_SHORT_INSERTS);
const mtr_log_t old_mode = m_
impl.m_
log_mode;
const mtr_log_t old_mode = m_log_mode;
switch (old_mode) {
case MTR_LOG_NO_REDO:
...
...
@@ -233,9 +219,8 @@ mtr_t::set_log_mode(mtr_log_t mode)
case MTR_LOG_ALL:
/* MTR_LOG_NO_REDO can only be set before generating
any redo log records. */
ut_ad(mode != MTR_LOG_NO_REDO
|| m_impl.m_n_log_recs == 0);
m_impl.m_log_mode = mode;
ut_ad(mode != MTR_LOG_NO_REDO || m_n_log_recs == 0);
m_log_mode = mode;
return(old_mode);
}
...
...
storage/innobase/include/mtr0types.h
View file @
33cb10d4
...
...
@@ -36,18 +36,18 @@ struct mtr_t;
/** Logging modes for a mini-transaction */
enum
mtr_log_t
{
/** Default mode: log all operations modifying disk-based data */
MTR_LOG_ALL
=
21
,
MTR_LOG_ALL
=
0
,
/** Log no operations and dirty pages are not added to the flush list.
Set when applying log in crash recovery or when a modification of a
ROW_FORMAT=COMPRESSED page is attempted. */
MTR_LOG_NONE
=
22
,
MTR_LOG_NONE
,
/** Don't generate REDO log but add dirty pages to flush list */
MTR_LOG_NO_REDO
=
23
,
MTR_LOG_NO_REDO
,
/** Inserts are logged in a shorter form */
MTR_LOG_SHORT_INSERTS
=
24
MTR_LOG_SHORT_INSERTS
};
/** @name Log item types
...
...
@@ -278,15 +278,10 @@ enum mtr_memo_type_t {
};
#endif
/* !UNIV_CHECKSUM */
#ifdef UNIV_DEBUG
# define MTR_MAGIC_N 54551
#endif
/* UNIV_DEBUG */
enum
mtr_state_t
{
MTR_STATE_INIT
=
0
,
MTR_STATE_ACTIVE
=
12231
,
MTR_STATE_COMMITTING
=
56456
,
MTR_STATE_COMMITTED
=
34676
MTR_STATE_ACTIVE
,
MTR_STATE_COMMITTED
};
#endif
/* mtr0types_h */
storage/innobase/log/log0recv.cc
View file @
33cb10d4
...
...
@@ -27,7 +27,6 @@ Created 9/20/1997 Heikki Tuuri
#include "univ.i"
#include <vector>
#include <map>
#include <string>
#include <my_service_manager.h>
...
...
@@ -3894,32 +3893,25 @@ recv_recovery_rollback_active(void)
@param[in] page_no page number
@return page frame
@retval NULL if no page was found */
const
byte
*
recv_dblwr_t
::
find_page
(
ulint
space_id
,
ulint
page_no
)
{
std
::
vector
<
const
byte
*
,
ut_allocator
<
const
byte
*>
>
matches
;
const
byte
*
result
=
0
;
for
(
const
byte
*
page
:
pages
)
{
if
(
page_get_space_id
(
page
)
==
space_id
&&
page_get_page_no
(
page
)
==
page_no
)
{
matches
.
push_back
(
page
);
}
}
lsn_t
max_lsn
=
0
;
for
(
const
byte
*
page
:
matches
)
{
lsn_t
page_lsn
=
mach_read_from_8
(
page
+
FIL_PAGE_LSN
);
if
(
page_lsn
>
max_lsn
)
{
max_lsn
=
page_lsn
;
result
=
page
;
}
}
return
(
result
);
const
byte
*
result
=
NULL
;
lsn_t
max_lsn
=
0
;
for
(
const
byte
*
page
:
pages
)
{
if
(
page_get_page_no
(
page
)
!=
page_no
||
page_get_space_id
(
page
)
!=
space_id
)
continue
;
const
lsn_t
lsn
=
mach_read_from_8
(
page
+
FIL_PAGE_LSN
);
if
(
lsn
<=
max_lsn
)
continue
;
max_lsn
=
lsn
;
result
=
page
;
}
return
result
;
}
#ifndef DBUG_OFF
...
...
storage/innobase/mtr/mtr0mtr.cc
View file @
33cb10d4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment