Reputation: 96927
A lot of websites run scheduled tasks at various "time distances", which bring new content, or updates content in the database. How is the database avoiding concurrency problems?
In a normal desktop app, if you have data accessed by multiple threads, they need to synchronize somehow.
Normally, a website continues to be operational at all times, and after a scheduled job finishes, you will see new content appearing, or old content being updated.
I don't even know what to search for in google :) so I can read more about this topic.
Upvotes: 0
Views: 117
Reputation: 12449
Modern DBMS have the concept of transactions. The DBMS makes sure all changes inside a transaction happen at once, and that each transaction from all users are processed one at a time. The DBMS knows what version of the data each transaction started with, and can usually sort things out.
While this prevents records with a mishmash of data, it is still possible for the data to no longer make sense when multiple people change related data. That's why large systems often have some kind of entity-level locking in the application, so if you have a customer database only one person can gain access to the data for that one customer for the purposes of changing it. That level of protection can't be done in the database, as intimate knowledge of the entity relationships and workflow of the application are required to prevent it.
Upvotes: 1