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

224 questions
3
votes
1 answer

Update query in LINQ contains all columns in WHERE clause instead of just the primary key column

I am updating a single column in a table using Linq, take fictitious table below. MyTable (PKID, ColumnToUpdate, SomeRandomColumn) var row = (from x in DataContext.MyTable where b.PKID == 5 select…
Radderz
  • 2,770
  • 4
  • 28
  • 40
3
votes
1 answer

Optimistic concurrency control clarification

I am new to ES7 and trying to understand optimistic concurrency control. I think I understand that when I get-request a document and send its _seq_no and _primary_term values in a later write-request to the same document, if the values differ, the…
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
  • 6,464
  • 1
  • 28
  • 56
3
votes
1 answer

ThreadLocal.get() returning null, even when I'm initializing it before

I feel like I might be misunderstanding how this should work. I have this code: public Timestamp startTransaction() { cleanupTransactionContext(); Timestamp timestamp = getLatestTimestamp(); initThreadLocalVariables(timestamp); …
jlasarte
  • 623
  • 8
  • 28
3
votes
3 answers

Is adding ETag to strongly typed model really a bad idea?

I am implementing an optimistic concurrency with DocumentDb API using .NET SDK. On several places i have found mentioning that having ETag on strongly typed model is a bad idea. Explicitly…
dee zg
  • 13,793
  • 10
  • 42
  • 82
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
3
votes
2 answers

Grails optimistic locking doesn't detect concurrent update?

Is optimistic locking supposed to catch concurrent update issues? By concurrent update, I mean that two different users both attempt to update an object with the same version number. For example, if there is a Person domain class, and Person with…
3
votes
0 answers

Doctrine2 - Best way for retrieving two differents objects of a same entity

I'm working on a tool for concurrency with Doctrine 2. I'm facing a "best practice" issue to retrieve a new instance of an entity without cache (the idea after that is to be able to compare some properties from 2 differents objects of the same…
3
votes
1 answer

Spring MVC: Validation, Post-Redirect-Get, Partial Updates, Optimistic Concurrency, Field Security

[This is a list of common questions I see about Spring MVC, which are solved in similar ways. I've posted them here, so I can easily refer to them from other questions] How do I update only a few fields of a model entity with forms? How do I use the…
3
votes
0 answers

Why do you need SpinWait in LockFreeUpdate sample from Albahari's "Threading in C#"

I am working on small Ref abstraction with lock-free optimistic Update method (supposed to work with immutable T data structures, immutable trees in particular). It is based on Albahari's "Threading in C#" LockFreeUpdate method in SpinWait usage…
dadhi
  • 4,807
  • 19
  • 25
3
votes
1 answer

RavenDB keeps throwing a ConcurrencyException

I keep getting a ConcurrencyException trying to update the same document multiple times in succession. PUT attempted on document '' using a non current etag is the message. On every save from our UI we publish an event using MassTransit. This…
Guillaume Schuermans
  • 906
  • 2
  • 12
  • 28
3
votes
1 answer

Hibernate/JPA version concurrency control and DTO/change command patterns

I would like to use @Version for optimistic concurrency control with JPA & Hibernate. I know how it works in the typical scenario of two parallel transactions. I also know that if I have a CRUD with 1:1 mapping between the form and entity, I can…
Konrad Garus
  • 53,145
  • 43
  • 157
  • 230
3
votes
2 answers

Entity Framework entity update ignoring timestamp

I'm trying to implement optimistic concurrency checking. I make use of the generic repository and unit of work patterns. I have introduced a Timestamp-attributed property (as byte array) to my entity, which increases the value automatically whenever…
2
votes
1 answer

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

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…
nize
  • 1,012
  • 1
  • 11
  • 27