Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database is not responding until all requests are submitted successfully: MySQL

I am using Laravel 5.3 for Web API and below is my JQuery Ajax request which saves records concurrently. Below is the code..

for (i = 0; i < 100; i++) {
    var 
     data={'Role' : "Role"+i},
     request = $.ajax({
        url:                'http://localhost:1234/Practise/public/api/SaveRoleApi',
        type:               "POST",
        data:               JSON.stringify(data),
        contentType:        "application/json; charset=utf-8",
        async:  true,
        success: function(d){ console.log(d); }
     });
}

I am using for loop to save 100 records. Please check there is async: true,. Reason I said it is saving records concurrently because the requests are being submitted randomly although I confirmed that all requests are being submitted successfully.

My Question is: I can't submit select statement select * from tblrole until all the above ajax requests are submitted.

Problem is: Database is not responding until all requests has been submitted.

What should I do to retrieve records during the Post request(s) submission is in progress?

Below are my Phpmyadmin details.

enter image description here

like image 426
Pankaj Avatar asked Oct 28 '25 11:10

Pankaj


1 Answers

Smells like you have autocommit=0 and never issued a COMMIT. Please show us the connect code, plus some of the SQL statements. I assume it is in SaveRoleApi.

Smells like "table locking", which you get from MyISAM. If your tables are that, change to InnoDB.

like image 193
Rick James Avatar answered Oct 30 '25 02:10

Rick James