そのため、AWS Aurora DB を 1 分間に約 1500 ~ 2000 回読み書きする laravel 5 php アプリがあります。単純な選択を行ってから、列の値を更新しています。
ただし、値を時々更新しようとすると、いくつかのエラーが発生します。(500 分の 1 はエラーになります)
[2015-11-13 09:15:00] live.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function update() on null
これが私たちのコードです
// Get the first free token sorted by the biggest ID to the smallest.
$token = TokenModel::where('expire_at', '>', Carbon::now())
->where('status', 'Free')
->orderBy('id', 'DESC')
->lockForUpdate()
->first();
// Update the status of the token.
$token->update(['status' => 'Used']);
削除/追加を試みlockForUpdate()
ましたが、問題は解決しません。
誰もこの問題に遭遇したことがありますか?
アップデート:
$token = null;
while ($token == null) {
// Get the first free token sorted by the biggest ID to the smallest.
$token = TokenModel::where('expire_at', '>', Carbon::now())
->where('status', 'Free')
->orderBy('id', 'DESC')
->lockForUpdate()
->first();
}