[CDO] Commit Exception on the second commit after thread interruption [message #1863579] |
Mon, 12 February 2024 10:18  |
Eclipse User |
|
|
|
We are experiencing a strange behavior (CDO Version 4.23.0) in case of a thread interruption while setting model attributes. This only occurs in case that the transaction uses a CDOMergingConflictResolver.
It can be reproduced as follows:
* Open an object in a transaction
* Modify the object in a thread which is interrupted (which throws an exception, which is fine)
* Commit the transaction in the original thread => everything looks good, also the value is correct
* Modify the object again and commit it => Unexpected commit exception: "Attempt by Transaction[2:1] to modify historical revisions: (...)"
This problem was a bit difficult to track down, because the error only happens on the second commit. Is there any way to recover from this state "trying to modify a historical revision"? Committing the transaction a second time does not help. Rolling back does help, but I would like to prevent it.
It can be reproduced with the following code:
public void testCase() throws Exception
{
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
transaction.options().addConflictResolver(new CDOMergingConflictResolver());
OrderDetail orderDetail = getModel1Factory().createOrderDetail();
orderDetail.setPrice(1);
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
resource.getContents().add(orderDetail);
transaction.commit();
Thread t = new Thread(() -> {
Thread.currentThread().interrupt();
orderDetail.setPrice(2);
});
t.start();
t.join();
transaction.commit();
orderDetail.setPrice(3);
transaction.commit();
}
|
|
|
|
Powered by
FUDForum. Page generated in 0.04356 seconds