简体   繁体   English

Amazon EC2上的ResultSet不完整

[英]Incomplete ResultSet on Amazon EC2

I am running a JNDI JDBC connection pool on Tomcat hosted on an Amazon Web Services EC2 talking to an Amazon Web Services PostgreSQL Relational Database. 我正在与Amazon Web Services PostgreSQL关系数据库对话的Amazon Web Services EC2上托管的Tomcat上运行JNDI JDBC连接池。

I have a table with 40,000 rows of data that I am attempting to collect in one go using a JDBC PreparedStatement "SELECT * FROM tableName". 我有一张表,其中有40,000行数据,我尝试使用JDBC PreparedStatement“ SELECT * FROM tableName”一次性收集。

This combination of things works flawlessly, collecting all 40,000 rows, when I run the servlet on my local machine (from my local Tomcat) and have it talk to the RDS via db-name.aws-rds-URL :5432, however, when I run the same servlet on my AWS EC2 and instruct it to talk to the RDS on its local vLAN, it never gets more than 30,000 rows, with resultSets as few as 2,000 rows. 当我在本地计算机上运行servlet(从本地Tomcat)并使其通过db-name.aws-rds-URL :5432与RDS进行通信时,这种组合完美地工作了,收集了所有40,000行。我在我的AWS EC2上运行相同的servlet,并指示它与本地vLAN上的RDS进行通信,它的行数永远不会超过30,000行,而resultSets则只有2,000行。 Each time I refresh it, it yields a new and different, yet incomplete, number of rows. 每次刷新时,它都会产生新的和不同但不完整的行数。

Below is my entry in Tomcat's global context.xml (I am using the same dataSource across multiple servlets). 以下是我在Tomcat的全局context.xml中的条目(我在多个servlet中使用相同的dataSource)。

< Resource
name="jdbc/postgres4"
auth="Container"
type="javax.sql.DataSource"
maxActive="8"
maxIdle="8"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://dn-name.aws-rds-URL:5432/SID"
username="db-username"
password="password" /> 

Any ideas on what could be going astray here? 关于这里可能会误入歧途的任何想法?

This was not a database issue at all... I added a counter to the while(rs.next()) loop and I ended up with 40,000 every time, while the servlet row nums varied as before. 这根本不是数据库问题……我在while(rs.next())循环中添加了一个计数器,每次都以40,000结尾,而servlet行的数量与以前一样。

I managed to fix the issue by switching from the Google Guava MapMaker() ConcurrentMap to the Java ConcurrentHashMap, except now I have to deal with the Java HashMap GC memory issue again... 通过从Google Guava MapMaker()ConcurrentMap切换到Java ConcurrentHashMap,我设法解决了该问题,但现在我不得不再次处理Java HashMap GC内存问题...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM