-
Notifications
You must be signed in to change notification settings - Fork 109
Conversation
NoteRegarding |
sql/index.go
Outdated
@@ -111,9 +110,9 @@ type IndexDriver interface { | |||
// Create a new index. If exprs is more than one expression, it means the | |||
// index has multiple columns indexed. If it's just one, it means it may | |||
// be an expression or a column. | |||
Create(db, table, id string, expressionHashes []hash.Hash, config map[string]string) (Index, error) | |||
Create(db, table, id string, expressionHashes []ExpressionHash, config map[string]string) (Index, error) | |||
// Load the index at the given path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load -> LoadAll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -0,0 +1,107 @@ | |||
package index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some documentation to methods and constructors on this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added extra comments. So far I think it's clear what it does.
|
||
err = d.Delete(sqlIdx) | ||
require.Nil(err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test what happens if the index generation is stopped abruptly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add some tests for "failing cases", but generally with docker container after restart it will recreate a schema. At the end we won't find anything in bitmaps. The only functions which should work are Has
and Get()
(empty get) where we do not touch pilosa.
So what's your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have some tests for failing cases sound great. I'm afraid of having an index loaded that make a query fails just because is corrupted, or an index that appears to work correctly but it has incorrect or partial results.
@ajnavarro - I've added |
sql/index/pilosa/driver.go
Outdated
|
||
var indexes []sql.Index | ||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just skip the directory? maybe that error is a permission denied error or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we can do (except logging)?
- Stop loading all indexes
- Return accumulated error with all dirs which cannot be loaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we should handle that error instead of just skipping it
@@ -285,7 +284,7 @@ func exprListsEqual(a, b []hash.Hash) bool { | |||
continue | |||
} | |||
|
|||
if reflect.DeepEqual(va.Sum(nil), vb.Sum(nil)) { | |||
if reflect.DeepEqual(va, vb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can just do va == vb
, since they are byte slices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, check: https://play.golang.org/p/_dRDL0lErrV
I get an error: "(slice can only be compared to nil)"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, the ones you can compare are byte arrays, not slices haha. Nvm, then
|
||
// WriteConfigFile writes the configuration to dir/config.yml file. | ||
func WriteConfigFile(dir string, cfg *Config) error { | ||
path := filepath.Join(dir, ConfigFileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this config file is not read and written concurrently right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not be. Generally it's not thread safe implementation. More like z internal one.
sql/index/pilosa/driver.go
Outdated
|
||
var indexes []sql.Index | ||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we should handle that error instead of just skipping it
} | ||
err = mapping.putLocation(index.Name(), colID, location) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if there is an error writing the mapping but everything is already synced with pilosa? Should we implement some kind of transaction for this to ensure data integrity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great. So far if mapping fails in Save then the function returns error.
We can cal it again and overwrite mapping and pilosa bitmap (what we can find in tests). so at the end should not be a problem just retry.
Why is Travis not executed? |
I've updated |
... or maybe just restarting pilosa container in tests hangs a travis randomly (because it works especially when the traffic is low) |
I started build manually, we'll see how it goes |
When I started manually everything looks fine - weird. |
Something is wrong with reporting build status. Build finished with success: https://travis-ci.org/kuba--/go-mysql-server/builds/387725498 |
...and build passed |
As a last small request, can you cleanup a little bit the history of the PR? I see a "Merge" commit in there |
Signed-off-by: kuba-- <kuba@sourced.tech>
Signed-off-by: kuba-- <kuba@sourced.tech>
I've squashed this PR to 2 commits - implementation and update (pull master and resolve conflicts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Shall we merge this @ajnavarro? I'm gonna update gitbase and it'd be nice to get this too. |
It closes: #174
Design doc.: https://docs.google.com/document/d/1rWeR739rZsSnCBsXqyviVss8JAO6msV9B1PoDD45O2A/edit?usp=sharing