Questions tagged [optimistic-locking]

When coordinating updates from multiple database sessions, optimistic locking is a strategy that assumes all updates can complete without conflict. It does not hold locks on any records while the user is editing, but checks to see if any other edits have occurred when the user tries to commit the changes. If two sessions try to edit the same data, the second one to commit will be rejected and have to redo the change. Also see pessimistic locking.

422 questions
0
votes
1 answer

Is there a way to "touch" a document in ArangoDb

I need to be able to "touch" a document (for optimistic purposes) in ArangoDb in order to check and update the _rev without modifying any other data in the document. I have yet to find a way to do this generically with AQL or Javascript Driver…
robross0606
  • 544
  • 1
  • 9
  • 19
0
votes
1 answer

Using LocalDateTime as @Version field with Hibernate 5.3 / JPA 2.2 on Java 11 leads to StaleObjectStateException

Consider an entity called Template with a field: @Version @Column(name = "LAST_UPDATE", nullable = false) private LocalDateTime lastUpdate; // Java 8's class The backing Oracle database field is TIMESTAMP. Now executing the following code: …
0
votes
2 answers

how does lost update differ from non repetable read?

Am trying to understand isolation levels and various issues ..... i.e. dirty read , non repeatable read , phantom read and lost update . Was reading about Non repeatable read Had also read about Lost update what I am confused about is to me both of…
akila
  • 667
  • 2
  • 7
  • 21
0
votes
1 answer

Yii2 how to implementation Optimistic Locks

Yii2 how to implementation Optimistic Locks. I'm trying to follow this official doc. I thought I carefully follow the step. but still error : Here my procedure. Create a column in the DB "version defualt velue = '0' 2.Model.php use…
0
votes
1 answer

Spring JPA repository locking confusion

I have some confusion on the way the locking on Spring JPA repository works and needs some clarification on same. So, I have a Spring boot service in which i am using hibernate to interact with database. In one of the service i have an Entity like…
0
votes
1 answer

Hibernate and "greatest value wins" logic

I have a high_scores table in my database, it has two values: player_id highest_score I need a repository method that saves a new high score. I don't really want to dirty up my code with optimistic lock retry logic for something so simple. What…
Brandon Yarbrough
  • 37,021
  • 23
  • 116
  • 145
0
votes
1 answer

(ObjectOptimisticLockingFailureException) StaleStateException in a single transaction

The code below is deliberately simplified and abridged to avoid unnecessary distraction. I've mysql database with table: CREATE TABLE `payment` ( `id` int(11) NOT NULL AUTO_INCREMENT, `status` varchar(45) DEFAULT NULL, `last_update_date`…
0
votes
1 answer

rails multiple user editing the same record

I have a table in the front end with multiple rows that can be read and edited. Each row has an edit icon that the user will click on, and a dialog will pop up to update the fields in the row. The save button on the dialog will save the fields (call…
gruuuvy
  • 2,028
  • 4
  • 31
  • 52
0
votes
1 answer

Is there any way to make both pessimistic and optimistic locking working in Hibernate

I have an entity like this @Entity @Table(name = "ACC_ACCOUNT_INFO") @Getter @Setter public class AccountInfoEntity implements Serializable { @GeneratedValue(strategy = GenerationType.SEQUENCE, generator =…
mystery
  • 875
  • 6
  • 16
0
votes
1 answer

table per client in database

We developing service were for each client user can make appointment. Is there strategy - table in database (MS SQL SERVER) for each client will be proper? We think such strategy simplifies and exclude complex table locking.
Alexandr
  • 1,452
  • 2
  • 20
  • 42
0
votes
1 answer

ActiveMQ Artemis redelivery delay

Setup: We have a Spring Boot application that is reading messages from an ActiveMQ Artemis JMS queue. The messages are processing in a JPA transaction. When there is an exception triggering a rollback in JPA, it also triggers a JMS rollback in…
0
votes
1 answer

How to handle Optimistic Locked item quantity update with concurrent users?

I have method which updates to Item quantity. MyEntity has @Version annoted version property as long. There is an item list endpoint /items Also there is an item update endpoint /item/update (consider as product stock, buying an item) So N…
0
votes
1 answer

How to implement an optimistic (or pessimistic) locking when using two databases that need to be in sync?

I'm working on a solution in which we have two databases that are used with the following purposes: An Elasticsearch used for search purposes A Postgres database that acts as a source of truth for the data Our application allows users to retrieve…
0
votes
1 answer

openjpa throws optimisticklockexception

I am trying openjpa and jpa. All I have is one entity class as corresponding table in the database. one of the attributes of the entity is username and corresponding row in the db table has varchar2(20). and in my main method what i tried to persist…
BeeRung
  • 1
  • 1
0
votes
1 answer

Spring optimistic lock for MongoDB document with java.util.Date field

I'm trying to implement optimistic locking for documents in an existing MongoDB database. Currently there is no version field and I would like to avoid adding it because we'll have to stop the application. But there is a lastModified date field and…