Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Implementation of Pilosa Index Driver #205

Merged
merged 2 commits into from
Jun 5, 2018
Merged

Implementation of Pilosa Index Driver #205

merged 2 commits into from
Jun 5, 2018

Conversation

kuba--
Copy link
Contributor

@kuba-- kuba-- commented May 25, 2018

@kuba-- kuba-- requested review from erizocosmico and ajnavarro and removed request for erizocosmico May 25, 2018 21:12
@kuba-- kuba-- added the enhancement New feature or request label May 25, 2018
@kuba-- kuba-- requested review from a team and erizocosmico and removed request for erizocosmico May 26, 2018 10:20
@kuba--
Copy link
Contributor Author

kuba-- commented May 26, 2018

Note

Regarding Get(key ...interface{}) (IndexLookup, error) implementation.
Right now, if nokey parameter was passed the function returns an iterator which will go through all index locations in the same order as sql.IndexKeyValueIter passed to Save returned.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Load -> LoadAll

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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)
}
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@kuba--
Copy link
Contributor Author

kuba-- commented May 29, 2018

@ajnavarro - I've added PilosaHiccup test, where I restart pilosa container every second. In a meantime I try to Save/Load/Get with retry logic.


var indexes []sql.Index
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Contributor Author

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)"

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.


var indexes []sql.Index
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
Copy link
Contributor

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)
}
}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@ajnavarro
Copy link
Contributor

Why is Travis not executed?

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

I've updated LoadAll (I accumulate errors) so at the end you can decide do you want to go only with what successfully was loaded or break/stop loading.
Regarding travis I do not know, maybe it's because I check if docker is running before test pilosa.
So I commented these checks as a potential test blockers.

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

... or maybe just restarting pilosa container in tests hangs a travis randomly (because it works especially when the traffic is low)

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

I started build manually, we'll see how it goes

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

When I started manually everything looks fine - weird.

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

Something is wrong with reporting build status. Build finished with success: https://travis-ci.org/kuba--/go-mysql-server/builds/387725498
and status url says "unknown"

@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

...and build passed

@erizocosmico
Copy link
Contributor

As a last small request, can you cleanup a little bit the history of the PR? I see a "Merge" commit in there

kuba-- added 2 commits June 4, 2018 20:58
Signed-off-by: kuba-- <kuba@sourced.tech>
Signed-off-by: kuba-- <kuba@sourced.tech>
@kuba--
Copy link
Contributor Author

kuba-- commented Jun 4, 2018

I've squashed this PR to 2 commits - implementation and update (pull master and resolve conflicts)

Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@erizocosmico
Copy link
Contributor

Shall we merge this @ajnavarro? I'm gonna update gitbase and it'd be nice to get this too.

@ajnavarro ajnavarro merged commit 0b8a5d0 into src-d:master Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Pilosa IndexDriver
3 participants