optimistic-concurrency

MySQL - Avoid to select, and update, the same record on repeatable_read

巧了我就是萌 提交于 2021-02-11 13:52:46
问题 i'm developping a PHP service that need to get a unique TOKEN from a MySQL table. The table is like: ID TOKEN ID_PROCESS 1 AAAAA 0 2 BBBBB 0 3 CCCCC 0 The table has millions of records with already generated TOKEN. I need to be extra sure that, for example, the record with ID = 1 is selected and then updated ( UPDATE table set ID_PROCESS = 123 WHERE ID = 1) from one user and that nobody else could select it and then update it overwriting the former update. For selecting an available TOKEN i

MySQL - Avoid to select, and update, the same record on repeatable_read

半城伤御伤魂 提交于 2021-02-11 13:51:21
问题 i'm developping a PHP service that need to get a unique TOKEN from a MySQL table. The table is like: ID TOKEN ID_PROCESS 1 AAAAA 0 2 BBBBB 0 3 CCCCC 0 The table has millions of records with already generated TOKEN. I need to be extra sure that, for example, the record with ID = 1 is selected and then updated ( UPDATE table set ID_PROCESS = 123 WHERE ID = 1) from one user and that nobody else could select it and then update it overwriting the former update. For selecting an available TOKEN i

mongoDB optimistic concurrency control for update

你离开我真会死。 提交于 2021-01-28 05:25:09
问题 I am simulating multiple concurrent request for MongoDB`s "update". Here is the thing, I insert a data amount=1000 in mongoDB, and every time I trigger the api, it will update the amount by amount += 50 and save it back to database. Basically it is a find and update operation on a single document. err := globalDB.C("bank").Find(bson.M{"account": account}).One(&entry) if err != nil { panic(err) } wait := Random(1, 100) time.Sleep(time.Duration(wait) * time.Millisecond) //step 3: add current

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

假装没事ソ 提交于 2020-12-26 10:03:37
问题 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 x).FirstOrDefault(); row.ColumnToUpdate = 20; DataContext.SubmitChanges(); This updates the column to as expected, no surprises here. However when I inspect the SQL commands which are generated, it does this: UPDATE [dbo].[MyTable ] SET [ColumnToUpdate ] = @p2 WHERE ([PKID] = @p0) AND (

Does MySQL have an equivalent of SQL Server rowversion?

守給你的承諾、 提交于 2020-01-13 11:23:10
问题 I am migrating a SQL Server database schema over to MySQL. Some of the tables on SQL Server have a column of type rowversion. This is an integer value that is set when the row is first inserted and then again each time any column of the row is updated. The number is only ever incremented. We make use of this to check for concurrency problems. So when an insert comes to the server we can check if the incoming value is different to the current stored value. If so, then the row has been updated

Does MySQL have an equivalent of SQL Server rowversion?

…衆ロ難τιáo~ 提交于 2020-01-13 11:21:32
问题 I am migrating a SQL Server database schema over to MySQL. Some of the tables on SQL Server have a column of type rowversion. This is an integer value that is set when the row is first inserted and then again each time any column of the row is updated. The number is only ever incremented. We make use of this to check for concurrency problems. So when an insert comes to the server we can check if the incoming value is different to the current stored value. If so, then the row has been updated

Code First - Retrieve and Update Record in a Transaction without Deadlocks

瘦欲@ 提交于 2020-01-05 10:24:41
问题 I have a EF code first context which represents a queue of jobs which a processing application can retrieve and run. These processing applications can be running on different machines but pointing at the same database. The context provides a method that returns a QueueItem if there is any work to do, or null, called CollectQueueItem . To ensure no two applications can pick up the same job, the collection takes place in a transaction with an ISOLATION LEVEL of REPEATABLE READ . This means that

Are nullable foreign keys allowed in Entity Framework 4?

蓝咒 提交于 2020-01-02 03:12:10
问题 I have a problem updating a foreign key in an Entity Framework entity. I am using self tracking entities and have an entity with some relations where the foreign key is also present as a property (one of the new features of EF4). The key (an integer) is marked as Nullable and Concurrency Mode fixed. Specifically I have an Alarm entity with a many to 0..1 relationship to a confirming user. (a user may confirm several alarms, but an alarm can be confirmed by only zero or one users). The entity

How can i force the DbUpdateConcurrencyException to be raised even if i am passing the FormCollection to my Post action method instead of an object

自闭症网瘾萝莉.ら 提交于 2019-12-31 04:30:21
问题 i have the following action method inside my asp.net mvc web application , which will raise a DbUpdateConcurrencyException as intended to handle any concurrent conflicts that might happen:- [HttpPost] public ActionResult Edit(Assessment a) { try { if (ModelState.IsValid) { elearningrepository.UpdateAssessment(a); elearningrepository.Save(); return RedirectToAction("Details", new { id = a.AssessmentID }); } } catch (DbUpdateConcurrencyException ex) { var entry = ex.Entries.Single(); var

Entity Framework formats DateTime SQL parameter without milliseconds for optimistic concurrency

萝らか妹 提交于 2019-12-31 04:16:27
问题 I'm trying to use a DateTime LastModifiedDate column with optimistic concurrency in Entity Framework (will likely upgrade it to DateTime2.) I've set the Concurrency Mode to Fixed. But when I retrieve an entity, change a column and try to save, get a concurrency exception. The stored LastModifiedDate is 2017-01-04 21:16:55.283 but look at the SQL Entity Framework is generating for the update: UPDATE [dbo].[Facilities] SET [Password] = @0 WHERE (([pk_FacilityID] = @1) AND ([LastModifiedDate] =