Skip to content

Cursor Stability, Internal Snapshots, MVCC #3464

Open

Description

@nviennot

What's RethinkDB model for index stability in this case:

  • Assume a regular index field on a table.
  • Create a 1000 document {:field => i} where i is the document index from 1 to 1000 (they are all distinct).
  • Start a between(0, nil, :index => :field).update(...) query.
  • While the index query has not completed yet, the first document gets updated and its field attribute gets changed to 10000
  • The previous update query finishes. Can it update the first document twice? because it reappeared at the end of the index?

Activity

  1. danielmewes commented on Dec 19, 2014

    @danielmewes
    Member

    Can it update the first document twice? because it reappeared at the end of the index?

    Yes. If you change the field that you are selecting by this can definitely happen.

  2. danielmewes commented on Dec 19, 2014

    @danielmewes
    Member

    I suppose that's an argument in favor of always using distinct semantics (#3462) whenever a query updates on a secondary-index based selection...

  3. nviennot commented on Dec 19, 2014

    @nviennot
    ContributorAuthor

    I'd rather have the DB to provide decent isolation properties, which shouldn't be hard to provide given the MVCC underlying engine.

  4. danielmewes commented on Dec 19, 2014

    @danielmewes
    Member

    @nviennot It's feasible for read queries, but a lot more difficult for writes.

  5. danielmewes commented on Dec 19, 2014

    @danielmewes
    Member

    Actually ignore that. I think it could work technically with a bit of a redesign (that is some significant redesign of how we do range reads and writes on the cluster level).

  6. nviennot commented on Dec 19, 2014

    @nviennot
    ContributorAuthor

    It would be great that any cursor actually reads from a snapshot of the DB, otherwise subtle bugs can arise.

  7. nviennot commented on Dec 20, 2014

    @nviennot
    ContributorAuthor

    Try this:

    • Create 300,000 documents on a table. Each of them has an attribute {:field => i} where i goes from 1 to 300,000.
    • Create an index on field
    • Run this: r.table("test").between(0, nil, "index" => :field).update { |doc| { :field => doc[:field] + 300000 } } }
    • The query never ends and documents keeps getting updated over and over. The only way out of this is to kill the server.
  8. changed the title [-]Consistency Question[/-] [+]Cursor Stability, Internal Snapshots, MVCC[/+] on Dec 20, 2014
  9. mlucy commented on Dec 20, 2014

    @mlucy
    Member

    That last bit is definitely a bug; closing the connection should abort the query.

  10. nviennot commented on Dec 20, 2014

    @nviennot
    ContributorAuthor

    I was wrong abut the last bit, I ctrl+c in the console, which interrupted the query, but the connection was left open. Still, it's funky behavior.

  11. added this to the backlog milestone on Dec 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions