MySQL Forums
Forum List  »  NDB clusters

Re: Exception on get method clusterj
Posted by: Craig Russell
Date: April 18, 2015 05:09PM

Arco van der Velden Wrote:
-------------------------------------------------------
> Hi,
>
> I assume you mean a boundary issue of BigDecimal.

Yes, that is what I meant.

> This isn't the case since this is a test
> application every transaction is adding 1 to the
> total attribute.
> When we test with 5000 transactions (spread over
> 16 threads) the error occurs but the value of
> total can not be over 5000 in this case.
> One thing to mention is after the error occurs the
> transaction isn't active anymore so it cannot be
> rolled back, because of the error.

Right. The code in your original message uses auto-commit so each session method begins a new transaction and either commits or rolls back before returning.

You mention that this code runs in multiple threads. The exception is possibly multi-thread related. How do you ensure that each thread has its own copy of the session and the positionsInterface object?

If you have multiple threads trying to update the same row in the database, the code won't work properly. In order to avoid multiple threads getting the same state and updating the row to the same (incorrect) value, you should use transactions and locking.

You should set the lock mode to EXCLUSIVE, begin a transaction, read the row, either insert or update the row, and commit (or roll back) the transaction. That will enforce the proper locking semantics.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Exception on get method clusterj
946
April 18, 2015 05:09PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.