Memtx multikey index replace variants: factor out multikey logic
#12285
CuriousGeorgiy
started this conversation in
RFC
Replies: 4 comments 6 replies
This comment has been hidden.
This comment has been hidden.
-
|
AFAIU, |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Can you provide some examples of usage of new API? For example, in |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
AFAIR, you said there are some problems with functional indexes (that they are compared by pointers sometimes). How those problems will be solved in the new API? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Table of Contents
memtx_index_keyProblem
Currently, memtx multikey index variants encapsulate the processing of multiple multikey keys. This is bad for two reasons.
First, this violates the memtx index
replaceinterface. Eachreplaceoperation is supposed to return areplacedand asuccessortuple for tracking a transaction's read and write sets in memtx MVCC. However, multikey index variants yield multiplereplacedandsuccessortuples which cannot be returned through the existing interface.Second, this makes the replace operation coarse grained. Effectively, we lose control of the index state of each multikey key: either all the keys are inserted the index or they are deleted from it. However, in the context of memtx MVCC, each multikey key has an independent history chain, and thus its presence in the index needs to managed independently.
Together, these discrepancies prevent support of multikey index variants in memtx MVCC (see also #12313).
Last but not least, this complicates the indexing logic. The
replaceoperation for multikey index variants builds complex insertion, deletion and rolling back loops on top of the regular index replace operation. This is bad, as thereplaceoperation should be as simple as possible and it should not be responsible for multiple operations.Goal
Most importantly, we need to make the
replaceoperation for multikey index variants interoperable with memtx MVCC. To do this, we need to:replacedandsuccessorvalues from thereplaceoperation for each multikey key;replaceoperation on a single multikey key.Additionally, it would be good to simplify the
replaceoperation logic.Internally, we will still have several overload of
memtx_index_vtab::replacefor each index variant (regular, multikey, functional). Merging these overloads is out of the scope of this RFC (#12190).Solution
The solution will be based on the new
memtx_index_keyabstraction described below. This abstraction will allow to generalize a tuple in the case of multikey index variants.memtx_index_keyWe will introduce new abstractions that generalize a tuple and
replacein the case of multikey index variants:memtx_index_keyandmemtx_index_replace_key:memtx_index_replace_keywill be used in memtx MVCC for chain-wise operations. This will allow it to manage each multikey key's presence in an index.Factoring out multikey logic
The virtual index replace method,
memtx_index_vtab::replacewill be changed to have the following signature (same asmemtx_index_replace_key):Multikey index variants of
replace(memtx_tree_index_replace_multikeyandmemtx_tree_func_index_replace) will only handle one operation: either the replacement ofnew_keyand duplicate check ofold_key->tupleor deletion ofold_key.We will introduce a new abstraction for multikey index results,
memtx_index_result, and a new replace method,memtx_index_replace_with_results:Since results are only used by MVCC, the rest of the code will use a simplified version of
memtx_index_replace:Multikey logic will be factored out to
memtx_index_replace{_with_results}. It will responsible for:replacedandsuccessorlists (memtx_index_replace_with_results).memtx_index_replace_with_resultswill be used in memtx MVCC to collect the results of index operations. This will allow it to collect multiplereplacedandsuccessorkeys.Beta Was this translation helpful? Give feedback.
All reactions