Questions tagged [optimistic-concurrency]

A concurrency control method applied to transactional systems that allows multiple transactions to frequently complete for resources without interfering with each other

A concurrency control method applied to transactional systems such as relational database management systems and software transactional memory. OCC assumes that multiple transactions can frequently complete without interfering with each other. While running, transactions use data resources without acquiring locks on those resources. Before committing, each transaction verifies that no other transaction has modified the data it has read.

Optimistic concurrency is generally used in environments with a low contention for data. Optimistic concurrency improves performance because no locking of records is required, and locking of records requires additional server resources. Also, in order to maintain record locks, a persistent connection to the database server is required.

http://en.wikipedia.org/wiki/Optimistic_concurrency_control
http://msdn.microsoft.com/en-us/library/aa0416cz%28v=vs.110%29.aspx

209 questions
4
votes
2 answers

Event store and optimistic concurrency

Greg Young in his document on CQRS in the "Building an event storage" section, when writing events to the event store he checked for optimistic concurrency. I do not really get why he made that check, can anyone explain to me with a concrete…
4
votes
3 answers

ProstgreSQL, MySQL optimistic concurrency

I have a web application in which data can be changed concurrently by the users. At the moment I include the old row values in each form and update the row only if the data is the same. With SQLite this to be the only option. This is ugly and I…
user141335
4
votes
2 answers

How I can avoid optimistic concurrency exception when I delete rows?

I have a method that receive the IDs of some rows to delete. I am using a code like this: public bool delete(IEnumerable paramIeId) { using(myContext) { foreach(long iterator in paramIeId) { …
Álvaro García
  • 15,452
  • 25
  • 82
  • 152
4
votes
1 answer

How to handle org.eclipse.persistence.exceptions.OptimisticLockExceptio

I want to handle concurrent execution by using Optimistic Locking. I have included @Version annotation in my entity class. In my code I am running two threads concurrently. Sometimes it is executing correctly. Sometimes it is throwing…
4
votes
1 answer

Optimistic locking with redis using GET and INCR

I want to "lock" a block of code optimistically. psuedo code is as follows: revision = GET('lock_key') # default as 0 { <> } new_revision = INCR('lock_key') if new_revision != revision + 1: raise Exception # now retry or…
lazy functor
  • 1,858
  • 2
  • 14
  • 15
4
votes
1 answer

Azure Table Storage Concurrency Issue

It seems like concurrency conflicts with Azure throw an exception with a message containing the error code 412. Is there a good way to tell that an exception is thrown due to a concurrency problem other than checking if the error message of a…
Teeknow
  • 1,015
  • 2
  • 16
  • 36
4
votes
1 answer

Entity Framework, PostgreSQL, Optimistic Concurrency with hidden xmin column

I'm working with Entity Framework (Model First approach) against a PostgreSQL 9.1 database. You probably all know that every table has a hidden column called xmin that I would use to help EF determine if the row has changed before performing an…
Olivier MATROT
  • 3,763
  • 4
  • 37
  • 66
4
votes
3 answers

Empty Dictionary Error on Delete with SqlDataSource - ASP.net ListView

I'm trying to make a simple ListView with optimistic concurrency. It uses the VS-automatically-generated Delete, Insert, Update statements (except 1 change to insert: see code). Insert and Edit work fine and commit to the database. When trying to…
3
votes
1 answer

optimistic concurrency with timestamp and typed dataset in asp.net

i'm creating a forum system for my web site with the use of c# and asp.net and for data access i'm using a typed dataset and for UI i'm using mvp pattern. in my database i have stored procedures which i have been added to my dataset. the problem was…
jim
  • 384
  • 2
  • 4
  • 23
3
votes
3 answers

Concurrency when deleting object in Entity Framework

I'm developing a web app using the entity framework. I load a list of objects and bind it to a repeater to show a summary of all the items. The user may click an edit icon or a delete icon for each item in the repeater. Example: Item 1 | Edit |…
3
votes
1 answer

Using NHibernate (and Fluent NH) to map datetime-type version columns with better than second accuracy (and not truncate milliseconds)

I have a table with a datetime-type column as the version. It's a legacy DB so I can't possibly change it to datetime2 or use a different versioning mechanism. The NHibernate class is mapping this to a DateTime c# typed property. I've seen several…
3
votes
1 answer

Optimistic concurrency control and write skew

I feel kind of stupid asking this question, but to clear things out, sometimes stupid questions must be asked :) So, we can define a write skew as Martin Kleppmann did in his talk: Write skew pattern: 1. read something 2. make a decision 3.…
3
votes
0 answers

Correct way of implementing optimistic concurrency with NEventStore

This is a beginner question, because I don't have any experience in using NEventStore and I'm giving it a try. The point of this question is related to the concept of optimistic concurrency check as envisioned by Greg Young in this document for…
Enrico Massone
  • 3,539
  • 1
  • 18
  • 28
3
votes
4 answers

I don't understand how can optimistic concurrency be implemented in C++11

I'm trying to implement a protected variable that does not use locks in C++11. I have read a little about optimistic concurrency, but I can't understand how can it be implemented neither in C++ nor in any language. The way I'm trying to implement…
Dan
  • 1,837
  • 12
  • 33
3
votes
2 answers

2 threads performing myAtomicReference.compareAndSet(expected,new Date())

static boolean unsynchronizedSetter(Date expected){ Date newDate = new Date(); AtomicReference myAtomicReference = Lookup.getAtomicRef(); boolean myStatus = myAtomicReference.compareAndSet(expected, newDate); //CAS return…
tanbin
  • 31
  • 2
1 2
3
13 14