Answer the question
In order to leave comments, you need to log in
How to resolve data conflict when multiple users edit data at the same time?
Hello, fellow bearded programmers. I am writing here for myself one project, and now a certain architectural problem has arisen, the solution of which I have not yet found. I do not deny, maybe I searched badly and stupidly, but as it is, it is.
I will describe the essence: there is a certain server and a certain number of clients. The client can accept the data from the server, possibly edit it and send it back. The server can take data from the internal storage (DB) and send this data to clients (perhaps many of them are the same, sharing is present), then receive this data and write it to the database. Well, standard architecture in general. And everything is fine until > 2 clients try to send the same data changed.
Example: there is a cell in the database on the server with the string "Hello, Habr!". Two clients are connected and take away this line from the server. The first client changes the string to "Hello, Habrahabr!", the second to "Hello, Habr and Geektimes!", after which they both send them to the server, where these strings are stored in a conditional temporary table. How can the server figure out what to put in the main cell in the database?
In this case, the information should not be lost. You can, of course, notify the user about the version conflict and leave the difficult choice to him, but then fewer windows and annoying warnings = better.
What ideas does anyone have? I will be grateful.
PS Server - C# under .NET 4.5, then there will be C++11. The client is C# under .NET 4.5 and Java.
PSS Perhaps a solution to a similar problem in Git or MS Word will do? Any information on how it's done?
Answer the question
In order to leave comments, you need to log in
In a request to the service, send data in the format
{
"text" : "то что редактируете",
"text_update" : "на что редактируете"
}
There are optimistic and pessimistic locks.
Database Locking: What it is, Why it Matters and W...
A beginner's guide to database locking and the los...
Formulate an algorithm by which the server must decide what to write, implement PROFIT. Only you will not be able to formulate, so this is not a task for the server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question