Skip to content

Comments

limit leveldb synctree lock to the local node#71

Merged
borshop merged 2 commits intodevelopfrom
bugfix/im/synctree_lock
Jun 1, 2015
Merged

limit leveldb synctree lock to the local node#71
borshop merged 2 commits intodevelopfrom
bugfix/im/synctree_lock

Conversation

@ian-mi
Copy link
Contributor

@ian-mi ian-mi commented May 27, 2015

As the intention of this use of global:trans appears to be to lock access to a synctree locally, limit the lock only on the local node. Hopefully this will help to reduce ensemble startup time. Attempts to address issue #70 (RIAK-1831).

@ian-mi ian-mi force-pushed the bugfix/im/synctree_lock branch from bd79dd6 to 1ff74f3 Compare May 27, 2015 06:33
@ian-mi
Copy link
Contributor Author

ian-mi commented May 27, 2015

As Andrew Stone noted in this comment locking can be avoided entirely if we check the result of ets:insert_new. I have update my pull request to do so.

@ian-mi ian-mi force-pushed the bugfix/im/synctree_lock branch 2 times, most recently from e809706 to 360cf9f Compare May 28, 2015 18:21
Copy link
Contributor

Choose a reason for hiding this comment

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

If safe_open returns {ok, DB}, you are almost guaranteed to have the one true instance open on that path (except for extreme timing races), and whatever is stored in the ETS is likely stale.

@ian-mi ian-mi force-pushed the bugfix/im/synctree_lock branch from 360cf9f to 4f936c3 Compare May 28, 2015 20:10
@nickelization
Copy link
Contributor

So, just to make sure I'm understanding this, eleveldb:open cannot open the same path twice at the same time, right? There's some sort of locking mechanism or something in there? I'm just assuming that's the way it works based on our discussions earlier and the way you've written the code, but I don't actually know myself. If that is indeed how it works, then everything looks great.

@nickelization
Copy link
Contributor

Also, it looks like the safe_open and reopen functions are no longer called by anything (reopen is exported, but I don't see it being used anywhere, and since this is fairly deep in the internals of riak_ensemble I assume it's not meant to be a public API function or anything). Not sure if we should consider removing those functions now, or maybe we want to leave them in for possible future use; I could see arguments either way.

@engelsanchez
Copy link
Contributor

@nickelization Yes, eleveldb has an internal lock that should prevent multiple instances opening the same directory. We should rely on that guarantee here.

@ian-mi
Copy link
Contributor Author

ian-mi commented May 28, 2015

I agree that reopen and safe_open should be removed as they should probably not be used instead of maybe_open_leveldb.

@nickelization
Copy link
Contributor

👍 7744c34

borshop added a commit that referenced this pull request May 29, 2015
limit leveldb synctree lock to the local node

Reviewed-by: nickelization
@cmeiklejohn
Copy link
Contributor

Am I missing something here? When retries gets to 0, won't this code just generate a case_clause exception?

@cmeiklejohn cmeiklejohn self-assigned this May 30, 2015
@cmeiklejohn
Copy link
Contributor

Ah, whoops. It looks like that was the behavior before as well.

@ian-mi
Copy link
Contributor Author

ian-mi commented Jun 1, 2015

I decided to keep the same behavior and generate the case_clause exception. I could easily change the code to pass the last error to the caller and match the return value, changing the generated exception to a bad_match exception, if you think that would be preferable.

@nickelization
Copy link
Contributor

Since it seems to fix the problem in question, and otherwise has the same behavior as before, I'm going to go ahead and merge this in since we're in a rush to get this out to a customer. If anyone else who's been reviewing this notices anything that's been missed let me know, but since it looks like Engel, Chris, and myself have all reviewed now I'm going to assume we're good here.

@nickelization
Copy link
Contributor

@borshop merge

@borshop borshop merged commit 7744c34 into develop Jun 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants