I find the easiest way to make thread safe changes is to an ActiveRecord object is to use .with_lock
Your code might look like...
def change_occupied_spaces!(by:)
retries ||= 0
self.with_lock do
reload
new_value = occupied_spaces + by
if new_value < 0