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

Ability to turn off Auto Reconnect in emongo_pool #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Ability to turn off Auto Reconnect in emongo_pool #2

wants to merge 3 commits into from

Conversation

jdhood1
Copy link

@jdhood1 jdhood1 commented Nov 10, 2011

Hey Oleg,

I have a requirement to let the application die if it cannot connect to or loses its connection to the DB. That way another program can report that problem to a UI and restart the application. The only way I could think of to do that was to add the ability to turn off auto reconnect in emongo_pool. That causes the emongo_sup to retry starting it a few times and then give up. That causes the app to die, which, in turn, causes my app to die because I started emongo with the Type field to 'permanent'. If there's a better way, please let me know.

I also noticed a bug with find_and_modify's 'fields' option. I noticed and removed an unused function in the performance test I recently added.

Jeremy

@master
Copy link
Owner

master commented Nov 21, 2011

Have you seen Erlang supervisor maximum restart frequency? http://www.erlang.org/doc/design_principles/sup_princ.html#frequency "If more than MaxR number of restarts occur in the last MaxT seconds, then the supervisor terminates all the child processes and then itself." Perhaps, it's a feature which you're looking for.

@jdhood1
Copy link
Author

jdhood1 commented Nov 21, 2011

You're right. It would have been way better to just make those configurable.

I started looking at the performance test I added more carefully because I was seeing some strange behavior in my applications. I was only checking to make sure the "err" value returned was null. However, when I started checking "n", the results were different. For an update_sync and delete_sync, I'd expect "n" to be 1 because 1 existing entry was modified. However, for insert_sync, it should be 0. Once I started checking "n", I realized that the messages to the DB and their responses were getting mixed up. For example, an update_sync response was being treated as an insert_sync response. I looked through the code for a couple of days, on and off, and even had one of my coworkers look at it with me for an entire day! We couldn't see anything that would have caused this behavior. The ReqId seemed to assigned and handled properly, parsed out of the response properly, etc. It wouldn't fail every time either. Out of the 500 processes running 10 tests each (5,000 tests total), only about 4-10 would fail. The failures would sometimes domino as well. For example, if the insert_sync got a response before the data was really inserted, the next command that expects the data to be in the DB would sometimes fail because the data wasn't there yet.

I'll push the new version of the performance test so you can see what I'm talking about. I vaguely remember having this problem a while back with Jacob's branch, so I don't think it's anything you introduced. If it's not a priority to you, then don't worry about it. I reverted back to my other version of Emongo that I merged off of Jacob's latest a while back. I added find_and_modify, all the *_sync functions, and some other stuff. I was in a time crunch and couldn't spend more time on this problem and had to get past it ASAP. I'll get the version I'm using up to github soon, if you're interested in having a look at it.

Thanks again for your responsiveness. It's great to having other Erlangers out there to talk to. We are few and far between, at least where I work.

Jeremy

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.

2 participants