Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC connection configuration: new option for pre-initialize to initialize the connection pool #5059

Closed
asfimport opened this issue May 6, 2019 · 8 comments

Comments

@asfimport
Copy link
Collaborator

Franz Schwab (Bug 63406):
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:
frschwab@8dd8462

Thanks for any feedback on this.
Best regards,
Franz

OS: All

@asfimport
Copy link
Collaborator Author

Franz Schwab (migrated from Bugzilla):
current work status from my side:
frschwab@102f0ac
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!

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
(In reply to Franz Schwab from comment 1)

current work status from my side:
https://github.com/frschwab/jmeter/commit/
102f0ac
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

@asfimport
Copy link
Collaborator Author

Franz Schwab (migrated from Bugzilla):
Thanks for the comment, here my reply:
frschwab@102f0ac#commitcomment-33533415
Best regards,
Franz

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Hello Franz,
Do you plan to submit a PR ?

Thanks

@asfimport
Copy link
Collaborator Author

Franz Schwab (migrated from Bugzilla):
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

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
(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:

Thanks

@asfimport
Copy link
Collaborator Author

Franz Schwab (migrated from Bugzilla):
pull request here: #477

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Fixed within commit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant