sql: delete index if there is an error when it's added to the registry #318
Conversation
Signed-off-by: Manuel Carmona <manu.carmona90@gmail.com>
Ok, it may work because in pilosa we have frames/fields as a combination of |
Lets add test for this case |
@kuba-- TestAddIndex is already testing it. Maybe we will need to add an integration test in gitbase instead when this is merged and updated there. |
@mcarmonaa - I think there is no need to add it to gitbase, but |
@kuba-- https://github.com/src-d/go-mysql-server/blob/master/sql/index_test.go#L131 is adding an instance of a new index with a different id |
I would prefer do not create a valid index folder when Create() method is called. We can create the |
@mcarmonaa - ok, you're right (my bad). so maybe we can keep the old instance and again try to load the index. @ajnavarro - so far
|
👍
Is it an index useful if you don't save something on it? |
@mcarmonaa - it's just an empty index (no data) I just wondering if it's possible no to create any index, I mean just compare expressions in potential new index with existing indexes expressions. Instead of first create and later validate |
@ajnavarro @kuba-- Which solution will we go ahead with finally? the |
@mcarmonaa If it is possible to compare before the If not, create the processing file on Save(). I would prefer the first approach. |
What if we modify
WDYT? |
Generally we can split current functionality |
...but if it's too complicated, lets go with |
I have implemented something similar to what you say @kuba--, the problem I see is that the process So we need something like: func (r *IndexRegistry) CreateAndAddIndex(
driver IndexDriver,
db, table, id string,
expressions []Expression,
config map[string]string,
) (idx Index, created chan<- struct{}, ready <-chan struct{}, err error) WDYT @ajnavarro @kuba-- ? |
imo, each of them are atomic operation (just to test it out) and |
Ok, let's with the I'll close this PR and implement it in another one. |
Related to src-d/gitbase#411
This is the simplest solution. If we want to avoid create the index if it can't be added to the registry, we must mix a little bit the create index and add index logic to rely on the
IndexRegitry.AddIndex
method to create the index instance. WDYT @src-d/data-retrieval ?