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
3329f0ed
Commit
3329f0ed
authored
Jan 26, 2021
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: Remove LOCK_REC (which was mutually exclusive with LOCK_TABLE)
parent
b32f057d
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
143 additions
and
281 deletions
+143
-281
storage/innobase/include/lock0lock.h
storage/innobase/include/lock0lock.h
+2
-5
storage/innobase/include/lock0lock.ic
storage/innobase/include/lock0lock.ic
+1
-3
storage/innobase/include/lock0priv.h
storage/innobase/include/lock0priv.h
+4
-13
storage/innobase/include/lock0priv.ic
storage/innobase/include/lock0priv.ic
+7
-23
storage/innobase/include/lock0types.h
storage/innobase/include/lock0types.h
+4
-27
storage/innobase/lock/lock0iter.cc
storage/innobase/lock/lock0iter.cc
+22
-42
storage/innobase/lock/lock0lock.cc
storage/innobase/lock/lock0lock.cc
+88
-135
storage/innobase/lock/lock0prdt.cc
storage/innobase/lock/lock0prdt.cc
+3
-6
storage/innobase/lock/lock0wait.cc
storage/innobase/lock/lock0wait.cc
+1
-1
storage/innobase/trx/trx0i_s.cc
storage/innobase/trx/trx0i_s.cc
+11
-26
No files found.
storage/innobase/include/lock0lock.h
View file @
3329f0ed
...
...
@@ -793,9 +793,7 @@ lock_rec_create(
lock_t
*
c_lock
,
/*!< conflicting lock */
que_thr_t
*
thr
,
/*!< thread owning trx */
#endif
unsigned
type_mode
,
/*!< in: lock mode and wait
flag, type is ignored and
replaced by LOCK_REC */
unsigned
type_mode
,
/*!< in: lock mode and wait flag */
const
buf_block_t
*
block
,
/*!< in: buffer block containing
the record */
ulint
heap_no
,
/*!< in: heap number of the record */
...
...
@@ -816,8 +814,7 @@ lock_rec_discard(
/** Create a new record lock and inserts it to the lock queue,
without checking for deadlocks or conflicts.
@param[in] type_mode lock mode and wait flag; type will be replaced
with LOCK_REC
@param[in] type_mode lock mode and wait flag
@param[in] page_id index page number
@param[in] page R-tree index page, or NULL
@param[in] heap_no record heap number in the index page
...
...
storage/innobase/include/lock0lock.ic
View file @
3329f0ed
...
...
@@ -81,9 +81,7 @@ lock_rec_create(
lock_t* c_lock, /*!< conflicting lock */
que_thr_t* thr, /*!< thread owning trx */
#endif
unsigned type_mode,/*!< in: lock mode and wait
flag, type is ignored and
replaced by LOCK_REC */
unsigned type_mode,/*!< in: lock mode and wait flag */
const buf_block_t* block, /*!< in: buffer block containing
the record */
ulint heap_no,/*!< in: heap number of the record */
...
...
storage/innobase/include/lock0priv.h
View file @
3329f0ed
...
...
@@ -95,10 +95,10 @@ ib_lock_t::print(std::ostream& out) const
out
<<
")"
;
if
(
is_record_lock
())
out
<<
un_member
.
rec_lock
;
else
if
(
is_table
())
out
<<
un_member
.
tab_lock
;
else
out
<<
un_member
.
rec_lock
;
out
<<
"]"
;
return
out
;
...
...
@@ -410,15 +410,6 @@ enum lock_rec_req_status {
static
const
ulint
lock_types
=
UT_ARR_SIZE
(
lock_compatibility_matrix
);
#endif
/* UNIV_DEBUG */
/*********************************************************************//**
Gets the type of a lock.
@return LOCK_TABLE or LOCK_REC */
UNIV_INLINE
ulint
lock_get_type_low
(
/*==============*/
const
lock_t
*
lock
);
/*!< in: lock */
/*********************************************************************//**
Gets the previous record lock set on a record.
@return previous lock on the same record, NULL if none exists */
...
...
@@ -492,8 +483,8 @@ lock_rec_set_nth_bit(
@return previous value of the bit */
inline
byte
lock_rec_reset_nth_bit
(
lock_t
*
lock
,
ulint
i
)
{
ut_ad
(
!
lock
->
is_table
());
lock_sys
.
mutex_assert_locked
();
ut_ad
(
lock_get_type_low
(
lock
)
==
LOCK_REC
);
ut_ad
(
i
<
lock
->
un_member
.
rec_lock
.
n_bits
);
byte
*
b
=
reinterpret_cast
<
byte
*>
(
&
lock
[
1
])
+
(
i
>>
3
);
...
...
storage/innobase/include/lock0priv.ic
View file @
3329f0ed
...
...
@@ -35,20 +35,6 @@ methods but they are used only in that file. */
#include "row0row.h"
/*********************************************************************//**
Gets the type of a lock.
@return LOCK_TABLE or LOCK_REC */
UNIV_INLINE
ulint
lock_get_type_low
(
/*==============*/
const
lock_t
*
lock
)
/*!< in: lock */
{
ut_ad
(
lock
);
return
(
lock
->
type_mode
&
LOCK_TYPE_MASK
);
}
/*********************************************************************//**
Checks if some transaction has an implicit x-lock on a record in a clustered
index.
...
...
@@ -91,9 +77,8 @@ lock_rec_set_nth_bit(
ulint
byte_index
;
ulint
bit_index
;
ut_ad
(
!
lock
->
is_table
());
lock_sys
.
mutex_assert_locked
();
ut_ad
(
lock
);
ut_ad
(
lock_get_type_low
(
lock
)
==
LOCK_REC
);
ut_ad
(
i
<
lock
->
un_member
.
rec_lock
.
n_bits
);
byte_index
=
i
/
8
;
...
...
@@ -135,7 +120,7 @@ lock_rec_get_next(
lock_sys
.
mutex_assert_locked
();
do
{
ut_ad
(
lock_get_type_low
(
lock
)
==
LOCK_REC
);
ut_ad
(
!
lock
->
is_table
()
);
lock
=
lock_rec_get_next_on_page
(
lock
);
}
while
(
lock
&&
!
lock_rec_get_nth_bit
(
lock
,
heap_no
));
...
...
@@ -185,8 +170,7 @@ lock_rec_get_nth_bit(
{
const
byte
*
b
;
ut_ad
(
lock
);
ut_ad
(
lock_get_type_low
(
lock
)
==
LOCK_REC
);
ut_ad
(
!
lock
->
is_table
());
if
(
i
>=
lock
->
un_member
.
rec_lock
.
n_bits
)
{
...
...
@@ -207,10 +191,10 @@ lock_rec_get_next_on_page_const(
/*============================*/
const
lock_t
*
lock
)
/*!< in: a record lock */
{
lock_sys
.
mutex_assert_locked
();
ut_ad
(
lock_get_type_low
(
lock
)
==
LOCK_REC
);
ut_ad
(
!
lock
->
is_table
());
const
page_id_t
page_id
(
lock
->
un_member
.
rec_lock
.
page_id
);
lock_sys
.
mutex_assert_locked
();
while
(
!!
(
lock
=
static_cast
<
const
lock_t
*>
(
HASH_GET_NEXT
(
hash
,
lock
))))
if
(
lock
->
un_member
.
rec_lock
.
page_id
==
page_id
)
...
...
@@ -304,8 +288,8 @@ lock_table_has(
lock_mode
mode
=
lock_get_mode
(
lock
);
ut_ad
(
trx
==
lock
->
trx
);
ut_ad
(
lock
_get_type_low
(
lock
)
&
LOCK_TABLE
);
ut_ad
(
lock
->
un_member
.
tab_lock
.
table
!=
NULL
);
ut_ad
(
lock
->
is_table
()
);
ut_ad
(
lock
->
un_member
.
tab_lock
.
table
);
if
(
table
==
lock
->
un_member
.
tab_lock
.
table
&&
lock_mode_stronger_or_eq
(
mode
,
in_mode
))
{
...
...
storage/innobase/include/lock0types.h
View file @
3329f0ed
...
...
@@ -99,13 +99,8 @@ operator<<(std::ostream& out, const lock_rec_t& lock)
type_mode field in a lock */
/** Lock types */
/* @{ */
#define LOCK_TABLE 16U
/*!< table lock */
#define LOCK_REC 32U
/*!< record lock */
#define LOCK_TYPE_MASK 0xF0UL
/*!< mask used to extract lock type from the
type_mode field in a lock */
#if LOCK_MODE_MASK & LOCK_TYPE_MASK
# error "LOCK_MODE_MASK & LOCK_TYPE_MASK"
#endif
/** table lock (record lock if the flag is not set) */
#define LOCK_TABLE 8U
#define LOCK_WAIT 256U
/*!< Waiting lock flag; when set, it
means that the lock has not yet been
...
...
@@ -184,13 +179,6 @@ struct ib_lock_t
LOCK_INSERT_INTENTION,
wait flag, ORed */
/** Determine if the lock object is a record lock.
@return true if record lock, false otherwise. */
bool
is_record_lock
()
const
{
return
(
type
()
==
LOCK_REC
);
}
bool
is_waiting
()
const
{
return
(
type_mode
&
LOCK_WAIT
);
...
...
@@ -211,9 +199,7 @@ struct ib_lock_t
return
(
type_mode
&
LOCK_INSERT_INTENTION
);
}
ulint
type
()
const
{
return
(
type_mode
&
LOCK_TYPE_MASK
);
}
bool
is_table
()
const
{
return
type_mode
&
LOCK_TABLE
;
}
enum
lock_mode
mode
()
const
{
...
...
@@ -226,16 +212,7 @@ struct ib_lock_t
std
::
ostream
&
print
(
std
::
ostream
&
out
)
const
;
const
char
*
type_string
()
const
{
switch
(
type_mode
&
LOCK_TYPE_MASK
)
{
case
LOCK_REC
:
return
(
"LOCK_REC"
);
case
LOCK_TABLE
:
return
(
"LOCK_TABLE"
);
default:
ut_error
;
}
}
{
return
is_table
()
?
"LOCK_TABLE"
:
"LOCK_REC"
;
}
};
typedef
UT_LIST_BASE_NODE_T
(
ib_lock_t
)
trx_lock_list_t
;
...
...
storage/innobase/lock/lock0iter.cc
View file @
3329f0ed
/*****************************************************************************
Copyright (c) 2007, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2020, MariaDB Corporation.
Copyright (c) 2020,
2021,
MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
...
...
@@ -49,27 +49,20 @@ lock_queue_iterator_reset(
ulint
bit_no
)
/*!< in: record number in the
heap */
{
lock_sys
.
mutex_assert_locked
();
iter
->
current_lock
=
lock
;
if
(
bit_no
!=
ULINT_UNDEFINED
)
{
iter
->
bit_no
=
bit_no
;
}
else
{
switch
(
lock_get_type_low
(
lock
))
{
case
LOCK_TABLE
:
iter
->
bit_no
=
ULINT_UNDEFINED
;
break
;
case
LOCK_REC
:
iter
->
bit_no
=
lock_rec_find_set_bit
(
lock
);
ut_a
(
iter
->
bit_no
!=
ULINT_UNDEFINED
);
break
;
default:
ut_error
;
}
}
lock_sys
.
mutex_assert_locked
();
iter
->
current_lock
=
lock
;
if
(
bit_no
!=
ULINT_UNDEFINED
);
else
if
(
lock
->
is_table
())
bit_no
=
ULINT_UNDEFINED
;
else
{
bit_no
=
lock_rec_find_set_bit
(
lock
);
ut_ad
(
bit_no
!=
ULINT_UNDEFINED
);
}
iter
->
bit_no
=
bit_no
;
}
/*******************************************************************//**
...
...
@@ -82,27 +75,14 @@ lock_queue_iterator_get_prev(
/*=========================*/
lock_queue_iterator_t
*
iter
)
/*!< in/out: iterator */
{
const
lock_t
*
prev_lock
;
lock_sys
.
mutex_assert_locked
();
switch
(
lock_get_type_low
(
iter
->
current_lock
))
{
case
LOCK_REC
:
prev_lock
=
lock_rec_get_prev
(
iter
->
current_lock
,
iter
->
bit_no
);
break
;
case
LOCK_TABLE
:
prev_lock
=
UT_LIST_GET_PREV
(
un_member
.
tab_lock
.
locks
,
iter
->
current_lock
);
break
;
default:
ut_error
;
}
lock_sys
.
mutex_assert_locked
();
if
(
prev_lock
!=
NULL
)
{
const
lock_t
*
prev_lock
=
!
iter
->
current_lock
->
is_table
()
?
lock_rec_get_prev
(
iter
->
current_lock
,
iter
->
bit_no
)
:
UT_LIST_GET_PREV
(
un_member
.
tab_lock
.
locks
,
iter
->
current_lock
);
iter
->
current_lock
=
prev_lock
;
}
if
(
prev_lock
)
iter
->
current_lock
=
prev_lock
;
return
(
prev_lock
)
;
return
prev_lock
;
}
storage/innobase/lock/lock0lock.cc
View file @
3329f0ed
This diff is collapsed.
Click to expand it.
storage/innobase/lock/lock0prdt.cc
View file @
3329f0ed
...
...
@@ -425,8 +425,7 @@ lock_t*
lock_prdt_add_to_queue
(
/*===================*/
unsigned
type_mode
,
/*!< in: lock mode, wait, predicate
etc. flags; type is ignored
and replaced by LOCK_REC */
etc. flags */
const
buf_block_t
*
block
,
/*!< in: buffer block containing
the record */
dict_index_t
*
index
,
/*!< in: index of record */
...
...
@@ -453,8 +452,6 @@ lock_prdt_add_to_queue(
}
#endif
/* UNIV_DEBUG */
type_mode
|=
LOCK_REC
;
/* Try to extend a similar non-waiting lock on the same page */
if
(
type_mode
&
LOCK_WAIT
)
{
goto
create
;
...
...
@@ -796,7 +793,7 @@ lock_prdt_lock(
}
else
{
if
(
lock_rec_get_next_on_page
(
lock
)
||
lock
->
trx
!=
trx
||
lock
->
type_mode
!=
(
LOCK_REC
|
prdt_mode
)
||
lock
->
type_mode
!=
prdt_mode
||
lock_rec_get_n_bits
(
lock
)
==
0
||
((
type_mode
&
LOCK_PREDICATE
)
&&
(
!
lock_prdt_consistent
(
...
...
@@ -885,7 +882,7 @@ lock_place_prdt_page_lock(
lock
=
lock_rec_get_next_on_page_const
(
lock
);
}
ut_ad
(
lock
==
NULL
||
lock
->
type_mode
==
(
mode
|
LOCK_REC
)
);
ut_ad
(
lock
==
NULL
||
lock
->
type_mode
==
mode
);
ut_ad
(
lock
==
NULL
||
lock_rec_get_n_bits
(
lock
)
!=
0
);
}
...
...
storage/innobase/lock/lock0wait.cc
View file @
3329f0ed
...
...
@@ -165,7 +165,7 @@ dberr_t lock_wait(que_thr_t *thr)
timespec
abstime
;
set_timespec_time_nsec
(
abstime
,
suspend_time
.
val
*
1000
);
abstime
.
MY_tv_sec
+=
innodb_lock_wait_timeout
;
thd_wait_begin
(
trx
->
mysql_thd
,
lock_get_type_low
(
wait_lock
)
==
LOCK_TABLE
thd_wait_begin
(
trx
->
mysql_thd
,
wait_lock
->
is_table
()
?
THD_WAIT_TABLE_LOCK
:
THD_WAIT_ROW_LOCK
);
while
(
trx
->
lock
.
wait_lock
)
{
...
...
storage/innobase/trx/trx0i_s.cc
View file @
3329f0ed
...
...
@@ -177,7 +177,7 @@ trx_i_s_cache_t* trx_i_s_cache = &trx_i_s_cache_static;
@retval 0xFFFF for table locks */
static
uint16_t
wait_lock_get_heap_no
(
const
lock_t
*
lock
)
{
return
lock_get_type
(
lock
)
==
LOCK_REC
return
!
lock
->
is_table
()
?
static_cast
<
uint16_t
>
(
lock_rec_find_set_bit
(
lock
))
:
uint16_t
{
0xFFFF
};
}
...
...
@@ -601,7 +601,7 @@ fill_lock_data(
trx_i_s_cache_t
*
cache
)
/*!< in/out: cache where to store
volatile data */
{
ut_a
(
lock_get_type
(
lock
)
==
LOCK_REC
);
ut_a
(
!
lock
->
is_table
()
);
switch
(
heap_no
)
{
case
PAGE_HEAP_NO_INFIMUM
:
...
...
@@ -705,12 +705,10 @@ static bool fill_locks_row(
volatile strings */
{
row
->
lock_trx_id
=
lock
->
trx
->
id
;
const
auto
lock_type
=
lock_get_type
(
lock
);
ut_ad
(
lock_type
==
LOCK_REC
||
lock_type
==
LOCK_TABLE
);
const
bool
is_gap_lock
=
lock_type
==
LOCK_REC
&&
(
lock
->
type_mode
&
LOCK_GAP
);
switch
(
lock
->
type_mode
&
LOCK_MODE_MASK
)
{
const
bool
is_table
=
lock
->
is_table
();
const
bool
is_gap_lock
=
lock
->
is_gap
();
ut_ad
(
!
is_gap_lock
||
!
is_table
);
switch
(
lock
->
mode
())
{
case
LOCK_S
:
row
->
lock_mode
=
uint8_t
(
1
+
is_gap_lock
);
break
;
...
...
@@ -741,7 +739,7 @@ static bool fill_locks_row(
return
false
;
}
if
(
lock_type
==
LOCK_REC
)
{
if
(
!
is_table
)
{
row
->
lock_index
=
ha_storage_put_str_memlim
(
cache
->
storage
,
lock_rec_get_index
(
lock
)
->
name
,
MAX_ALLOWED_FOR_STORAGE
(
cache
));
...
...
@@ -824,26 +822,19 @@ fold_lock(
#else
ulint
ret
;
switch
(
lock_get_type
(
lock
))
{
case
LOCK_REC
:
if
(
!
lock
->
is_table
())
{
ut_a
(
heap_no
!=
0xFFFF
);
ret
=
ut_fold_ulint_pair
((
ulint
)
lock
->
trx
->
id
,
lock
->
un_member
.
rec_lock
.
page_id
.
fold
());
ret
=
ut_fold_ulint_pair
(
ret
,
heap_no
);
break
;
case
LOCK_TABLE
:
}
else
{
/* this check is actually not necessary for continuing
correct operation, but something must have gone wrong if
it fails. */
ut_a
(
heap_no
==
0xFFFF
);
ret
=
(
ulint
)
lock_get_table_id
(
lock
);
break
;
default:
ut_error
;
}
return
(
ret
);
...
...
@@ -867,15 +858,13 @@ locks_row_eq_lock(
#ifdef TEST_NO_LOCKS_ROW_IS_EVER_EQUAL_TO_LOCK_T
return
(
0
);
#else
switch
(
lock_get_type
(
lock
))
{
case
LOCK_REC
:
if
(
!
lock
->
is_table
())
{
ut_a
(
heap_no
!=
0xFFFF
);
return
(
row
->
lock_trx_id
==
lock
->
trx
->
id
&&
row
->
lock_page
==
lock
->
un_member
.
rec_lock
.
page_id
&&
row
->
lock_rec
==
heap_no
);
case
LOCK_TABLE
:
}
else
{
/* this check is actually not necessary for continuing
correct operation, but something must have gone wrong if
it fails. */
...
...
@@ -883,10 +872,6 @@ locks_row_eq_lock(
return
(
row
->
lock_trx_id
==
lock
->
trx
->
id
&&
row
->
lock_table_id
==
lock_get_table_id
(
lock
));
default:
ut_error
;
return
(
FALSE
);
}
#endif
}
...
...
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