Skip to content

Remove (?:in|de)crement!? - #17073

Closed
tamird wants to merge 1 commit into
rails:masterfrom
square:remove-incrementers
Closed

tamird wants to merge 1 commit into
rails:masterfrom
square:remove-incrementers

Conversation

@tamird

@tamird tamird commented Sep 26, 2014

Copy link
Copy Markdown
Contributor

These methods are useless sugar and are quite dangerous. They implement
last-write-wins while having names that suggest atomicity and safety.

The AR convention seems to prefer that UPDATE queries be made via
class methods - these methods are already available in CounterCache.

Reintroducing these methods is a tricky proposition, because doing it
right means adding a read immediately after the update to update the
in-memory value; this requires a transaction and some state tracking to
ensure that other dirty attributes are not discarded.

This might be appropriate for 5.0.

cc @bogdan

These methods are useless sugar and are quite dangerous. They implement
last-write-wins while having names that suggest atomicity and safety.

The AR convention seems to prefer that `UPDATE` queries be made via
class methods - these methods are already available in `CounterCache`.

Reintroducing these methods is a tricky proposition, because doing it
right means adding a read immediately after the update to update the
in-memory value; this requires a transaction and some state tracking to
ensure that other dirty attributes are not discarded.
@seuros

seuros commented Sep 26, 2014

Copy link
Copy Markdown
Member

👍

@jeremy

jeremy commented Sep 27, 2014

Copy link
Copy Markdown
Member

Yeah, handing out this API without a disclaimer or guidance is asking for incorrect usage and app data inconsistency. To use this as-is, you need to take an exclusive lock on the row when it's read.

Removing the API won't remove apps' need for it. Better for apps to rely on something we can improve (and document) rather than independently building N buggy implementations with the same issue.

@jeremy jeremy closed this Sep 27, 2014
@tamird
tamird deleted the remove-incrementers branch April 17, 2015 03:38
@rafaelfranca rafaelfranca modified the milestones: 5.0.0 [temp], 5.0.0 Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants