Skip to content

What should be done about non-atomicity of Table.counter_set() #1549

Closed

Description

@dhermes

See #1541 for discussion.

There is a note from the HappyBase source code

Note that application code should never store a incremented or decremented counter value directly; use the atomic Table.counter_inc and Table.counter_dec methods for that.

and we just went one step further and just made Table.counter_set() a not implemented method (it raises NotImplementedError when called).

Activity

  1. added
    type: questionRequest for information or clarification. Not an issue.
    api: bigtableIssues related to the Bigtable API.
    on Feb 29, 2016
  2. self-assigned this
    on Feb 29, 2016
  3. tseaver commented on Mar 8, 2016

    @tseaver
    Contributor

    Similar to #1524?

  4. dhermes commented on Mar 9, 2016

    @dhermes
    ContributorAuthor

    Nope. This is an issue of a single request not being transactional while that one is the issue of having to send N + 1 requests at once to match an HBase / Thrift feature.

  5. tseaver commented on Jul 1, 2016

    @tseaver
    Contributor

    @dhermes Could we map happybase.table.Table.counter_set onto a CheckAndMutateRow request, where the predicate checked that there was no value alraeady set? We would leave false_mutations empty in that case.

  6. dhermes commented on Jul 2, 2016

    @dhermes
    ContributorAuthor

    We should verify that that would actually be atomic though. I'd guess the "check" and "mutate" don't actually happen atomically (would be a high cost to pay for every CheckAndMutateRow made).

  7. tseaver commented on Jul 19, 2016

    @tseaver
    Contributor

    The docs for the Bigtable data interface say:

    rpc CheckAndMutateRow(CheckAndMutateRowRequest) returns (CheckAndMutateRowResponse)
    
    Mutates a row atomically based on the output of a predicate Reader filter.
    
  8. dhermes commented on Jul 19, 2016

    @dhermes
    ContributorAuthor

    @tseaver It could mean that the set of mutations are either all applied or none, not implying anything about the atomicity of the "check and mutate" as a single operation.

    @mbrukman @tswast can you weigh in?

  9. mbrukman commented on Jul 19, 2016

    @mbrukman
    Contributor

    It's unclear to me how Table.counter_set() would map to a CheckAndMutate—it only accepts a row, column, and value, but not the previous value, so there's nothing to check against, unless I'm missing something. What would we check against as the previous value?

    The use case that it presumably addresses is to enable a user to reset a counter to 0, or initialize the state from some non-zero value if they're migrating data from elsewhere and want to start from a known state, rather than increment their way up to it.

  10. tseaver commented on Jul 19, 2016

    @tseaver
    Contributor

    From #1989 just now: @garye wrote:

    It seems like a CheckAndMutateRow with a pass_all filter (more explicit than leaving it unset) and a single mutation setting the value would do the trick. The check and mutate steps happen in a transaction so the semantics of counter_set should hold.

  11. garye commented on Jul 19, 2016

    @garye
    Contributor

    I took it back over on #1989, see if you think that makes sense.

  12. added a commit that references this issue on Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: bigtableIssues related to the Bigtable API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions