JMeter JDBC manual commit

Viewed 848

I'm using JMeter to do some load testing, and need to run a test which inserts a few thousand records. Part of the requirement is that it should not commit each individual update, but only commit every thousand records. Seems pretty straightforward, but I cannot find any examples or documentation explaining how to do a manual commit in JMeter, and I can't get it to work.

I've got it set up to read a few entries from a csv file, plus a counter variable for an incrementing ID field. If auto commit is enabled, that works fine.
When I disable auto commit, nothing gets committed -- as you'd expect. But how DO I get it committed? I can't even get it to commit every update without auto commit, let alone a specified rate.

  • I tried adding a JDBC post processor with a commit statement and/or commit query type, on the same DB connection pool, only one thread on that pool and in the test, but that doesn't work.
  • Tried doing the same as a separate JDBC request, that didn't work either.
  • Tried adding the commit to my update statement itself, no luck.
  • Tried changing transaction isolation, but none of those values seem to make a difference.
  • Tried opening a transaction with a pre-processor or a request or within the existing request, but that also hasn't helped.

I assume my problem might be that the commit is going into a separate transaction from the actual update statements...but I can't find any way to change that...

1 Answers

Try doing the following:

  • Add a JDBC Request with Query Type set to AutoCommit(false)
  • Put your JDBC Requests as you want
  • Add a JDBC Request with Query Type set to Commit

Your plan should look like this:

Overview and config

Fist set autocommit to false:

set autocommit to false

Then call your update queries:

your SQL queries

Finally commit:

commit

Reset autocommit to true:

reset autocommit

If this does not work, I suggest you report an issue to JMeter.

Related