Skip to content

Simone's Insert Bug #1155

Closed
Closed

Description

@mlucy

Simone gets the following error when inserting the data in ~mlucy/real_bugs/insert:

{"unchanged"=>0, "skipped"=>0, "replaced"=>0, "inserted"=>228, "first_error"=>"Primary key `id` cannot be changed ..

Activity

  1. ghost assigned on Jul 10, 2013
  2. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    The current state of this is that I'm having trouble reproducing.

  3. coffeemug commented on Jul 10, 2013

    @coffeemug
    Contributor

    Do you want to pair-reproduce this?

  4. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    So, Simone gave me a dump, and when I import that dump and insert it the same way he did, I don't get the same error. I had to translate the dump from a SQL dump, though, so it's possible I messed something up during that step.

    I trespassed further on Simone's generosity and asked whether he'd be able to provide a standalone script that reproduces the problem for him, since it might be something subtle. If he's willing to do that, and I still can't reproduce it, pair-programming the problem or just handing it off to a fresh set of eyes might be a good idea.

  5. coffeemug commented on Jul 10, 2013

    @coffeemug
    Contributor

    Would he be able to provide a tar.gz of a rethinkdb_data directory? That might help (sorry for butting in)

  6. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    I was under the impression from the google group that the bug occured while inserting into an empty table, so getting the rethinkdb_data might not be too helpful.

    My other though was that it might be the CentOS build.

  7. mlucy commented on Jul 10, 2013

    @mlucy
    MemberAuthor

    @simo2409 -- just to check, does the bug occur when you're inserting into an empty table in a fresh RethinkDB instance? If not, would you be willing to provide us with your rethinkdb_data directory?

  8. simo2409 commented on Jul 10, 2013

    @simo2409

    Yes, I have 1 db (not "test", I created a new one) with 1 table, on each try I did:
    1 - delete old table (so the db was empty)
    2 - create a new table
    3 - try to insert documents -> got error

  9. simo2409 commented on Jul 10, 2013

    @simo2409

    If it can be useful I can try to remove RethinkDB (from CentOS build), compile it from sources and re-try to insert

  10. simo2409 commented on Jul 10, 2013

    @simo2409

    In the while I re-wrote the import script (to be a normal ruby script and not a rake task so Michael can try to reproduce the problem) and I sent it to Michael (sorry but I can't put it here for privacy (data is dummy but the db structure is real)

  11. simo2409 commented on Jul 10, 2013

    @simo2409

    Good news (more or less), I compiled RethinkDB 1.7.1 from sources and insert works without any problem, so I believe it's a problem with the CentOS build

  12. simo2409 commented on Jul 11, 2013

    @simo2409

    I was wrong sorry, I did another try and the problem still persists (even on self-compiled RethinkDB) but I think to understood the problem.

    I try to repeat everything to make it clear:

    1 - I installed RethinkDB from CentOS build and I started 2 instances => Error
    2 - I compiled RethinkDB from sources and I started 1 instance => Works
    3 - Still using RethinkDB from sources, I started 2 instances => Error

    So this makes me think that the problem appears only when there are 2 instances connected.
    2 instances are connected but 1 is completely un-used (db has only 1 shard in total and there is no replication setup)

  13. simo2409 commented on Jul 11, 2013

    @simo2409

    Last test, I re-installed RethinkDB from CentOS build, running only 1 instance => Works

    So it seems to be a problem when there are 2 instances running on the same box

  14. mlucy commented on Jul 11, 2013

    @mlucy
    MemberAuthor

    Ah! I'll try with 2 instances, thanks @simo2409 .

  15. coffeemug commented on Jul 11, 2013

    @coffeemug
    Contributor

    @simo2409 I wanted to chime in and thank you for your patience in isolating this bug. It helps improve the product immensely. If you'd be kind enough to fill out http://rethinkdb.com/community/cla/, we'll send you a little something for it!

  16. mlucy commented on Jul 11, 2013

    @mlucy
    MemberAuthor

    So, here's an update:

    • @simo2409 sent me a script that reliably reproduces the bug for him when run against two release CentOS servers from a client running on Ruby 1.9 on OS X.
    • I am unable to reproduce the bug when running against two release Ubuntu servers from a client running Ruby 1.9 on OS X.

    The next logical step is to test against a CentOS build.

    @AtnNn or @neumino -- do you happen to have a CentOS build of 1.7 / a CentOS VM lying around?

  17. AtnNn commented on Jul 11, 2013

    @AtnNn
    Member

    @mlucy you can extract the binary from the rpm by doing alien --to-tgz and then tar xf. You should be able to run the binary it on newton.

  18. Tryneus commented on Jul 11, 2013

    @Tryneus
    Member

    @mlucy, I have a CentOS virtualbox VM running on my workstation if you want to grab it. It has rethinkdb next building, so it should be pretty easy to build/run whatever. Feel free to save state and copy it wherever.

  19. mlucy commented on Jul 11, 2013

    @mlucy
    MemberAuthor

    @AtnNn -- where's the RPM?

  20. mlucy commented on Jul 11, 2013

    @mlucy
    MemberAuthor

    Good news -- this reproduces with the CentOS binary!

  21. mlucy commented on Jul 11, 2013

    @mlucy
    MemberAuthor

    Alright, I think I've tracked this down. (I'll grab Etienne tomorrow and test my theory.)

    The bug occurs when a query is handled on a different server than the one storing the data. We turn the insert into a batched_replaces_t and serialize it over the network. The batched_replaces_t contains an std::vector<std::pair<int64_t, point_replace_t> >. The point_replace_t contains a wire_func_t nested deep inside it.

    The problem comes from the interaction of the deserialization functions for std::vector and wire_func_t. The deserialization function for std::vector calls resize to size the vector appropriately. As far as I can tell (and this seems wacky to me), when you resize a vector to a larger size, the CentOS build invokes the default constructor to build a reference object, then uses the copy constructor to move copies of it into all the new positions. Cursory googling (http://stackoverflow.com/questions/7413876/does-the-vector-resize-method-calls-the-default-elements-contructors-when-resi) seems to suggest that this is legal.

    The deserialization function for wire_datum_t assumed that each wire_datum_t would be default-constructed before rdb_serialize was called on it. (Copying it is legal, but only after it's been initialized.) If this isn't the case, we end up with two separate wire_func_t objects that share pointers to the same Term in source before either one has been deserialized. Shenanigans ensue.

    This is easy(ish) to fix. I'll do it tomorrow once I get a working CentOS build environment to test whether it fixes the problem.

  22. mlucy commented on Jul 13, 2013

    @mlucy
    MemberAuthor

    So, I'm currently blocked on the extremely embarrassing problem of not being able to compile RethinkDB on CentOS. I plan to grab Etienne on Monday and study at the feet of the devops master.

  23. neumino commented on Jul 13, 2013

    @neumino
    Member

    @mlucy instructions are here:
    #938 (comment)
    You don't have to install the npm dependencies though.

    (or in the branch michel_update_all of the website)

  24. mlucy commented on Jul 13, 2013

    @mlucy
    MemberAuthor

    Go this building -- thanks @neumino .

  25. mlucy commented on Jul 13, 2013

    @mlucy
    MemberAuthor

    This is in review 736 by @jdoliner . (I tested it with a CentOS build, and it seems to make the problem go away.)

  26. mlucy commented on Jul 13, 2013

    @mlucy
    MemberAuthor

    @simo2409 -- thanks again for reporting this, and being so patient while we tracked it down! We should hopefully have this fix out in a point release next week.

  27. simo2409 commented on Jul 13, 2013

    @simo2409

    Great to hear it! Thank you!

  28. mlucy commented on Jul 16, 2013

    @mlucy
    MemberAuthor

    This is in next and v1.7.x.

    @AtnNn -- could we do a point release this week?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions