Update Record Permissions

When I use the api
https://developer.kintone.io/hc/en-us/articles/115005364008

Sometimes I see an error below:
message: " Failed to save the changes because the database could not be locked. Please wait a while and try again."

Error code is 520.

Sometimes It works properly

Any ideas for this problem?

Hello Tom

I assume the error is occurring probably because of the following (but not limited):

When a record is updating, as mutual exclusion, a selected part of the record database will temporarily be in lock status.
If the same part of the database that is in a lock status needs to be updated, the subsequent process will be in a wait status.

Then, if the first process is taking too much time and the subsequent process that is in a wait status passes the timeout value, the error that you mentioned occurs.

The cause explained in the above is just one possibility, but the error is mostly due to too much process at the same time.

I hope this answers your question.