You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I'm trying to troubleshoot problem of queries not executing concurrently.
I have a stored procedure in DB, which simply waits for specified number of seconds and then returns:
CREATE OR REPLACE FUNCTION test_sleep (x float) RETURNS float STABLE as $$
from time import sleep
sleep(x)
return x
$$ LANGUAGE plpythonu;
select test_sleep(15);
Running test, which creates 1 connection pool with maxpoolsize: 10, executes select test_sleep(10); 4 times in parallel: test executes in 14 seconds, which is fine.
Running test, which creates 1 connection pool with maxpoolsize: 10, executes select test_sleep(10); 5 times in parallel: test executes in 22 seconds, which is not acceptable. It executes first 4 on one go, and then executes last command in a separate go.
Repeated above test multiple times - timing results are the same.
Running test, which creates 1 connection pool with maxpoolsize: 10, executes select test_sleep(10); 10 times in parallel. Here's how it executes:
[00:00] Start querying
[00:17] Query #1 wait 10 seconds returned ResulSet
[00:17] Query #2 wait 10 seconds returned ResulSet
[00:17] Query #3 wait 10 seconds returned ResulSet
[00:17] Query #4 wait 10 seconds returned ResulSet
[00:28] Query #5 wait 10 seconds returned ResulSet
[00:28] Query #6 wait 10 seconds returned ResulSet
[00:28] Query #7 wait 10 seconds returned ResulSet
[00:28] Query #8 wait 10 seconds returned ResulSet
[00:28] Results read from ResultSet #1: 1 row
[00:28] Results read from ResultSet #2: 1 row
[00:28] Results read from ResultSet #3: 1 row
[00:28] Results read from ResultSet #4: 1 row
[00:28] Results read from ResultSet #5: 1 row
[00:28] Results read from ResultSet #6: 1 row
[00:28] Results read from ResultSet #7: 1 row
[00:28] Results read from ResultSet #8: 1 row
[00:39] Query #9 wait 10 seconds returned ResulSet
[00:39] Results read from ResultSet #9: 1 row
[00:39] Query #10 wait 10 seconds returned ResulSet
[00:39] Results read from ResultSet #10: 1 row
[00:39] Finished querying
So it's already 2 problems:
(A) concurrency cap is only 4 queries
(B) resultSet.toObjectIter(...) lag caused by other concurrent queries
Running same with one connection pool per query yields same result.
Launching same JS test script from command line 10 times in parallel, 1 query each: executes fine, 14 seconds in overall.
Further tests showed, that after some work-time connection pool fails to asynchronize randomly even for 3 concurrent queries.
So, we had to workaround this by doing node process fork, and thus handling all DB querying in subprocesses, each having own connection pool with size 1. This works, although memory/CPU consumption becomes awful. But now we don't have time to rewrite our system on Java...
Hello I'm trying to troubleshoot problem of queries not executing concurrently.
I have a stored procedure in DB, which simply waits for specified number of seconds and then returns:
Running test, which creates 1 connection pool with
maxpoolsize: 10
, executesselect test_sleep(10);
4 times in parallel: test executes in 14 seconds, which is fine.Running test, which creates 1 connection pool with
maxpoolsize: 10
, executesselect test_sleep(10);
5 times in parallel: test executes in 22 seconds, which is not acceptable. It executes first 4 on one go, and then executes last command in a separate go.Repeated above test multiple times - timing results are the same.
Running test, which creates 1 connection pool with
maxpoolsize: 10
, executesselect test_sleep(10);
10 times in parallel. Here's how it executes:[00:00] Start querying
[00:17] Query #1 wait 10 seconds returned ResulSet
[00:17] Query #2 wait 10 seconds returned ResulSet
[00:17] Query #3 wait 10 seconds returned ResulSet
[00:17] Query #4 wait 10 seconds returned ResulSet
[00:28] Query #5 wait 10 seconds returned ResulSet
[00:28] Query #6 wait 10 seconds returned ResulSet
[00:28] Query #7 wait 10 seconds returned ResulSet
[00:28] Query #8 wait 10 seconds returned ResulSet
[00:28] Results read from ResultSet #1: 1 row
[00:28] Results read from ResultSet #2: 1 row
[00:28] Results read from ResultSet #3: 1 row
[00:28] Results read from ResultSet #4: 1 row
[00:28] Results read from ResultSet #5: 1 row
[00:28] Results read from ResultSet #6: 1 row
[00:28] Results read from ResultSet #7: 1 row
[00:28] Results read from ResultSet #8: 1 row
[00:39] Query #9 wait 10 seconds returned ResulSet
[00:39] Results read from ResultSet #9: 1 row
[00:39] Query #10 wait 10 seconds returned ResulSet
[00:39] Results read from ResultSet #10: 1 row
[00:39] Finished querying
So it's already 2 problems:
(A) concurrency cap is only 4 queries
(B)
resultSet.toObjectIter(...)
lag caused by other concurrent queriesRunning same with one connection pool per query yields same result.
Launching same JS test script from command line 10 times in parallel, 1 query each: executes fine, 14 seconds in overall.
Here is the code:
Connection pool initialisation options:
Java version:
DB maximum concurrent connections per user: 15.
Any ideas what might have went wrong?
The text was updated successfully, but these errors were encountered: