multiple sessions using transactions

Hi, we are using Java version of IControl API. We are using one and the same test user for multiple, parallel requests. Here is snippet of code that is behaving very inconsistently:

SystemSessionBindingStub sessionStub = interfaces.getSystemSession();

sessionStub.start_transaction();
deleteServer();
interfaces.getManagementPartition().set_active_partition(XXX);
interfaces.getGlobalLBWideIP().delete_wideip(new String[] { "xxx"});
interfaces.getGlobalLBPool().delete_pool(new String[] { "pool" });

sessionStub.submit_transaction();

When only one session is active this works just fine and everything is deleted. But if test user is being used by someone else for other requests at the same time, submit_transaction() throws:

Exception caught in System::urn:iControl:System/Session::submit_transaction() Exception: Common::OperationFailed primary_error_code : 16908289 (0x01020001) secondary_error_code : 0 error_string : No transaction is open to submit.

I suspect that having multiple sessions for the same test user is causing these issues. Am I right? Is there some configuration that will prevent sessions to interfere with each other?

best regards Stoyan

Hi stojoman, you should set a Session Identifier to each request header to prevents multiple concurrent requests.

Please see DevCentral

Here is sample

SystemSessionBindingStub sessionStub = interfaces.getSystemSession();

 //get session identifier
 String session_identifier = String.valueOf(interfaces.getSystemSession().get_session_identifier());

 //set session identifier to each stabs 
 sessionStub.setHeader("urn:iControl", "session", session_identifier);
 interfaces.getGlobalLBWideIP().setHeader("urn:iControl", "session", session_identifier);
 interfaces.getGlobalLBPool().setHeader("urn:iControl", "session", session_identifier);
 ...

 // start transaction
 sessionStub.start_transaction();

 // do something
 ...

 // submit transaction  
 sessionStub.submit_transaction();

In addition,

set_active_partition()

is not support Session, you need to use

sessionStub.set_active_folder()

.

Hi uchi, thank you for your proposal. Adding session_id to each request solved some of my problems. Unfortunately running two transactions in parallel with the same user is still not working. Is this supported by IControl - Can a single user start more than one transaction at the same time? best regards Stoyan

I’ll have to go back and look, but I believe the transaction id is stored in-memory on the server side within the given user’s context. If you have two sessions starting and ending transactions, if the first ends the transaction after the second creates one, the second’s end will likely fail as it’s been removed by the first session.

If you need to use the same user account for multiple transactions, I’d recommend using the System.SystemInfo locking mechanisms to acquire and release locks. These are again, just server settings in the user context, but you can use them tell another parallel session that work is in progress by the same user. I discussed those interfaces in this article: https://devcentral.f5.com/articles/concurrent-icontrol-programming-explained.

Hope this helps…

-Joe