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
af7bd64e
Commit
af7bd64e
authored
Nov 10, 2022
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: Use BTR_INSERT_TREE for pessimistic insert
parent
b363d975
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
32 deletions
+31
-32
storage/innobase/ibuf/ibuf0ibuf.cc
storage/innobase/ibuf/ibuf0ibuf.cc
+8
-12
storage/innobase/include/btr0btr.h
storage/innobase/include/btr0btr.h
+12
-8
storage/innobase/include/row0ins.h
storage/innobase/include/row0ins.h
+2
-2
storage/innobase/row/row0ins.cc
storage/innobase/row/row0ins.cc
+7
-8
storage/innobase/row/row0log.cc
storage/innobase/row/row0log.cc
+2
-2
No files found.
storage/innobase/ibuf/ibuf0ibuf.cc
View file @
af7bd64e
...
...
@@ -3090,7 +3090,7 @@ ibuf_index_page_calc_free_from_bits(ulint physical_size, ulint bits)
/** Buffer an operation in the insert/delete buffer, instead of doing it
directly to the disk page, if this is possible.
@param[in] mode BTR_MODIFY_PREV or BTR_
MODIFY
_TREE
@param[in] mode BTR_MODIFY_PREV or BTR_
INSERT
_TREE
@param[in] op operation type
@param[in] no_counter TRUE=use 5.0.3 format; FALSE=allow delete
buffering
...
...
@@ -3186,7 +3186,7 @@ ibuf_insert_low(
the new entry to it without exceeding the free space limit for the
page. */
if
(
BTR_LATCH_MODE_WITHOUT_INTENTION
(
mode
)
==
BTR_MODIFY
_TREE
)
{
if
(
mode
==
BTR_INSERT
_TREE
)
{
for
(;;)
{
mysql_mutex_lock
(
&
ibuf_pessimistic_insert_mutex
);
mysql_mutex_lock
(
&
ibuf_mutex
);
...
...
@@ -3217,9 +3217,7 @@ ibuf_insert_low(
ut_free
(
pcur
.
old_rec_buf
);
mem_heap_free
(
heap
);
if
(
err
==
DB_SUCCESS
&&
BTR_LATCH_MODE_WITHOUT_INTENTION
(
mode
)
==
BTR_MODIFY_TREE
)
{
if
(
err
==
DB_SUCCESS
&&
mode
==
BTR_INSERT_TREE
)
{
ibuf_contract_after_insert
(
entry_size
);
}
...
...
@@ -3266,7 +3264,7 @@ ibuf_insert_low(
until after the IBUF_OP_DELETE has been buffered. */
fail_exit:
if
(
BTR_LATCH_MODE_WITHOUT_INTENTION
(
mode
)
==
BTR_MODIFY
_TREE
)
{
if
(
mode
==
BTR_INSERT
_TREE
)
{
mysql_mutex_unlock
(
&
ibuf_mutex
);
mysql_mutex_unlock
(
&
ibuf_pessimistic_insert_mutex
);
}
...
...
@@ -3382,8 +3380,7 @@ ibuf_insert_low(
ibuf
.
empty
=
page_is_empty
(
root
);
}
}
else
{
ut_ad
(
BTR_LATCH_MODE_WITHOUT_INTENTION
(
mode
)
==
BTR_MODIFY_TREE
);
ut_ad
(
mode
==
BTR_INSERT_TREE
);
/* We acquire an sx-latch to the root page before the insert,
because a pessimistic insert releases the tree x-latch,
...
...
@@ -3558,7 +3555,7 @@ ibuf_insert(
entry
,
entry_size
,
index
,
page_id
,
zip_size
,
thr
);
if
(
err
==
DB_FAIL
)
{
err
=
ibuf_insert_low
(
BTR_
MODIFY_TREE
|
BTR_LATCH_FOR_INSERT
,
err
=
ibuf_insert_low
(
BTR_
INSERT_TREE
,
op
,
no_counter
,
entry
,
entry_size
,
index
,
page_id
,
zip_size
,
thr
);
}
...
...
@@ -3922,13 +3919,12 @@ ibuf_restore_pos(
const
page_id_t
page_id
,
/*!< in: page identifier */
const
dtuple_t
*
search_tuple
,
/*!< in: search tuple for entries of page_no */
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
MODIFY
_TREE */
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
PURGE
_TREE */
btr_pcur_t
*
pcur
,
/*!< in/out: persistent cursor whose
position is to be restored */
mtr_t
*
mtr
)
/*!< in/out: mini-transaction */
{
ut_ad
(
mode
==
BTR_MODIFY_LEAF
||
BTR_LATCH_MODE_WITHOUT_INTENTION
(
mode
)
==
BTR_MODIFY_TREE
);
ut_ad
(
mode
==
BTR_MODIFY_LEAF
||
mode
==
BTR_PURGE_TREE
);
if
(
UNIV_LIKELY
(
pcur
->
restore_position
(
mode
,
mtr
)
==
btr_pcur_t
::
SAME_ALL
))
{
...
...
storage/innobase/include/btr0btr.h
View file @
af7bd64e
...
...
@@ -125,8 +125,16 @@ enum btr_latch_mode {
block->lock range.*/
BTR_LATCH_FOR_DELETE
=
512
,
/** Attempt to purge a secondary index record in the tree. */
BTR_PURGE_TREE
=
BTR_MODIFY_TREE
|
BTR_LATCH_FOR_DELETE
/** In the case of BTR_MODIFY_TREE, the caller specifies
the intention to delete record only. It is used to optimize
block->lock range.*/
BTR_LATCH_FOR_INSERT
=
1024
,
/** Attempt to delete a record in the tree. */
BTR_PURGE_TREE
=
BTR_MODIFY_TREE
|
BTR_LATCH_FOR_DELETE
,
/** Attempt to insert a record into the tree. */
BTR_INSERT_TREE
=
BTR_MODIFY_TREE
|
BTR_LATCH_FOR_INSERT
};
/** This flag ORed to BTR_INSERT says that we can ignore possible
...
...
@@ -134,13 +142,9 @@ UNIQUE definition on secondary indexes when we decide if we can use
the insert buffer to speed up inserts */
#define BTR_IGNORE_SEC_UNIQUE 2048U
/** In the case of BTR_MODIFY_TREE, the caller specifies the intention
to insert record only. It is used to optimize block->lock range.*/
#define BTR_LATCH_FOR_INSERT 4096U
/** This flag is for undo insert of rtree. For rtree, we need this flag
to find proper rec to undo insert.*/
#define BTR_RTREE_UNDO_INS
8192
U
#define BTR_RTREE_UNDO_INS
4096
U
/** In the case of BTR_MODIFY_LEAF, the caller intends to allocate or
free the pages of externally stored fields. */
...
...
@@ -148,7 +152,7 @@ free the pages of externally stored fields. */
/** Try to delete mark the record at the searched position when the
record is in spatial index */
#define BTR_RTREE_DELETE_MARK
32768
U
#define BTR_RTREE_DELETE_MARK
16384
U
#define BTR_LATCH_MODE_WITHOUT_FLAGS(latch_mode) \
((latch_mode) & ulint(~(BTR_INSERT \
...
...
storage/innobase/include/row0ins.h
View file @
af7bd64e
...
...
@@ -94,13 +94,13 @@ same fields is found, the other record is necessarily marked deleted.
It is then unmarked. Otherwise, the entry is just inserted to the index.
@retval DB_SUCCESS on success
@retval DB_LOCK_WAIT on lock wait when !(flags & BTR_NO_LOCKING_FLAG)
@retval DB_FAIL if retry with BTR_
MODIFY
_TREE is needed
@retval DB_FAIL if retry with BTR_
INSERT
_TREE is needed
@return error code */
dberr_t
row_ins_sec_index_entry_low
(
/*========================*/
ulint
flags
,
/*!< in: undo logging and locking flags */
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
MODIFY
_TREE,
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
INSERT
_TREE,
depending on whether we wish optimistic or
pessimistic descent down the index tree */
dict_index_t
*
index
,
/*!< in: secondary index */
...
...
storage/innobase/row/row0ins.cc
View file @
af7bd64e
...
...
@@ -174,7 +174,7 @@ dberr_t
row_ins_sec_index_entry_by_modify
(
/*==============================*/
ulint
flags
,
/*!< in: undo logging and locking flags */
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
MODIFY
_TREE,
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
INSERT
_TREE,
depending on whether mtr holds just a leaf
latch or also a tree latch */
btr_cur_t
*
cursor
,
/*!< in: B-tree cursor */
...
...
@@ -241,7 +241,7 @@ row_ins_sec_index_entry_by_modify(
break
;
}
}
else
{
ut_a
(
mode
==
BTR_MODIFY
_TREE
);
ut_a
d
(
mode
==
BTR_INSERT
_TREE
);
if
(
buf_pool
.
running_out
())
{
return
(
DB_LOCK_TABLE_FULL
);
...
...
@@ -2825,13 +2825,13 @@ same fields is found, the other record is necessarily marked deleted.
It is then unmarked. Otherwise, the entry is just inserted to the index.
@retval DB_SUCCESS on success
@retval DB_LOCK_WAIT on lock wait when !(flags & BTR_NO_LOCKING_FLAG)
@retval DB_FAIL if retry with BTR_
MODIFY
_TREE is needed
@retval DB_FAIL if retry with BTR_
INSERT
_TREE is needed
@return error code */
dberr_t
row_ins_sec_index_entry_low
(
/*========================*/
ulint
flags
,
/*!< in: undo logging and locking flags */
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
MODIFY
_TREE,
ulint
mode
,
/*!< in: BTR_MODIFY_LEAF or BTR_
INSERT
_TREE,
depending on whether we wish optimistic or
pessimistic descent down the index tree */
dict_index_t
*
index
,
/*!< in: secondary index */
...
...
@@ -2856,7 +2856,7 @@ row_ins_sec_index_entry_low(
rtr_info_t
rtr_info
;
ut_ad
(
!
dict_index_is_clust
(
index
));
ut_ad
(
mode
==
BTR_MODIFY_LEAF
||
mode
==
BTR_
MODIFY
_TREE
);
ut_ad
(
mode
==
BTR_MODIFY_LEAF
||
mode
==
BTR_
INSERT
_TREE
);
cursor
.
thr
=
thr
;
cursor
.
rtr_info
=
NULL
;
...
...
@@ -3001,7 +3001,7 @@ row_ins_sec_index_entry_low(
err
=
btr_cur_search_to_nth_level
(
index
,
0
,
entry
,
PAGE_CUR_LE
,
(
search_mode
&
~
(
BTR_INSERT
|
BTR_IGNORE_SEC_UNIQUE
)),
&
~
(
BTR_INSERT
|
BTR_IGNORE_SEC_UNIQUE
)),
//???
&
cursor
,
&
mtr
);
if
(
err
!=
DB_SUCCESS
)
{
goto
func_exit
;
...
...
@@ -3040,7 +3040,6 @@ row_ins_sec_index_entry_low(
err
=
rtr_ins_enlarge_mbr
(
&
cursor
,
&
mtr
);
}
}
else
{
ut_ad
(
mode
==
BTR_MODIFY_TREE
);
if
(
buf_pool
.
running_out
())
{
err
=
DB_LOCK_TABLE_FULL
;
goto
func_exit
;
...
...
@@ -3243,7 +3242,7 @@ row_ins_sec_index_entry(
log_free_check
();
err
=
row_ins_sec_index_entry_low
(
flags
,
BTR_
MODIFY
_TREE
,
index
,
flags
,
BTR_
INSERT
_TREE
,
index
,
offsets_heap
,
heap
,
entry
,
0
,
thr
);
}
...
...
storage/innobase/row/row0log.cc
View file @
af7bd64e
...
...
@@ -1583,7 +1583,7 @@ row_log_table_apply_insert_low(
entry
=
row_build_index_entry
(
row
,
NULL
,
index
,
heap
);
error
=
row_ins_sec_index_entry_low
(
flags
,
BTR_
MODIFY
_TREE
,
flags
,
BTR_
INSERT
_TREE
,
index
,
offsets_heap
,
heap
,
entry
,
thr_get_trx
(
thr
)
->
id
,
thr
);
...
...
@@ -2109,7 +2109,7 @@ row_log_table_apply_update(
error
=
row_ins_sec_index_entry_low
(
BTR_CREATE_FLAG
|
BTR_NO_LOCKING_FLAG
|
BTR_NO_UNDO_LOG_FLAG
|
BTR_KEEP_SYS_FLAG
,
BTR_
MODIFY
_TREE
,
index
,
offsets_heap
,
heap
,
BTR_
INSERT
_TREE
,
index
,
offsets_heap
,
heap
,
entry
,
thr_get_trx
(
thr
)
->
id
,
thr
);
/* Report correct index name for duplicate key error. */
...
...
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