一个诡异的 Model::save 方法不存在的问题
前提是这样的,队列的某个consumer中的关于一个模型的save,有时候提是方法不存在
伪代码如下:
function handle()
{
$id = $this->id;
$model = Model::query()->find($id);
if (!$model) throw new Exception('not found');
Queue::push(new OtherJob($model->serial_id));
$model['attr_1'] = 'processed';
try {
$model->save();
} catch (Throwable $e) {
$this->log(vsprintf("save_fail message:[%s], serialize:[%s], type:[%s]", [
$e->getMessage(),
serialize($order),
gettype($order),
]), 'error');
}
}
偶发性的能看到日志里有如下内容:
save_fail message:[Call to a member function save() on array], o:[a
{s
”last_queue_at”;O
”Illuminate\Support\Carbon”
{s
”date”;s
”2020-04-08 16:12:58.738117”;s
”timezone_type”;i:3;s
”timezone”;s
”PRC”;}}], type:[array]
但是看数据库中的attr_1确实也变成了processed
有碰到过类似问题的吗?
推荐文章: