optimistic-locking

Dynamo DB Optimistic Locking Behavior during Save Action

亡梦爱人 提交于 2019-12-24 09:59:30
问题 Scenario: We have a Dynamo DB table supporting Optimistic Locking with Version Number. Two concurrent threads are trying to save two different entries with the same primary key value to that Table. Question: Will ConditionalCheckFailedException be thrown for the latter save action? 回答1: Yes, the second thread which tries to insert the same data would throw ConditionalCheckFailedException . com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException As soon as the item is saved in

PHP/MySQL/jQuery Pessimistic Locking of Record

左心房为你撑大大i 提交于 2019-12-22 09:08:12
问题 I've been thinking about developing some simple record locking for an application I'm involved in. There are a few users who will take literally hours to complete an edit of a record. This causes issues when someone else wants to make a change to the record. Currently there is no locking involved. I'm not certain that Optimistic locking is reliable in my case, as the record is saved thru an AJAX request. I'm looking at applying some kind of Pessimistic Locking; using two fields, such as,

How to do concurrent modification testing for grails application

可紊 提交于 2019-12-21 04:08:36
问题 I'd like to run tests that simulate users modifying certain data at the same time for a grails application. Are there any plug-ins / tools / mechanisms I can use to do this efficiently? They don't have to be grails specific. It should be possible to fire multiple actions in parallel. I'd prefer to run the tests on functional level (so far I'm using Selenium for other tests) to see the results from the user perspective. Of course this can be done in addition to integration testing if you'd

Hibernate (JPA): how to handle StaleObjectStateException when several object has been modified and commited

笑着哭i 提交于 2019-12-19 09:00:44
问题 Consider the scenario: A Db transaction envolving more than one row from different tables with versioning. For example: A shopLists and products. Where a shopList may contain products (with their amount in the shoplist) and products have their current stock. When I insert ou edit a shopList, I want the stock of those products in the shopList to be updated to keep the stock consistant. To do that, I open a transaction, insert/update the shopList, update the stocks for each product (apply delta

How do you implement a coarse-grained optimistic lock in REST?

左心房为你撑大大i 提交于 2019-12-19 00:57:17
问题 I have implemented optimistic locking for my REST resources that have 1-to-1 mapping to database tables by passing back a version number which was in the GET back through to the PUT call. If the version number changed in the database between the time I did the GET and the PUT, then an optimistic lock exception has occurred. Pretty simple design. Now, how do I do the same for composite REST resources that map to multiple database tables? I'd like to not have to pass back multiple version

Hibernate session not refreshing data from DB after initial commit failure

夙愿已清 提交于 2019-12-13 19:25:42
问题 I am working on a multithreaded Java application that uses Hibernate . We are getting a org.hibernate.StaleObjectStateException because we have optimistic locking in place and a certain entity (let's call it Pojo ) is updated from many application modules, which can and have collided in race conditions (I have not designed the application). The problematic code block looks something like this: Transaction txn = null; HibernateException ex = null for(int retryAttempt = 0; retryAttempt < 5;

How to use optional attributes in web service update messages (DTOs)?

余生颓废 提交于 2019-12-13 15:33:15
问题 BACKGROUND Assume you have a (SOAP) web service, BookService , managing books in a library. In the information model assume that the Book entity has the following attributes: id author publisher title shelfId In order to manipulate the data four web service operations are defined: AddBook GetBook UpdateBook DeleteBook Request and response message are defined for each operation. However, the design of the update message XML schemas is more complicated. We would like to achieve the following

Can Hibernate's @Version consider changes in related entities?

拈花ヽ惹草 提交于 2019-12-12 15:08:22
问题 I have 2 entities: Parent and Child in a one-to-many relationship. The Parent is versioned, i.e. has a @Version field. My goal is to synchronize changes to both Parent and Child entities on the Parent 's version. E.g. one thread updates the Parent and another one updates one of it's Child s, this should cause an OptimisticLockException. Is it possible? I tried adding a @PreUpdate to the Child which would increment the version of it's Parent , but that didn't help because Hibernate seems to

Recovering from hibernate optimistic locking exception

夙愿已清 提交于 2019-12-12 09:27:09
问题 I have a method like this: @Transactional(propagation = Propagation.REQUIRES_NEW) public void doSomeWork(){ Entity = entity = dao.loadEntity(); // do some related work ... try { dao.saveEntity(entity); } catch(StaleObjectStateException sose){ dao.flush(entity); doSomeWork(); } } I was expecting that by using REQUIRES_NEW transaction propagation and the recursion shown, the StaleObjectStateException would eventually clear but this isn't the case. How do I recover from this exception? 回答1:

Could there be a deadlock when using optimistic locking?

南笙酒味 提交于 2019-12-12 08:58:43
问题 As is known, there are two locking strategy: Optimistic vs. Pessimistic locking Pessimistic Locking is when you lock the record for your exclusive use until you have finished with it. It has much better integrity than optimistic locking but requires you to be careful with your application design to avoid Deadlocks. Also knonw, that Optimistic Concurrency Control is not the same as Multi Version Concurrency Control (Oracle or MSSQL-Snapshot/MVCC-RC): Optimistic vs Multi Version Concurrency