Bug 63406 - JDBC connection configuration: new option for pre-initialize to initialize the connection pool
Summary: JDBC connection configuration: new option for pre-initialize to initialize th...
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 5.1.1
Hardware: All All
: P1 enhancement (vote)
Target Milestone: JMETER_5.2
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2019-05-06 12:37 UTC by Franz Schwab
Modified: 2019-07-22 19:54 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Franz Schwab 2019-05-06 12:37:23 UTC
Hello JMeter developers,

I would like to suggest an enhancement to the JDBC connection configuration:
An option (true/false) where you can choose to pre-initialize the JDBC connection pool.
The default option should be "false", in order to not break existing behavior.

Currently, you get longer execution times for the first JDBC request for each thread of a thread group,
because the JDBC pool is only initialized when the first JDBC request asks the JDBC connection pool for a connection to execute its sql query.

Initialization currently also means: initializing the whole pool - before any JDBC request sampler is given a connection.
That means that each JDBC request, that is started before the connection pool is fully initialized, is affected by measuring connection establishment times for each of the following KPIs:
Elapsed time, latency, connect time.

There would also be an argument for setting the default option to be "true" and break existing behavior - as it doesn't make sense to measure "connect time" for example:
Because "connect time" for the first query doesn't mean "connection establishment time for one connection" - it currently means "connection establishment time for the whole pool".
The bigger the pool, the bigger the effect.

I know there are workarounds for this (e.g. a setup thread group). But then you have the sampler times even of that setup thread group in your result.jtl file.
I know there is an option to use a JSR223 post processor, sending some Groovy code like "prev.setIgnore()". But this is not very user friendly.

Here is what I found regarding the connection pooling library:
https://commons.apache.org/proper/commons-dbcp/apidocs/org/apache/commons/dbcp2/BasicDataSource.html#setInitialSize-int-
it says: "The pool is initialized the first time one of the following methods is invoked: getConnection, setLogwriter, setLoginTimeout, getLoginTimeout, getLogWriter."

https://commons.apache.org/proper/commons-dbcp/apidocs/org/apache/commons/dbcp2/BasicDataSource.html#getLogWriter--
it says: "Calls createDataSource(), so has the side effect of initializing the connection pool."

Using the side effect in our favour, here is my suggested change (currently hardcoded) - I need to add in in the GUI as an option of course - before asking for a git pull request:
https://github.com/frschwab/jmeter/commit/8dd8462f9349b990640f3e2290c84f23a715a7c5

Thanks for any feedback on this.
Best regards,
Franz
Comment 1 Franz Schwab 2019-05-10 15:02:47 UTC
current work status from my side:
https://github.com/frschwab/jmeter/commit/102f0ac58af82a28e01565047f3d114366996231
do you have any comments? Otherwise I am asking for a pull request in the next days.
I would be happy to get some feedback!
Comment 2 Philippe Mouawad 2019-05-14 15:19:40 UTC
(In reply to Franz Schwab from comment #1)
> current work status from my side:
> https://github.com/frschwab/jmeter/commit/
> 102f0ac58af82a28e01565047f3d114366996231
> do you have any comments? Otherwise I am asking for a pull request in the
> next days.
> I would be happy to get some feedback!

Hello,
First thanks for contributing,  it's great !

I have looked at PR and left one comment .

Regards
Comment 3 Franz Schwab 2019-05-14 17:00:08 UTC
Thanks for the comment, here my reply:
https://github.com/frschwab/jmeter/commit/102f0ac58af82a28e01565047f3d114366996231#commitcomment-33533415
Best regards,
Franz
Comment 4 Philippe Mouawad 2019-06-08 13:02:05 UTC
Hello Franz,
Do you plan to submit a PR ?

Thanks
Comment 5 Franz Schwab 2019-06-13 07:26:00 UTC
Hi Philippe,

I assume some tests would be necessary before submitting a pr request?
I didn't find the time yet to do so.

Best,
Franz
Comment 6 Philippe Mouawad 2019-06-13 19:56:38 UTC
(In reply to Franz Schwab from comment #5)
> Hi Philippe,
> 
> I assume some tests would be necessary before submitting a pr request?
> I didn't find the time yet to do so.
> 
> Best,
> Franz

Hi Franz, yes we prefer a Junit clearly.
But you could submit a PR and then commit a JUnit test.
This way you can start getting feedback.

Please note we have migrated now to Git directly , so you may need to either reclone it or follow this procedure:

- https://github.com/vlsi/jmeter-git-cleanup/tree/v2.2.0/clean_fork

Thanks
Comment 7 Franz Schwab 2019-07-11 13:32:57 UTC
pull request here: https://github.com/apache/jmeter/pull/477
Comment 8 Philippe Mouawad 2019-07-22 19:54:09 UTC
Fixed within commit:

- https://github.com/apache/jmeter/commit/031807aed3d8365513b9e0689ce599bc5d97ddc1