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
64b55151
Commit
64b55151
authored
Jun 29, 2022
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate online_alter_cache_data from binlog_cache_data
parent
e358d5ee
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
58 deletions
+60
-58
sql/handler.cc
sql/handler.cc
+0
-33
sql/handler.h
sql/handler.h
+1
-0
sql/log.cc
sql/log.cc
+54
-22
sql/log.h
sql/log.h
+3
-1
sql/sql_class.h
sql/sql_class.h
+1
-1
sql/table.h
sql/table.h
+1
-1
No files found.
sql/handler.cc
View file @
64b55151
...
...
@@ -7243,39 +7243,6 @@ bool handler::check_table_binlog_row_based_internal()
mysql_bin_log
.
is_open
()));
}
#ifdef HAVE_REPLICATION
static
int
binlog_log_row_online_alter
(
TABLE
*
table
,
const
uchar
*
before_record
,
const
uchar
*
after_record
,
Log_func
*
log_func
)
{
THD
*
thd
=
table
->
in_use
;
if
(
!
table
->
online_alter_cache
)
{
table
->
online_alter_cache
=
online_alter_binlog_get_cache_data
(
thd
,
table
);
trans_register_ha
(
thd
,
false
,
binlog_hton
,
0
);
if
(
thd
->
in_multi_stmt_transaction_mode
())
trans_register_ha
(
thd
,
true
,
binlog_hton
,
0
);
}
// We need to log all columns for the case if alter table changes primary key
DBUG_ASSERT
(
!
before_record
||
bitmap_is_set_all
(
table
->
read_set
));
MY_BITMAP
*
old_rpl_write_set
=
table
->
rpl_write_set
;
table
->
rpl_write_set
=
&
table
->
s
->
all_set
;
int
error
=
(
*
log_func
)(
thd
,
table
,
table
->
s
->
online_alter_binlog
,
table
->
online_alter_cache
,
true
,
before_record
,
after_record
);
table
->
rpl_write_set
=
old_rpl_write_set
;
return
unlikely
(
error
)
?
HA_ERR_RBR_LOGGING_FAILED
:
0
;
}
#endif // HAVE_REPLICATION
static
int
binlog_log_row_to_binlog
(
TABLE
*
table
,
const
uchar
*
before_record
,
const
uchar
*
after_record
,
...
...
sql/handler.h
View file @
64b55151
...
...
@@ -658,6 +658,7 @@ typedef ulonglong alter_table_operations;
class
Event_log
;
class
Cache_flip_event_log
;
class
binlog_cache_data
;
class
online_alter_cache_data
;
typedef
bool
Log_func
(
THD
*
,
TABLE
*
,
Event_log
*
,
binlog_cache_data
*
,
bool
,
const
uchar
*
,
const
uchar
*
);
...
...
sql/log.cc
View file @
64b55151
...
...
@@ -275,13 +275,11 @@ void make_default_log_name(char **out, const char* log_ext, bool once)
Helper classes to store non-transactional and transactional data
before copying it to the binary log.
*/
class
binlog_cache_data
:
public
Sql_alloc
,
public
ilist_node
<>
class
binlog_cache_data
{
public:
binlog_cache_data
()
:
share
(
0
),
sv_list
(
0
),
m_pending
(
0
),
status
(
0
),
before_stmt_pos
(
MY_OFF_T_UNDEF
),
incident
(
FALSE
),
saved_max_binlog_cache_size
(
0
),
ptr_binlog_cache_use
(
0
),
binlog_cache_data
()
:
before_stmt_pos
(
MY_OFF_T_UNDEF
),
m_pending
(
0
),
status
(
0
),
incident
(
FALSE
),
saved_max_binlog_cache_size
(
0
),
ptr_binlog_cache_use
(
0
),
ptr_binlog_cache_disk_use
(
0
)
{
}
...
...
@@ -361,11 +359,6 @@ class binlog_cache_data: public Sql_alloc, public ilist_node<>
before_stmt_pos
=
pos
;
}
void
store_prev_position
()
{
before_stmt_pos
=
my_b_write_tell
(
&
cache_log
);
}
void
restore_prev_position
()
{
truncate
(
before_stmt_pos
);
...
...
@@ -418,8 +411,12 @@ class binlog_cache_data: public Sql_alloc, public ilist_node<>
*/
IO_CACHE
cache_log
;
TABLE_SHARE
*
share
;
// for online alter table
SAVEPOINT
*
sv_list
;
protected:
/*
Binlog position before the start of the current statement.
*/
my_off_t
before_stmt_pos
;
private:
/*
Pending binrows event. This event is the event where the rows are currently
...
...
@@ -434,11 +431,6 @@ class binlog_cache_data: public Sql_alloc, public ilist_node<>
*/
uint32
status
;
/*
Binlog position before the start of the current statement.
*/
my_off_t
before_stmt_pos
;
/*
This indicates that some events did not get into the cache and most likely
it is corrupted.
...
...
@@ -506,6 +498,19 @@ class binlog_cache_data: public Sql_alloc, public ilist_node<>
};
class
online_alter_cache_data
:
public
Sql_alloc
,
public
ilist_node
<>
,
public
binlog_cache_data
{
public:
void
store_prev_position
()
{
before_stmt_pos
=
my_b_write_tell
(
&
cache_log
);
}
TABLE_SHARE
*
share
;
SAVEPOINT
*
sv_list
;
};
void
Log_event_writer
::
add_status
(
enum_logged_status
status
)
{
if
(
likely
(
cache_data
))
...
...
@@ -2261,8 +2266,35 @@ static int binlog_commit_flush_xa_prepare(THD *thd, bool all,
}
#ifdef HAVE_REPLICATION
int
binlog_log_row_online_alter
(
TABLE
*
table
,
const
uchar
*
before_record
,
const
uchar
*
after_record
,
Log_func
*
log_func
)
{
THD
*
thd
=
table
->
in_use
;
if
(
!
table
->
online_alter_cache
)
{
table
->
online_alter_cache
=
online_alter_binlog_get_cache_data
(
thd
,
table
);
trans_register_ha
(
thd
,
false
,
binlog_hton
,
0
);
if
(
thd
->
in_multi_stmt_transaction_mode
())
trans_register_ha
(
thd
,
true
,
binlog_hton
,
0
);
}
// We need to log all columns for the case if alter table changes primary key
DBUG_ASSERT
(
!
before_record
||
bitmap_is_set_all
(
table
->
read_set
));
MY_BITMAP
*
old_rpl_write_set
=
table
->
rpl_write_set
;
table
->
rpl_write_set
=
&
table
->
s
->
all_set
;
int
error
=
(
*
log_func
)(
thd
,
table
,
table
->
s
->
online_alter_binlog
,
table
->
online_alter_cache
,
true
,
before_record
,
after_record
);
table
->
rpl_write_set
=
old_rpl_write_set
;
return
unlikely
(
error
)
?
HA_ERR_RBR_LOGGING_FAILED
:
0
;
}
static
void
binlog_online_alter_cleanup
(
ilist
<
binlog
_cache_data
>
&
list
,
bool
ending_trans
)
binlog_online_alter_cleanup
(
ilist
<
online_alter
_cache_data
>
&
list
,
bool
ending_trans
)
{
if
(
ending_trans
)
{
...
...
@@ -6382,9 +6414,9 @@ bool MYSQL_BIN_LOG::write_table_map(THD *thd, TABLE *table, bool with_annotate)
#ifdef HAVE_REPLICATION
static
binlog
_cache_data
*
binlog_setup_cache_data
(
MEM_ROOT
*
root
,
TABLE_SHARE
*
share
)
static
online_alter
_cache_data
*
binlog_setup_cache_data
(
MEM_ROOT
*
root
,
TABLE_SHARE
*
share
)
{
auto
cache
=
new
(
root
)
binlog
_cache_data
();
auto
cache
=
new
(
root
)
online_alter
_cache_data
();
if
(
!
cache
||
open_cached_file
(
&
cache
->
cache_log
,
mysql_tmpdir
,
LOG_PREFIX
,
(
size_t
)
binlog_cache_size
,
MYF
(
MY_WME
)))
{
...
...
@@ -6399,9 +6431,9 @@ static binlog_cache_data *binlog_setup_cache_data(MEM_ROOT *root, TABLE_SHARE *s
return
cache
;
}
binlog
_cache_data
*
online_alter_binlog_get_cache_data
(
THD
*
thd
,
TABLE
*
table
)
online_alter
_cache_data
*
online_alter_binlog_get_cache_data
(
THD
*
thd
,
TABLE
*
table
)
{
ilist
<
binlog
_cache_data
>
&
list
=
thd
->
online_alter_cache_list
;
ilist
<
online_alter
_cache_data
>
&
list
=
thd
->
online_alter_cache_list
;
/* we assume it's very rare to have more than one online ALTER running */
for
(
auto
&
cache
:
list
)
...
...
sql/log.h
View file @
64b55151
...
...
@@ -1320,7 +1320,9 @@ int binlog_flush_pending_rows_event(THD *thd, bool stmt_end,
binlog_cache_data
*
cache_data
);
Rows_log_event
*
binlog_get_pending_rows_event
(
binlog_cache_mngr
*
cache_mngr
,
bool
use_trans_cache
);
binlog_cache_data
*
online_alter_binlog_get_cache_data
(
THD
*
thd
,
TABLE
*
table
);
int
binlog_log_row_online_alter
(
TABLE
*
table
,
const
uchar
*
before_record
,
const
uchar
*
after_record
,
Log_func
*
log_func
);
online_alter_cache_data
*
online_alter_binlog_get_cache_data
(
THD
*
thd
,
TABLE
*
table
);
binlog_cache_data
*
binlog_get_cache_data
(
binlog_cache_mngr
*
cache_mngr
,
bool
use_trans_cache
);
...
...
sql/sql_class.h
View file @
64b55151
...
...
@@ -5556,7 +5556,7 @@ class THD: public THD_count, /* this must be first */
Item
*
sp_prepare_func_item
(
Item
**
it_addr
,
uint
cols
);
bool
sp_eval_expr
(
Field
*
result_field
,
Item
**
expr_item_ptr
);
ilist
<
binlog
_cache_data
>
online_alter_cache_list
;
ilist
<
online_alter
_cache_data
>
online_alter_cache_list
;
bool
sql_parser
(
LEX
*
old_lex
,
LEX
*
lex
,
char
*
str
,
uint
str_len
,
bool
stmt_prepare_mode
);
...
...
sql/table.h
View file @
64b55151
...
...
@@ -1630,7 +1630,7 @@ struct TABLE
*/
Item
*
notnull_cond
;
binlog
_cache_data
*
online_alter_cache
;
online_alter
_cache_data
*
online_alter_cache
;
inline
void
reset
()
{
bzero
((
void
*
)
this
,
sizeof
(
*
this
));
}
void
init
(
THD
*
thd
,
TABLE_LIST
*
tl
);
...
...
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