B
B
beduin012021-01-09 12:46:06
Dart
beduin01, 2021-01-09 12:46:06

Why does an error occur when a method is called frequently?

foo() async {
  await db.KVToTableInsert(tableToInsert, jsonMap);
  }


Inside `KVToTableInsert` a set of SQL Insert statements is generated.
I pull the foo method in the microservice in this way:
app.post('/foo', (req, res) async {
    dbEnums insertResult = await matchQuery.foo("tablename", req.body);


I have a feeling that when many requests come in at the same time, KVToTableInsert, without having time to process one, starts processing another request and this leads to errors. because I get errors that it is trying to insert the result into a table from another query (KVToTableInsert stores the table name in itself).

Question. Am I right. How to fix. And how to organize such code correctly.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question