C
C
Crash2018-04-13 17:12:39
MySQL
Crash, 2018-04-13 17:12:39

The subtleties of the MySQL database when writing and reading data from the same table at the same time?

There is a table in the MySQL database with constantly updated and read data.
Those. one script once a minute (by cron) updates the data in it (they are obtained by parsing with the API)
Another script, from a third-party resource (not ours), requests this data every 15 seconds by calling the appropriate controller action.
So what happens when they collide? Those. one script writes to the database, and the other reads from it at the same time. The second will not receive any data at all, or will it only receive the data that was before the update by the first script?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2018-04-13
@Bandicoot

Not enough data. Different storage engines will behave differently. For transactional storage, the transaction isolation level and how transactional processing is implemented in both applications will matter.
innodb, read commited, writer's transactional work: the reader will see the version of the data as if the writer hadn't done anything yet.
innodb, read commited, non-transactional work of the writer/autocommit - the reader will see some intermediate result, something is updated, something else is not.
myisam - wait for the write request to complete (interfering request only! The next write request will wait for the read request to complete), read the current state

K
Konstantin Malyarov, 2018-04-13
@Konstantin18ko

In my opinion, there is such a thing as a queue . I can be wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question