HibernateException in patient registration workflow

I’ve the following environment setup on my development machine: Platform version: 1.11.5 Reference Application version: 2.3.1 + bundled modules

The patient registration just works fine when operated from browser when number of users are less and there’s a less/no traffic. But, to test the performance of the system for higher loads I developed a JMeter script of the workflow and ran it for more than 2 users concurrently and got the following exception:

org.hibernate.HibernateException: illegally attempted to associate a proxy with two open Sessions

What could be the possible cause for the same??

So far I’ve found that the PatientDAO creates entry into both Person and Patient table on executing savePatient method.

Can you give the full stack trace?

Stack Trace: http://pastebin.com/m2sVzG4B

That’s very strange, the Hibernate session is a thread local and you have 2 threads sharing the same proxy. You may try either using distinct objects or unproxying it before saving.

Is this easy to reproduce in a unit test? If not, if in checkPatientIdentifiers(), you changed Context.getPatientService().getPatientIdentifierTypes() to getPatientIdentifierTypes(), would the problem persist?

@dkayiwa changing Context.getPatientService().getPatientIdentifierTypes() to getPatientIdentifierTypes() doesn’t solve the problem but the stack trace has changed marginally: http://pastebin.com/uvt9wH1n

@lluismf can you share some details about your suggestion ??

Can you share your code? I don’t know what’s a “JMeter script”.

JMeter is a load testing tool. I’ve a test plan that can request provided URL against defined set of users/threads. I’m running into above mentioned issue where I try to run more than 5 parallel threads through patient registration workflow(using POST request).

Each thread should create a new Hibernate session (a web filter does that), I don’t see how the same proxy is shared between them.

I’ve seen this error before and it’s actually possible, it is common when you open a new session within a thread that already has another open session. Can you share you code please?

@wyclif, I’m using the exact same code from module RegistrationApp-1.4 . I haven’t altered anything as far as code is concerned. Just trying to test the application against varied loads supplied from JMeter (Performance Testing).

Note: The register patient workflow fails with the above error when I run tests with 5 parallel threads/users.

Then it is a bug somewhere in the code, can you create a ticket with details of how to reproduce it please?

Created an issue:

I wonder if this may be the cause of the issue:

I don’t think so, transactions and Hibernate sessions are two different things.