I learnt that all secondary B-trees in InnoDB store pairs of the form (search key, TID) where TID is the primary keys of the records. I have the following questions:
(1) In InnoDB, does the secondary B-trees implement deletion by mark-deletion? That is, the entries in the leaves are marked as deletion instead of physical deletion.
(2) If so, when inserting a new entry whose search key is the same as some existing mark-deleted entry, how does InnoDB decide if the mark-deleted entry has been committed or not? For example, suppose the B-tree is a unique index. Suppose the first transaction mark-deletes search key hello
, and the second transaction tries to insert search key hello
. If the first transaction has not yet committed, the insertion should be failed; otherwise, the insertion should be successful. I wonder how InnoDB decides if it is allowed to insert hello
.