assignMentor (line 114 in app/models/section.rb) does not take into account race conditions. It is possible that two thread simultaneously pass check on line 115 but then both get assigned to the section via lines 118-121. Big issue in all of this: I don't know how to lock an object in ruby on rails when that object is created via the database. Perhaps we can lock the db row for that section via http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html.
assignMentor (line 114 in app/models/section.rb) does not take into account race conditions. It is possible that two thread simultaneously pass check on line 115 but then both get assigned to the section via lines 118-121. Big issue in all of this: I don't know how to lock an object in ruby on rails when that object is created via the database. Perhaps we can lock the db row for that section via http://api.rubyonrails.org/classes/ActiveRecord/Locking/Pessimistic.html.