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

Fixes/error no members handling #36

Merged

Conversation

oguizol
Copy link
Contributor

@oguizol oguizol commented Apr 4, 2016

Simple handling of :pooler.take_group_member when returning :error_no_members
Now when we receive such value, we make a new call after a random time.

Olivier added 3 commits March 31, 2016 08:44
commit 146a1f2
Author: Olivier <[email protected]>
Date:   Thu Mar 31 08:38:33 2016 +0200

    updated other start function

commit 19a5d77
Author: Olivier <[email protected]>
Date:   Wed Mar 30 17:43:02 2016 +0200

    typo

commit 86865b1
Author: Olivier <[email protected]>
Date:   Wed Mar 30 17:23:41 2016 +0200

    improved random number retrieval

commit 21104b1
Author: Olivier <[email protected]>
Date:   Wed Mar 30 17:16:58 2016 +0200

    fixed issues

commit e48c024
Author: Olivier <[email protected]>
Date:   Wed Mar 30 16:45:46 2016 +0200

    handled error_no_members from pooler by issuing a new request after a random delay
@@ -12,7 +12,8 @@ defmodule Riak.CRDT.Counter do
@doc """
Increment a `counter` on the `amount` defaulting in 1
"""
def increment(counter, amount \\ 1) when Record.is_record(counter, :counter) do
def increment(counter, amount \\ 1)
Copy link
Owner

Choose a reason for hiding this comment

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

What is the purpose of this additional increment def, and the decrement below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It prevents from having a warning at compile time on that function because it has default value for the 'amount' param and several clauses.
I believe this warning is issued since elixir 1.2

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense, 👍

@oguizol
Copy link
Contributor Author

oguizol commented Apr 7, 2016

Actually we had to put a delay as we observed that it did not work if we called :pooler.take_group_member a second time right after.

Also, the random time was added in case there are simultaneous calls.
I can implement your proposal and put the random at the higher level.

Also it would be good to have a default timeout, in the new take_group_member function.
I'll update the PR.

@drewkerrigan
Copy link
Owner

Cool, I'll review again after you update. Using a random delay to deal with potential deadlocks or other problems can be scary, it would be nice to better understand how and when simultaneous calls will cause issues in pooler. I'm not ruling out the possibility that pooler isn't the correct library to use in this client if we're seeing issues with simultaneous calls

@oguizol
Copy link
Contributor Author

oguizol commented Apr 7, 2016

@drewkerrigan : There might be a smarter way to code the call to take_group_member within the macro and leave the function private as you suggested but I am not too comfortable with macro...


defp init_seed do
# Let's initialize a seed for pseudo uniform random number - no periodic
<< a :: 32, b :: 32, c :: 32 >> = :crypto.rand_bytes(12)
Copy link
Owner

Choose a reason for hiding this comment

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

With the timeout mechanism in place, it doesn't seem like we need to mess with the random number seed anymore right? Or were you leaving this here so that the downstream pooler stuff benefits it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you are right! I'll remove it.

Le 7 avr. 2016 à 18:30, Drew Kerrigan [email protected] a écrit :

In lib/riak/connection.ex:

 :riakc_pb_socket.start(host, port, args)

end
+

  • defp init_seed do
  • Let's initialize a seed for pseudo uniform random number - no periodic

  • << a :: 32, b :: 32, c :: 32 >> = :crypto.rand_bytes(12)
    With the timeout mechanism in place, it doesn't seem like we need to mess with the random number seed anymore right? Or were you leaving this here so that the downstream pooler stuff benefits it?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

@drewkerrigan
Copy link
Owner

👍 LGTM

@drewkerrigan drewkerrigan merged commit cc3f729 into drewkerrigan:master Apr 7, 2016
@oguizol
Copy link
Contributor Author

oguizol commented Apr 7, 2016

Great! Checking the issues, this PR may be a (transient?) fix for issues #25 and #33
Looks like, the timeout thing could have been implemented at the pooler level: epgsql/pooler#54

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