K
K
KirSupi2021-09-07 11:23:00
MySQL
KirSupi, 2021-09-07 11:23:00

What are multi-user databases or how to work with MySQL correctly?

Conventionally, there are two complex PHP scripts
. One fine day, they both started up and started loading data into one table in MySQL, as a result, one of them crashed, said "the database is already busy" and went to sleep
. Actually, what should I do to prevent this from happening? Are there any databases in which such problems do not arise or are there any solutions when working with MySQL?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman MySQL, 2021-09-07
Tag

"DB already busy"

a muscle does not have such an error, let's be more specific

I
index0h, 2021-09-07
@index0h

Question from the series: "I pressed something and everything is gone, what should I do?". Without inspecting these complex scripts, you will not succeed.
If I understand correctly, you have a problem with concurrent access to the same data.
In principle, there are at least 2 relatively simple solutions:
1. Control through locks. Roughly speaking, the 1st script, before starting work with record N, "blocks it" by writing this identifier to memcached / redis / or via GET_LOCK, if it succeeded, it continues execution, if it didn't work, it tries to block, or it is taken for the next record.
2. The solution is more specific, less reliable, but faster. Explicitly indicate for the first script: you work only with paired records, and for the second - with non-paired ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question