Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
Created March 19, 2014 18:24
Show Gist options
  • Save dallasmarlow/9648034 to your computer and use it in GitHub Desktop.
Save dallasmarlow/9648034 to your computer and use it in GitHub Desktop.
# invalid re-assignment strategy as the table's `AUTO_INCREMENT` isn't updated which will cause new inserts to fail
def invalidate_block id
[
'set autocommit = 0',
'lock tables blacklist write',
'update blacklist set valid = 0, invalidated_at = now(), id = ((select max(blacklist.id)) + 1) where id =' + id.to_s,
'commit',
'unlock tables',
'set autocommit = 1',
].each do |statement|
db.run statement
end
rescue Exception => message
log.error ['unable to invalidate block with id: ' + id.to_s, message].join("\n")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment