Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash error when using multi secondary index #5542

Closed
abovemike opened this issue Mar 18, 2016 · 6 comments
Closed

crash error when using multi secondary index #5542

abovemike opened this issue Mar 18, 2016 · 6 comments
Assignees
Milestone

Comments

@abovemike
Copy link

crash log file:

2016-03-18T16:07:31.160038342 53.033688s error: Error in src/rdb_protocol/btree.cc at line 866:
2016-03-18T16:07:31.160057174 53.033707s error: Guarantee failed: [cmp != 0]
2016-03-18T16:07:31.160068783 53.033719s error: Backtrace:
2016-03-18T16:07:31.212232952 53.085885s error: Fri Mar 18 16:07:31 2016\n\n1 [0xa5ce10]: backtrace_t::backtrace_t() at 0xa5ce10 (/usr/bin/rethinkdb)\n2 [0xa5d1a3]: format_backtrace(bool) at 0xa5d1a3 (/usr/bin/rethinkdb)\n3 [0xc9f6b5]: report_fatal_error(char const_, int, char const_, ...) at 0xc9f6b5 (/usr/bin/rethinkdb)\n4 [0x7cb85e]: /usr/bin/rethinkdb() [0x7cb85e] at 0x7cb85e ()\n5 [0x7d9469]: void ql::datumspec_t::visit(std::function<void (ql::datum_range_t const&)>, std::function<void (std::map<ql::datum_t, unsigned long, std::lessql::datum_t, std::allocator<std::pair<ql::datum_t const, unsigned long> > > const&)>) const at 0x7d9469 (/usr/bin/rethinkdb)\n6 [0x7d6364]: rget_cb_t::handle_pair(scoped_key_value_t&&, unsigned long, boost::optionalstd::string const&, concurrent_traversal_fifo_enforcer_signal_t) at 0x7d6364 (/usr/bin/rethinkdb)\n7 [0x9e2161]: concurrent_traversal_adapter_t::handle_pair_coro(scoped_key_value_t_, semaphore_acq_t_, fifo_enforcer_write_token_t, auto_drainer_t::lock_t) at 0x9e2161 (/usr/bin/rethinkdb)\n8 [0x9e1ee4]: callable_action_instance_t<std::Bind<std::Mem_fn<void (concurrent_traversal_adapter_t::)(scoped_key_value_t, semaphore_acq_t*, fifo_enforcer_write_token_t, auto_drainer_t::lock_t)> (concurrent_traversal_adapter_t, scoped_key_value_t, semaphore_acq_t*, fifo_enforcer_write_token_t, auto_drainer_t::lock_t)> >::run_action() at 0x9e1ee4 (/usr/bin/rethinkdb)\n9 [0x9819f8]: coro_t::run() at 0x9819f8 (/usr/bin/rethinkdb)
2016-03-18T16:07:31.212428420 53.086078s error: Exiting.

document example:

{
  "blockhashes": [
    "4391bf05f3843d778bb6f0595eecc4fcc815b03f49a02bee00d96eca0e6f2c7a"
  ],
  "inputTxouts": [
    {
      "addresses": [
        "LfyDt2kSYqQHBVMTfzYuAtWz6zKSxxXqWz"
      ],
      "txid": "376702af471a6695d032663243b091ea67fae06f781bd75a5920a64024042d55",
      "vout": 1
    }
  ],
  "locktime": 0,
  "outputTxouts": [
    {
      "addresses": [
        "LNGL33kL4ojsUW6v9RVoLcVL6HDNxzvJWc"
      ],
      "value": 4.57911
    },
    {
      "addresses": [
        "LfiAPSz377oMhinoHuMWjKAFsLWxJCwhRh"
      ],
      "value": 2.00704038
    }
  ],
  "size": 258,
  "timeEarliest": {
    "$reql_type$": "TIME",
    "epoch_time": 1458293363,
    "timezone": "+00:00"
  },
  "txid": "00907b848d41a638fc96304f85a792f80f24b6834fc8d3a198a59b9e1c7a0197",
  "version": 1
}

secondary index:

r.db('litecoin').table('transaction')
  .indexCreate( "addressCreate",
        function (tx) {
          return tx('outputTxouts').map( function (txout) {
            return txout('addresses').map( function (address) {
              return [ address, tx('timeEarliest') ];
            })
          });
        }, { multi: true }
      )

query that crashes the server:
r.db('litecoin').table('transaction').between( [ r.minval, r.minval ], [ r.maxval, r.maxval ], { index: 'addressCreate', leftBound: 'open' } )

i'm basically tagging each Transaction based on an array of strings (Address) using the multi secondary index, so i can efficiently search for all transactions that are involved with a specific Address. any ideas on what i am doing wrong?

@abovemike
Copy link
Author

nevermind. works after i removed leftBound: 'open' from options

@danielmewes
Copy link
Member

Thanks for the bug report @abovemike.
Re-opening, since it's still a crash and we need to fix it.

@danielmewes danielmewes reopened this Mar 18, 2016
@danielmewes danielmewes added this to the 2.2.6 milestone Mar 18, 2016
@danielmewes
Copy link
Member

@abovemike I looked into this with @mlucy and we believe we understand where the bug came from. Unfortunately the fix will require changes to the on-disk format, and is outside the scope if a bug fix release (2.2.6). Instead we will fix it for RethinkDB 2.3, which isn't that far away either.

We also noticed that your index function probably is one nesting too deep with respect to the output. The outer map should probably be a concatMap. That too should avoid the crash in your particular case.

@danielmewes danielmewes modified the milestones: 2.3, 2.2.6 Mar 18, 2016
@danielmewes danielmewes self-assigned this Mar 18, 2016
danielmewes pushed a commit that referenced this issue Mar 19, 2016
@danielmewes
Copy link
Member

Fix in review 3535

@abovemike
Copy link
Author

wow thanks for the fast response. you are exactly right, i was confused on the secondary index function. for anyone that gets here through search, the proper way would be more like this:

      r.table('transaction').indexCreate( "addressCreate",
        function (tx) {
          return tx('outputTxouts').concatMap( function (txout) {
            return txout('addresses');
          }).map( function (address) {
            return [ address, tx('timeEarliest') ];
          });
        }, { multi: true }

looking forward to 2.3! keep up the great work danielmewes & mlucy

@danielmewes
Copy link
Member

Fixed in next by a57b599. Will ship with RethinkDB 2.3.0

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

No branches or pull requests

2 participants