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
8311eae6
Commit
8311eae6
authored
Sep 22, 2023
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
online alter: use thd->ha_data to store cache_list
parent
cb521746
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
16 deletions
+40
-16
sql/online_alter.cc
sql/online_alter.cc
+40
-14
sql/sql_class.h
sql/sql_class.h
+0
-2
No files found.
sql/online_alter.cc
View file @
8311eae6
...
...
@@ -24,6 +24,7 @@
static
handlerton
*
online_alter_hton
;
typedef
ilist
<
online_alter_cache_data
>
Online_alter_cache_list
;
class
online_alter_cache_data
:
public
Sql_alloc
,
public
ilist_node
<>
,
public
binlog_cache_data
...
...
@@ -68,12 +69,31 @@ online_alter_cache_data *setup_cache_data(MEM_ROOT *root, TABLE_SHARE *share)
}
static
online_alter_cache_data
*
get_cache_data
(
THD
*
thd
,
TABLE
*
table
)
static
Online_alter_cache_list
&
get_cache_list
(
handlerton
*
ht
,
THD
*
thd
)
{
ilist
<
online_alter_cache_data
>
&
list
=
thd
->
online_alter_cache_list
;
void
*
data
=
thd_get_ha_data
(
thd
,
ht
);
DBUG_ASSERT
(
data
);
return
*
(
Online_alter_cache_list
*
)
data
;
}
static
Online_alter_cache_list
&
get_or_create_cache_list
(
THD
*
thd
)
{
void
*
data
=
thd_get_ha_data
(
thd
,
online_alter_hton
);
if
(
!
data
)
{
data
=
new
Online_alter_cache_list
();
thd_set_ha_data
(
thd
,
online_alter_hton
,
data
);
}
return
*
(
Online_alter_cache_list
*
)
data
;
}
static
online_alter_cache_data
*
get_cache_data
(
THD
*
thd
,
TABLE
*
table
)
{
auto
&
cache_list
=
get_or_create_cache_list
(
thd
);
/* we assume it's very rare to have more than one online ALTER running */
for
(
auto
&
cache
:
list
)
for
(
auto
&
cache
:
cache_
list
)
{
if
(
cache
.
sink_log
==
table
->
s
->
online_alter_binlog
)
return
&
cache
;
...
...
@@ -81,7 +101,7 @@ static online_alter_cache_data *get_cache_data(THD *thd, TABLE *table)
MEM_ROOT
*
root
=
&
thd
->
transaction
->
mem_root
;
auto
*
new_cache_data
=
setup_cache_data
(
root
,
table
->
s
);
list
.
push_back
(
*
new_cache_data
);
cache_
list
.
push_back
(
*
new_cache_data
);
return
new_cache_data
;
}
...
...
@@ -148,12 +168,13 @@ int online_alter_end_trans(handlerton *hton, THD *thd, bool all, bool commit)
{
DBUG_ENTER
(
"online_alter_end_trans"
);
int
error
=
0
;
if
(
thd
->
online_alter_cache_list
.
empty
())
auto
&
cache_list
=
get_cache_list
(
hton
,
thd
);
if
(
cache_list
.
empty
())
DBUG_RETURN
(
0
);
bool
is_ending_transaction
=
ending_trans
(
thd
,
all
);
for
(
auto
&
cache
:
thd
->
online_alter_
cache_list
)
for
(
auto
&
cache
:
cache_list
)
{
auto
*
binlog
=
cache
.
sink_log
;
DBUG_ASSERT
(
binlog
);
...
...
@@ -197,14 +218,12 @@ int online_alter_end_trans(handlerton *hton, THD *thd, bool all, bool commit)
{
my_error
(
ER_ERROR_ON_WRITE
,
MYF
(
ME_ERROR_LOG
),
binlog
->
get_name
(),
errno
);
cleanup_cache_list
(
thd
->
online_alter_cache_list
,
is_ending_transaction
);
cleanup_cache_list
(
cache_list
,
is_ending_transaction
);
DBUG_RETURN
(
error
);
}
}
cleanup_cache_list
(
thd
->
online_alter_cache_list
,
is_ending_transaction
);
cleanup_cache_list
(
cache_list
,
is_ending_transaction
);
for
(
TABLE
*
table
=
thd
->
open_tables
;
table
;
table
=
table
->
next
)
table
->
online_alter_cache
=
NULL
;
...
...
@@ -220,13 +239,14 @@ SAVEPOINT* savepoint_add(THD *thd, LEX_CSTRING name, SAVEPOINT **list,
int
online_alter_savepoint_set
(
THD
*
thd
,
LEX_CSTRING
name
)
{
DBUG_ENTER
(
"binlog_online_alter_savepoint"
);
if
(
thd
->
online_alter_cache_list
.
empty
())
auto
&
cache_list
=
get_cache_list
(
online_alter_hton
,
thd
);
if
(
cache_list
.
empty
())
DBUG_RETURN
(
0
);
if
(
savepoint_alloc_size
<
sizeof
(
SAVEPOINT
)
+
sizeof
(
my_off_t
))
savepoint_alloc_size
=
sizeof
(
SAVEPOINT
)
+
sizeof
(
my_off_t
);
for
(
auto
&
cache
:
thd
->
online_alter_
cache_list
)
for
(
auto
&
cache
:
cache_list
)
{
if
(
cache
.
hton
->
savepoint_set
==
NULL
)
continue
;
...
...
@@ -246,7 +266,9 @@ int online_alter_savepoint_set(THD *thd, LEX_CSTRING name)
int
online_alter_savepoint_rollback
(
THD
*
thd
,
LEX_CSTRING
name
)
{
DBUG_ENTER
(
"online_alter_savepoint_rollback"
);
for
(
auto
&
cache
:
thd
->
online_alter_cache_list
)
auto
&
cache_list
=
get_cache_list
(
online_alter_hton
,
thd
);
for
(
auto
&
cache
:
cache_list
)
{
if
(
cache
.
hton
->
savepoint_set
==
NULL
)
continue
;
...
...
@@ -264,7 +286,11 @@ int online_alter_savepoint_rollback(THD *thd, LEX_CSTRING name)
static
int
online_alter_close_connection
(
handlerton
*
hton
,
THD
*
thd
)
{
DBUG_ASSERT
(
thd
->
online_alter_cache_list
.
empty
());
auto
*
cache_list
=
(
Online_alter_cache_list
*
)
thd_get_ha_data
(
thd
,
hton
);
DBUG_ASSERT
(
!
cache_list
||
cache_list
->
empty
());
delete
cache_list
;
thd_set_ha_data
(
thd
,
hton
,
NULL
);
return
0
;
}
...
...
sql/sql_class.h
View file @
8311eae6
...
...
@@ -5634,8 +5634,6 @@ 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
<
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
);
...
...
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