-
Notifications
You must be signed in to change notification settings - Fork 74
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
Transaction in Replicate not block global #147
Comments
Hey 👋 ! I will try to take a look at it very soon, BTW, thanks for the detailed information about the issue, that helps a lot :) |
Hi @thachtan 👋 ! First of all, apologies for the lateness, I've been pretty busy so I hadn't been able to check this out. Now, I ran the example you have, and did work for me as expected, but I had to fix some issues you had in your code, let me list them here:
config :demo_nebulex_lock_key, ReplicatedCache,
stats: true,
primary: [
gc_interval: :timer.hours(12),
max_size: 1_000_000,
allocated_memory: 2_000_000_000,
gc_cleanup_min_timeout: :timer.seconds(10),
gc_cleanup_max_timeout: :timer.minutes(10),
backend: :shards,
partitions: System.schedulers_online() * 2 #=> Beaware this is resolved in compile-time
] The issue here is the primary storage config must be within the option
Summing up, as I mentioned before, after fixing your code (especially/mainly fix no. 1), I got: Node 1: iex(node1@127.0.0.1)1> DemoNebulexLockKey.get_cache(1)
true
account after deposit 100: %{balance: 400, id: 1, name: "account 1"}
account after add 200: %{balance: 600, id: 1, name: "account 1"}
%{balance: 600, id: 1, name: "account 1"} Node 2: iex(node2@127.0.0.1)1> DemoNebulexLockKey.get_cache(1)
true
account after deposit 100: %{balance: 200, id: 1, name: "account 1"}
account after add 200: %{balance: 600, id: 1, name: "account 1"}
%{balance: 600, id: 1, name: "account 1"} Try to fix it as I mentioned, and let me know how it goes, stay tuned! |
Hey 👋 ! You were right, there was an issue with the transaction logic, but I just pushed a fix to the master branch. If I run your demo with the fix: iex(node1@127.0.0.1)1> DemoNebulexLockKey.get_cache(1, 5000)
true
account before deposit 100: %{balance: 0, id: 1, name: "account 1"}
account after deposit 100: %{balance: 100, id: 1, name: "account 1"}
account after add 200: %{balance: 300, id: 1, name: "account 1"}
%{balance: 300, id: 1, name: "account 1"} Just to point out the iex(node2@127.0.0.1)1> DemoNebulexLockKey.get_cache(1, 10000) Then the result is: iex(node2@127.0.0.1)1> DemoNebulexLockKey.get_cache(1, 10000)
true
account before deposit 100: %{balance: 300, id: 1, name: "account 1"}
account after deposit 100: %{balance: 400, id: 1, name: "account 1"}
account after add 200: %{balance: 600, id: 1, name: "account 1"}
%{balance: 600, id: 1, name: "account 1"} Please try to test again your demo with the fix and let me know if it works for you, if so, I will publish a new patch release ASAP. Thanks! |
Oh it works as my expected. Thank you for take time to help this issues. |
Excellent! And thanks to you too, it was an important issue, and you provided a lot of details so that made the work much easier, thanks!! BTW, a new release |
I have some trouble with replicate adapter when using transaction. a process in another node still update/put cache with the same key.
I have mini repo describe this issue.
Context in example:
I think this cause by Nebulex.Adapter.Transaction only block the current pid of cache app
The text was updated successfully, but these errors were encountered: