This use of activerecord seems not thread-safe