-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Asynchronous Writing Datastores #140
Conversation
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.
The mount datastore needs a small fix and a test but otherwise LGTM.
After this PR is merged can we have a version bump according to semver practices since this is a breaking change to the |
We will bump the minor version because the package version is sub-zero. |
Won't break |
|
||
if mountPts[i].Equal(prefix) || suffix.String() != "/" { | ||
return 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.
Hm. This looks like a bug in lookupAll
. lookupAll
should only return mounts that can contain descendents of key
.
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 merge this as-is and fix it later or move this logic into lookupAll
now.
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.
Could you clarify what you think the bug is here? It looks like the documented behavior for lookupAll
.
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.
lookupAll
is supposed to return all datastores that might contain keys that are descendants of the given key. That means we should be calling Sync
on all datastores returned by lookupAll
datastores and we shouldn't have this extra check.
However, if we have ["/foo", "/foo/bar"]
, "/foo"
should "cover" "/foo/bar"
given that lookup
will always return "/foo"
. However, when given the prefix "/foo"
, lookupAll
will return both.
Note: this is only technically a bug. Nobody would ever mount "/foo"
over "/foo/bar"
.
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.
Nobody would ever mount "/foo" over "/foo/bar"
I thought it was expected behavior that we might mount "/" and also "/foo", or is the root a special case?
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.
My first example was bad: order matters. If we mount "/" over "/foo", "/" will win (I think? check me here). In go-ipfs, we mount "/blocks" over "/".
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 say "nobody would ever mount "/foo" over "/foo/bar" because "/foo" is a prefix of "/foo/bar" (and we check mounts in-order).
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 was wrong. We reverse-sort datastores so "/foo/bar" always comes before "/foo".
However, the bug was valid. Fix in #141.
d7a00b4
to
b6f1f99
Compare
b6f1f99
to
8ddf6ad
Compare
LGTM but let's merge this tomorrow. Hitting merge then going to bed is a bad idea (I mean, it's one of my favorite bad ideas but I think it's time to call it a day). |
Per #137 we would like to support Datastores that internally have asynchronous writes. We are doing this by adding a
Sync(prefix ds.Key)
function to the Datastore interface.The plan is:
Sync()
command on their datastores