Skip to content
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

Cabol.122.riak backend config enhancement #124

Merged
merged 4 commits into from
Mar 12, 2015

Conversation

cabol
Copy link
Contributor

@cabol cabol commented Mar 12, 2015

  1. Configuration of Riak backend was modified to support bucket per store, and stores can share one backend.
  2. Some workarounds were added to mitigate the problem with connection pool, which in case of Riak (and is the same with PostgreSQL) is not handled by native Erlang client. Even though, it needs to be modified, providing a real connection pool solution.

    Workaround 1:

    when the store calls get_connection, a new Riak connection is returned - one to one model (between connection and store).

    Workaround 2:

    A simple list (LIFO) was added to hold a set of connections that are created in the sumo_backend_riak:init function. When the store needs a connection, must call sumo_backend_riak:checkout_conn to get the Pid, and when it finish, must call sumo_backend_riakcheckin_conn. These operations have some problems, for instance, the don't consider an overflow, so the amount of new connection are not watched, so in case of high concurrency, exist the risk of have so many connection hitting the DB and causing contention.

Note: This is a temporary solution, a real good solution is still needed. Please check workaround 2 and see if is good for now or not.

cabol added 2 commits March 10, 2015 14:34
…e backend. Also, R/W quorums can be configured now within the store.
… the backend. 1st workaround was modify the 'get_connection' function in the backend to return a new connection. 2nd workaround was add 'checkin' and 'checkout' functions to simulate a simple connection pool in LIFO mode (but is not a real pool), but they still have some problems.
-type r_param() :: r | pr | notfound_ok.
-type w_param() :: w | pw | dw | returnbody.

-record(state, {backend, conn :: pid(),
Copy link
Member

Choose a reason for hiding this comment

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

backend is missing its type declaration.

… workaround to 1st approach - when the store invokes , a new Riak connection is returned - one to one model (between connection and store).
@@ -205,12 +237,12 @@ doc_id(Doc) ->
sumo_internal:get_field(IdField, Doc).

%% @private
new_doc(Doc, #state{conn = Conn, bucket = Bucket}) ->
new_doc(Doc, #state{conn = Conn, bucket = Bucket, write_quorum = W}) ->
Copy link
Member

Choose a reason for hiding this comment

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

W should be Wq to match the rest of the functions

elbrujohalcon pushed a commit that referenced this pull request Mar 12, 2015
…ncement

Cabol.122.riak backend config enhancement
@elbrujohalcon elbrujohalcon merged commit d0a8dcd into master Mar 12, 2015
@cabol cabol deleted the cabol.122.riak_backend_config_enhancement branch March 31, 2015 17:45
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.

3 participants