Domino V12 EAP contains new methods to manage code transactions. The underlying C API has been there for quite some time, but I've never really looked at it. Now it's finally official and you will be able to leverage these new features in your apps.
The EAP program is currently only shipped as a Docker container, which makes the testing a bit hard - you don't have Domino Designer or easy access to the JVM. The only ways to test the APIs that I could think of were:
- Try to import the code using DXL on the server - should work for LotusScript
- Try server-side XPages compilation, e.g. using Jesse's NSF ODP Tooling
- Build a jar file locally using V12 Notes.jar and reuse that
The last option seemed to be the easiest one and before I had a chance to try it, Ulrich Krause has used that in his test with Java server addin - https://www.eknori.de/2020-11-01/testing-new-database-methods-in-domino-v12-early-access-without-domino-designer-v12/
I wanted to have something more interactive, so I just use the jar from XPages app.
Testing
So far I've executed just a few scenarios. My primary goal was to find out how close to standard ACID transactions we can get.
Test 1 - simple positive run
Nothing fancy about this. The steps are:
- start a transaction
- create and save a document
- commit the transaction
I use db.search to verify number of documents in the database.
Test 2 - rollback
This is getting a bit more interesting. A rollback - something new for Domino devs.
The code is the same, I just call rollback instead of a commit.
Test 3 - concurrent access
Transactions for a single thread/single-user operations are easy, the real problems start to appear oce things start to happen in parallel.
I've now added a 5s sleep before the rollback, so I can run this in 2 different browser windows.
All looks good at first sight. The problem is that I definitely did not need 5 seconds to click the button in my second window, so it can only mean that the second execution got blocked for some time, until the first one was closed (with a rollback). This could be easily verified by running one of the previous tests in parallel to the Test 3 - and yes. While alone it was instant, now it finished after the Test 3 execution.
Test 4 - view access
When you have some more complex logic in your app, you may need to do some additional lookups during your transaction. I knew that this is going to be a bit tricky and I was wondering how HCL is handling this as the view index has its own life.
To test this, I've added a check to count all views in a view. First, right after the start of the transaction and then after the save.
Now the result is not so good - I got an exception. After further testing, it seems that once you save a document in a transaction, you can no longer access any view (not just views that contain the document).
More to follow
I have not tried DQL or any other operations yet, but I guess I'll do it soon.
Conclusion
Access to the transation APIs is definitely a step forward, but HCL will need to document the limitations. So far it seems to me that once you save a document in a transaction, you basically block all other transactions from being executed and you lose access to views in that database. It completely makes sense as the primary goal of a transactional system is to keep itself in a consistent state, but it will cause a huge performance penalty if not used carefully. It will be also interesting to see how a mix of transactional and non-transactional code behaves.
Code for the test is on github
<xp:panel id="t3">
<xp:button value="Test 3" id="button3">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:var tc = new net.pristo.domino.transtest.TestRunner();
viewScope.tr3 = tc.Test03(database);}]]></xp:this.action>
</xp:eventHandler></xp:button>
<br/>
<xp:inputTextarea id="inputTextarea3" readonly="true"
value="#{viewScope.tr3}">
</xp:inputTextarea>
</xp:panel>
Comments
Post a Comment