On Tuesday, August 28, 2012 6:58:53 PM UTC-7, Jeremy Evans wrote:
>
> On Tuesday, August 28, 2012 5:13:33 PM UTC-7, Ravi wrote:
>>
>> Increasing max_connection also not working. I ran the application 50-60 
>> times in few span of seconds (at each call it creates 3-4 databse objects) 
>> and now it is giving me same error. "Too many connections"
>
>
> Is there a reason that you are running 50-60 copies of the application, 
> and creating 3-4 Database objects in each one?  That sounds like a very 
> poor design to me.
>
Yes, this is the requirement. There can be multiple users accessing/running 
this program. Just out of curious, what is the drawback of creating more 
than one db object say 2 or 3?

>  
>
>> I think I need to close/disconnect the DB for each thread I have in the 
>> app.
>>
>
> You should fix your design instead of attempting to do this.  If you 
> really want to do this, I've already mentioned how in earlier messages.
>
Agree. I have fixed the design keeping in mind what we discussed. Also, I 
designed the program thinking that the db will disconnect all connections 
when the program exits or ends. but I think the connections are always 
there only the DB object is destroyed.

>  
>
>> Also, is there a way externally I can check the number of connections to 
>> the database or close all connections (out of app)?
>>
>
> DB.pool.size gives you the current size of the pool.  You would need to 
> make your application offer some way for users to call Database#disconnect 
> inside the app (signals, web api, etc.).  Not that you should actually do 
> this, as it's a bad idea.
>

DB.pool.size give me the pool size in current instance of program but since 
I am unable to connect to database now(Too many connections) I was 
searching a way I can handle/monitor all  open connections (after the 
program exits). 


> Fix your design:
>
> 1) Unless you need to connect to arbitrary databases based on runtime 
> input, assign your Database object to a constant on app initialization. 
>  You should generally not create Database objects at runtime in most cases. 
>  If you are doing this without a good reason, your design needs to be 
> fixed.  Based on the code you have posted so far, I don't see a good reason 
> for you to create Database objects at runtime.
>

I am creating the DB object once only when starting the app/program (may be 
at run time). but what if the program run multiple times, the DB object is 
destroyed at the end of program?
How can I initialize the program or create Database object once before 
running the app/program ie, not at runtime.
   

>
> 2) If your app is single threaded, put Sequel in single threaded mode.
>
Done this part. 

>
> 3) Adjust your database configuration so that it allows more connections 
> than you plan on making to it.
>
Increased the max_connections. 

>
> Until you follow these steps or provide a good reason why they shouldn't 
> apply to you, please don't ask for additional help.
>
I appreciate all your help and followed above steps. I designed the program 
by following the steps given at 
http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html and 
end up with only issue.

>
> Jeremy
>

Thanks again,
Ravi 

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/KxPlOrlaFMIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to