-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fixes/error no members handling #36
Conversation
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) |
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.
What is the purpose of this additional increment def, and the decrement below?
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.
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
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.
Makes sense, 👍
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. Also it would be good to have a default timeout, in the new take_group_member function. |
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 |
@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) |
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.
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?
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.
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
👍 LGTM |
Great! Checking the issues, this PR may be a (transient?) fix for issues #25 and #33 |
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.