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
ccdfcedf
Commit
ccdfcedf
authored
May 29, 2020
by
Sergey Vojtovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-22693 - InnoDB: get rid of casts for rw_trx_hash iterator
Less error prone, stricter type control.
parent
043828bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
45 deletions
+43
-45
storage/innobase/include/trx0sys.h
storage/innobase/include/trx0sys.h
+35
-26
storage/innobase/lock/lock0lock.cc
storage/innobase/lock/lock0lock.cc
+3
-9
storage/innobase/trx/trx0roll.cc
storage/innobase/trx/trx0roll.cc
+2
-4
storage/innobase/trx/trx0trx.cc
storage/innobase/trx/trx0trx.cc
+3
-6
No files found.
storage/innobase/include/trx0sys.h
View file @
ccdfcedf
...
@@ -385,6 +385,10 @@ class rw_trx_hash_t
...
@@ -385,6 +385,10 @@ class rw_trx_hash_t
LF_HASH
hash
;
LF_HASH
hash
;
template
<
typename
T
>
using
walk_action
=
my_bool
(
rw_trx_hash_element_t
*
element
,
T
*
action
);
/**
/**
Constructor callback for lock-free allocator.
Constructor callback for lock-free allocator.
...
@@ -487,18 +491,19 @@ class rw_trx_hash_t
...
@@ -487,18 +491,19 @@ class rw_trx_hash_t
}
}
struct
eliminate_duplicates_arg
template
<
typename
T
>
struct
eliminate_duplicates_arg
{
{
trx_ids_t
ids
;
trx_ids_t
ids
;
my_hash_walk_action
action
;
walk_action
<
T
>
*
action
;
void
*
argument
;
T
*
argument
;
eliminate_duplicates_arg
(
size_t
size
,
my_hash_walk_action
act
,
void
*
arg
)
:
eliminate_duplicates_arg
(
size_t
size
,
walk_action
<
T
>
*
act
,
T
*
arg
)
:
action
(
act
),
argument
(
arg
)
{
ids
.
reserve
(
size
);
}
action
(
act
),
argument
(
arg
)
{
ids
.
reserve
(
size
);
}
};
};
template
<
typename
T
>
static
my_bool
eliminate_duplicates
(
rw_trx_hash_element_t
*
element
,
static
my_bool
eliminate_duplicates
(
rw_trx_hash_element_t
*
element
,
eliminate_duplicates_arg
*
arg
)
eliminate_duplicates_arg
<
T
>
*
arg
)
{
{
for
(
trx_ids_t
::
iterator
it
=
arg
->
ids
.
begin
();
it
!=
arg
->
ids
.
end
();
it
++
)
for
(
trx_ids_t
::
iterator
it
=
arg
->
ids
.
begin
();
it
!=
arg
->
ids
.
end
();
it
++
)
{
{
...
@@ -525,15 +530,16 @@ class rw_trx_hash_t
...
@@ -525,15 +530,16 @@ class rw_trx_hash_t
}
}
struct
debug_iterator_arg
template
<
typename
T
>
struct
debug_iterator_arg
{
{
my_hash_walk_action
action
;
walk_action
<
T
>
*
action
;
void
*
argument
;
T
*
argument
;
};
};
template
<
typename
T
>
static
my_bool
debug_iterator
(
rw_trx_hash_element_t
*
element
,
static
my_bool
debug_iterator
(
rw_trx_hash_element_t
*
element
,
debug_iterator_arg
*
arg
)
debug_iterator_arg
<
T
>
*
arg
)
{
{
mutex_enter
(
&
element
->
mutex
);
mutex_enter
(
&
element
->
mutex
);
if
(
element
->
trx
)
if
(
element
->
trx
)
...
@@ -748,23 +754,28 @@ class rw_trx_hash_t
...
@@ -748,23 +754,28 @@ class rw_trx_hash_t
@retval 1 iteration was interrupted (action returned 1)
@retval 1 iteration was interrupted (action returned 1)
*/
*/
int
iterate
(
trx_t
*
caller_trx
,
my_hash_walk_action
action
,
void
*
argument
)
template
<
typename
T
>
int
iterate
(
trx_t
*
caller_trx
,
walk_action
<
T
>
*
action
,
T
*
argument
=
nullptr
)
{
{
LF_PINS
*
pins
=
caller_trx
?
get_pins
(
caller_trx
)
:
lf_hash_get_pins
(
&
hash
);
LF_PINS
*
pins
=
caller_trx
?
get_pins
(
caller_trx
)
:
lf_hash_get_pins
(
&
hash
);
ut_a
(
pins
);
ut_a
(
pins
);
#ifdef UNIV_DEBUG
#ifdef UNIV_DEBUG
debug_iterator_arg
debug_arg
=
{
action
,
argument
};
debug_iterator_arg
<
T
>
debug_arg
=
{
action
,
argument
};
action
=
reinterpret_cast
<
my_hash_walk_action
>
(
debug_iterator
);
action
=
reinterpret_cast
<
decltype
(
action
)
>
(
debug_iterator
<
T
>
);
argument
=
&
debug_arg
;
argument
=
reinterpret_cast
<
T
*>
(
&
debug_arg
)
;
#endif
#endif
int
res
=
lf_hash_iterate
(
&
hash
,
pins
,
action
,
argument
);
int
res
=
lf_hash_iterate
(
&
hash
,
pins
,
reinterpret_cast
<
my_hash_walk_action
>
(
action
),
const_cast
<
void
*>
(
static_cast
<
const
void
*>
(
argument
)));
if
(
!
caller_trx
)
if
(
!
caller_trx
)
lf_hash_put_pins
(
pins
);
lf_hash_put_pins
(
pins
);
return
res
;
return
res
;
}
}
int
iterate
(
my_hash_walk_action
action
,
void
*
argument
)
template
<
typename
T
>
int
iterate
(
walk_action
<
T
>
*
action
,
T
*
argument
=
nullptr
)
{
{
return
iterate
(
current_trx
(),
action
,
argument
);
return
iterate
(
current_trx
(),
action
,
argument
);
}
}
...
@@ -776,16 +787,17 @@ class rw_trx_hash_t
...
@@ -776,16 +787,17 @@ class rw_trx_hash_t
@sa iterate()
@sa iterate()
*/
*/
int
iterate_no_dups
(
trx_t
*
caller_trx
,
my_hash_walk_action
action
,
template
<
typename
T
>
void
*
argument
)
int
iterate_no_dups
(
trx_t
*
caller_trx
,
walk_action
<
T
>
*
action
,
T
*
argument
=
nullptr
)
{
{
eliminate_duplicates_arg
arg
(
size
()
+
32
,
action
,
argument
);
eliminate_duplicates_arg
<
T
>
arg
(
size
()
+
32
,
action
,
argument
);
return
iterate
(
caller_trx
,
reinterpret_cast
<
my_hash_walk_action
>
return
iterate
(
caller_trx
,
eliminate_duplicates
<
T
>
,
&
arg
);
(
eliminate_duplicates
),
&
arg
);
}
}
int
iterate_no_dups
(
my_hash_walk_action
action
,
void
*
argument
)
template
<
typename
T
>
int
iterate_no_dups
(
walk_action
<
T
>
*
action
,
T
*
argument
=
nullptr
)
{
{
return
iterate_no_dups
(
current_trx
(),
action
,
argument
);
return
iterate_no_dups
(
current_trx
(),
action
,
argument
);
}
}
...
@@ -881,8 +893,7 @@ class trx_sys_t
...
@@ -881,8 +893,7 @@ class trx_sys_t
trx_id_t
get_min_trx_id
()
trx_id_t
get_min_trx_id
()
{
{
trx_id_t
id
=
get_max_trx_id
();
trx_id_t
id
=
get_max_trx_id
();
rw_trx_hash
.
iterate
(
reinterpret_cast
<
my_hash_walk_action
>
rw_trx_hash
.
iterate
(
get_min_trx_id_callback
,
&
id
);
(
get_min_trx_id_callback
),
&
id
);
return
id
;
return
id
;
}
}
...
@@ -976,9 +987,7 @@ class trx_sys_t
...
@@ -976,9 +987,7 @@ class trx_sys_t
ids
->
clear
();
ids
->
clear
();
ids
->
reserve
(
rw_trx_hash
.
size
()
+
32
);
ids
->
reserve
(
rw_trx_hash
.
size
()
+
32
);
rw_trx_hash
.
iterate
(
caller_trx
,
rw_trx_hash
.
iterate
(
caller_trx
,
copy_one_id
,
&
arg
);
reinterpret_cast
<
my_hash_walk_action
>
(
copy_one_id
),
&
arg
);
*
max_trx_id
=
arg
.
m_id
;
*
max_trx_id
=
arg
.
m_id
;
*
min_trx_no
=
arg
.
m_no
;
*
min_trx_no
=
arg
.
m_no
;
...
...
storage/innobase/lock/lock0lock.cc
View file @
ccdfcedf
...
@@ -5157,8 +5157,7 @@ lock_validate()
...
@@ -5157,8 +5157,7 @@ lock_validate()
lock_mutex_enter
();
lock_mutex_enter
();
/* Validate table locks */
/* Validate table locks */
trx_sys
.
rw_trx_hash
.
iterate
(
reinterpret_cast
<
my_hash_walk_action
>
trx_sys
.
rw_trx_hash
.
iterate
(
lock_validate_table_locks
);
(
lock_validate_table_locks
),
0
);
/* Iterate over all the record locks and validate the locks. We
/* Iterate over all the record locks and validate the locks. We
don't want to hog the lock_sys_t::mutex. Release it during the
don't want to hog the lock_sys_t::mutex. Release it during the
...
@@ -5452,9 +5451,7 @@ static void lock_rec_other_trx_holds_expl(trx_t *caller_trx, trx_t *trx,
...
@@ -5452,9 +5451,7 @@ static void lock_rec_other_trx_holds_expl(trx_t *caller_trx, trx_t *trx,
lock_rec_other_trx_holds_expl_arg
arg
=
{
page_rec_get_heap_no
(
rec
),
block
,
lock_rec_other_trx_holds_expl_arg
arg
=
{
page_rec_get_heap_no
(
rec
),
block
,
trx
};
trx
};
trx_sys
.
rw_trx_hash
.
iterate
(
caller_trx
,
trx_sys
.
rw_trx_hash
.
iterate
(
caller_trx
,
reinterpret_cast
<
my_hash_walk_action
>
lock_rec_other_trx_holds_expl_callback
,
&
arg
);
(
lock_rec_other_trx_holds_expl_callback
),
&
arg
);
lock_mutex_exit
();
lock_mutex_exit
();
}
}
}
}
...
@@ -6233,10 +6230,7 @@ lock_table_has_locks(
...
@@ -6233,10 +6230,7 @@ lock_table_has_locks(
#ifdef UNIV_DEBUG
#ifdef UNIV_DEBUG
if
(
!
has_locks
)
{
if
(
!
has_locks
)
{
trx_sys
.
rw_trx_hash
.
iterate
(
trx_sys
.
rw_trx_hash
.
iterate
(
lock_table_locks_lookup
,
table
);
reinterpret_cast
<
my_hash_walk_action
>
(
lock_table_locks_lookup
),
const_cast
<
dict_table_t
*>
(
table
));
}
}
#endif
/* UNIV_DEBUG */
#endif
/* UNIV_DEBUG */
...
...
storage/innobase/trx/trx0roll.cc
View file @
ccdfcedf
...
@@ -717,8 +717,7 @@ void trx_roll_report_progress()
...
@@ -717,8 +717,7 @@ void trx_roll_report_progress()
rows they modified. Numbers must be accurate, because only this
rows they modified. Numbers must be accurate, because only this
thread is allowed to touch recovered transactions. */
thread is allowed to touch recovered transactions. */
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
reinterpret_cast
<
my_hash_walk_action
>
trx_roll_count_callback
,
&
arg
);
(
trx_roll_count_callback
),
&
arg
);
if
(
arg
.
n_rows
>
0
)
{
if
(
arg
.
n_rows
>
0
)
{
service_manager_extend_timeout
(
service_manager_extend_timeout
(
...
@@ -776,8 +775,7 @@ void trx_rollback_recovered(bool all)
...
@@ -776,8 +775,7 @@ void trx_rollback_recovered(bool all)
other thread is allowed to modify or remove these transactions from
other thread is allowed to modify or remove these transactions from
rw_trx_hash.
rw_trx_hash.
*/
*/
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
reinterpret_cast
<
my_hash_walk_action
>
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
trx_rollback_recovered_callback
,
(
trx_rollback_recovered_callback
),
&
trx_list
);
&
trx_list
);
while
(
!
trx_list
.
empty
())
while
(
!
trx_list
.
empty
())
...
...
storage/innobase/trx/trx0trx.cc
View file @
ccdfcedf
...
@@ -2135,8 +2135,7 @@ int trx_recover_for_mysql(XID *xid_list, uint len)
...
@@ -2135,8 +2135,7 @@ int trx_recover_for_mysql(XID *xid_list, uint len)
ut_ad
(
len
);
ut_ad
(
len
);
/* Fill xid_list with PREPARED transactions. */
/* Fill xid_list with PREPARED transactions. */
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
reinterpret_cast
<
my_hash_walk_action
>
trx_sys
.
rw_trx_hash
.
iterate_no_dups
(
trx_recover_for_mysql_callback
,
&
arg
);
(
trx_recover_for_mysql_callback
),
&
arg
);
if
(
arg
.
count
)
if
(
arg
.
count
)
{
{
ib
::
info
()
<<
arg
.
count
ib
::
info
()
<<
arg
.
count
...
@@ -2146,8 +2145,7 @@ int trx_recover_for_mysql(XID *xid_list, uint len)
...
@@ -2146,8 +2145,7 @@ int trx_recover_for_mysql(XID *xid_list, uint len)
transactions twice, by first calling tc_log->open() and then
transactions twice, by first calling tc_log->open() and then
ha_recover() directly. */
ha_recover() directly. */
if
(
arg
.
count
<=
len
)
if
(
arg
.
count
<=
len
)
trx_sys
.
rw_trx_hash
.
iterate
(
reinterpret_cast
<
my_hash_walk_action
>
trx_sys
.
rw_trx_hash
.
iterate
(
trx_recover_reset_callback
);
(
trx_recover_reset_callback
),
NULL
);
}
}
return
int
(
std
::
min
(
arg
.
count
,
len
));
return
int
(
std
::
min
(
arg
.
count
,
len
));
}
}
...
@@ -2201,8 +2199,7 @@ trx_t* trx_get_trx_by_xid(const XID* xid)
...
@@ -2201,8 +2199,7 @@ trx_t* trx_get_trx_by_xid(const XID* xid)
trx_get_trx_by_xid_callback_arg
arg
=
{
xid
,
0
};
trx_get_trx_by_xid_callback_arg
arg
=
{
xid
,
0
};
if
(
xid
)
if
(
xid
)
trx_sys
.
rw_trx_hash
.
iterate
(
reinterpret_cast
<
my_hash_walk_action
>
trx_sys
.
rw_trx_hash
.
iterate
(
trx_get_trx_by_xid_callback
,
&
arg
);
(
trx_get_trx_by_xid_callback
),
&
arg
);
return
arg
.
trx
;
return
arg
.
trx
;
}
}
...
...
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