Forum: Building VoltDB Clients

Post: VoltDB jdbc throws ‘Too many pending stat requests'

VoltDB jdbc throws ‘Too many pending stat requests'
simon0806
Mar 8, 2017
'Too many pending stat requests'
org.voltdb.jdbc.SQLError.get(SQLError.java:60)
org.voltdb.jdbc.JDBC4Statement$VoltSQL.execute(JDBC4Statement.java:143)
org.voltdb.jdbc.JDBC4Statement.executeQuery(JDBC4Statement.java:458)
org.voltdb.jdbc.JDBC4PreparedStatement.executeQuery(JDBC4PreparedStatement.java:123)
org.voltdb.jdbc.JDBC4DatabaseMetaData.loadSystemInformation(JDBC4DatabaseMetaData.java:62)
org.voltdb.jdbc.JDBC4DatabaseMetaData.<init>(JDBC4DatabaseMetaData.java:53)
org.voltdb.jdbc.JDBC4Connection.getMetaData(JDBC4Connection.java:278)


As show as above, I have use a 80 threads to getMetaData, and then i throws the error. How can I handle it. the code is like :

public class test extends thread {
public void run() {
....
connection.getMetaData();
....
}
}

for(int i = 0; i < 80; i++)
new test().start
bballard
Mar 8, 2017
Hi,

The connection.getMetaData() call invokes a system procedure @SystemInformation. There are special threads on each server that handle system procedure calls, and since these are informational rather than transactions, there is a back-pressure mechanism that returns "Too many pending stat requests" to these calls.

Is the connection.getMetaData() call throwing a SQLException?

If so, you can catch this exception and try calling getMetaData() again until it is successful.

You could avoid this by adding a small delay to when these threads are started or the getMetaData is called, but this shouldn't even be necessary because you can use a single Connection object.

Typically we recommend using a single JDBC connection, which can be shared across multiple threads, as is shown in our JDBC benchmark examples:
./examples/voltkv/client/voltkv/JDBCBenchmark.java
./examples/voltkv/src/voltkv/JDBCBenchmark.java
./examples/voter/client/voter/JDBCBenchmark.java

Many other databases are limited to one synchronous call per connection, so you would use connection pooling and separate connections for each application thread. VoltDB's JDBC driver supports concurrent calls with the same connection, so you can safely share it with multiple application threads.
simon0806
Mar 9, 2017
Thank you for your response, I used to set up connection for each thread, and I will try as your recommend. just one connection and share