Skip to content

Commit 5944c89

Browse files
committed
Try to fix judge result data race
1 parent 8ac7387 commit 5944c89

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/channels/fetch_channel.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def submission_result(data)
3434
update_hash[:total_time] = tasks.map{|i| i.time}.sum.round(0)
3535
update_hash[:total_memory] = tasks.map{|i| i.rss}.max || 0
3636
end
37-
submission.update(**update_hash)
37+
submission.with_lock do
38+
submission.update(**update_hash)
39+
end
3840
ActionCable.server.broadcast("submission_#{submission.id}_overall", update_hash.merge({id: submission.id}))
3941
end
4042

0 commit comments

Comments
 (0)