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
Make sure all stores are closed if an error occurs with one of them. #1178
Conversation
Allows two processes trying to access the same database at the same time to backoff and retry until the other one releases it. Otherwise one can end up with some of the database's stores and the other one with the rest, meaning neither can open it.
I like it, a few, questions/nits
|
Yes, I'll rename From my reading (http://hackingdistributed.com/2013/06/17/hyperleveldb/) it seems hyperleveldb achieves better use of multiple threads within a process but not the ability to write from multiple processes. On linux, leveldb uses static int LockOrUnlock(int fd, bool lock) {
errno = 0;
struct flock f;
memset(&f, 0, sizeof(f));
f.l_type = (lock ? F_WRLCK : F_UNLCK);
f.l_whence = SEEK_SET;
f.l_start = 0;
f.l_len = 0; // Lock/unlock entire file
return fcntl(fd, F_SETLK, &f);
}
It looks like
I don't know about Mac. |
Thanks, a mac is going to be the same as Linux. I'm not sure if a test is
|
you don't need a leading underscore at all here, just |
Sure, thanks. Just wondering why the other |
the main adapter object has methods without underscore so when the adapters are implemented they add an underscore to their method names to avoid clashes. |
Sorry for the delay here, back from holidays now so wont be the same delay in future. I havent looked into the leveldb process semantics and I never realised they already held locks for us, I thought we have far more severe problems there, thats nice :) I am worried about exposing this in the api though, we havent kept the api entirely symetrical, the http adapter has some differing capabilities, but I would prefer not to expose them when we dont need to, in this case theres no reason to expose it right? if so could we change it to just a plain inner function and happy to merge I do think we want test infrastructure for this, but its going to be hard to do and dont want to block improvements on that, I will have node specific tests in soon but this stuff is going to need a lot of extra work to coordinate processes |
merged 18177d3 |
Allows two processes trying to access the same database at the same time to
backoff and retry until the other one releases it.
Otherwise one can end up with some of the database's stores and the other one
with the rest, meaning neither can open it.
Note: It doesn't seem there's test infrastructure for adapter-specific tests.