Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PostGresql - non superuser connection limit exceeded

Posted on 2003-12-01
3
Medium Priority
?
2,384 Views
Last Modified: 2012-06-27
I am running a JSP application on Tomcat that refreshes every minute. When it refreshes, it opens a connection to the DB, executes a few queries/updates, and then closes all the connections. I have similar pages in my app that do similar things.

One page though consistently blows up after about 20 minutes. It gives me a Fatal exception that says the "non superuser connection limit is exceeded". I have tried to figure out what is going wrong, especially since I know that I am closing the connections each time, and I know it is specific to PostGresql because the same pages run fine with an MS SQL db in the backend.

Does anybody have any ideas? I have checked the Postgresql site and there was nothing really helpful there that I could find.
0
Comment
Question by:Arawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
stoneman earned 300 total points
ID: 9852475
The number of superuser connections is set in the postgresql.conf file with the following line:

#superuser_reserved_connections = 2

It sounds like you are using the superuser account (usually postgres or pgsql) to login in from php. This is bad. It's like launching your webserver under root or something - potential security risk. Usually you create a user account and let the webapp use that to login.

The reason for the running out of connections could be something simple like you have a couple of pgsql shells open, that would prevent the webapp from getting a valid connection.

There is also another param in that file:

max_connections = 200

I think this is the default value. The max_connections comes into play whenever you use the user accounts to login.

Finally, why does the one page blow up and not the others? I'd like to see the jsp to make sure exactly what you are doing. If you are indeed closing the connection then that should prevent this. But perhaps there is something else. Please post snippets if you can.

Hope this helps,

Gregory

0
 
LVL 4

Author Comment

by:Arawn
ID: 9852583
stoneman

I don't think I am using the superuser account, because this is actually a hosted database. And I can't see any hosting company giving away the superuser password.

The pertinent info from the page is below. I have truncated a whole bunch of things that aren't important. The main thing is that it is clear that the page is refreshing, and that the connection is being closed.

<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setIntHeader("Refresh", 60 );

String sql="select aucID from auctionAuctions where aucEnded=0 and aucCloseDate<'"+currSQLDate+"' and aucNumBid>0";
java.util.ArrayList openAuctions=new java.util.ArrayList();
Class.forName(jdbc_driver);  
Connection con =       DriverManager.getConnection(jdbc_databaseURL,jdbc_username,jdbc_password);  
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){      
      openAuctions.add(""+rs.getInt("aucID"));
}
for(int x=0; x<openAuctions.size(); x++){
      sql="select auctionItems.itemTitle, auctionAuctions.aucCurrentBid, auctionUsers.userEmail from auctionItems, auctionAuctions, auctionUsers  where aucID="+openAuctions.get(x)+" and auctionUsers.UserID=auctionAuctions.aucCurrentBidder and auctionAuctions.aucItemID=auctionItems.itemID";
      rs= stmt.executeQuery(sql);
      if(rs.next()){      
                      // do stuff
      rs.close();      
      }      
}
sql="update auctionAuctions set aucEnded=1 where aucCloseDate<'"+currSQLDate+"' and aucNumBid=0";
stmt.executeUpdate(sql);
stmt.close();
con.close();
%>
0
 
LVL 4

Author Comment

by:Arawn
ID: 9949384
It ended up being a problem on the host's side. Thanks for answering.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question