Index Error with Ruby Client


#1

Have a strange error with the index query - the Ruby code snippet below -

stmt = Statement.new("marketcheck", "listings", ["id", "price", "miles", "scraped_at", "status_date", "is_searchable_is", "seller_name", "source", "group_id", "grouped_at", "zip", "is_grouped", "touch_count", "is_duplicate"])
stmt.filters << Filter.Equal("vin", vin)
rs = aerospike_client.query(stmt)
listings = []
rs.each do |rec|
   puts rec
end
return listings

It returns an error as follows -

Aerospike::Exceptions::Aerospike: Index error
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/query/stream_command.rb:47:in `parse_record_results'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/command/batch_command.rb:51:in `parse_result'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/command/command.rb:454:in `execute'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/client.rb:941:in `execute_command'
from /home/anand/.rvm/gems/ruby-2.1.5/gems/aerospike-1.0.11/lib/aerospike/client.rb:749:in `block (2 levels) in query'

The index was created from the Aerospike Monitoring console -

The same index queries using the Node client works okay. The code that works with the node driver -

app.get('/history/:vin', function (req, res) {
  console.log('History for VIN - ' + req.params.vin);
  var vin = req.params.vin;

  var statement = {};
  var filter = aerospike.filter;
  statement.filters = [filter.equal("vin", vin)]; 
  statement.select = ["id", "price", "miles", "scraped_at", "status_date", "is_searchable", "seller_name", "source", "group_id", "grouped_at", "zip", "is_grouped", "touch_count", "is_duplicate"];
  
  var query = client.query('marketcheck', 'listings', statement);
  
  var stream = query.execute();
  var records = [];

  stream.on('data', function(record){
   records.push(record.bins);
  });
  stream.on('error', function(error) {
   console.log("VIN Stream ERROR - " + vin);
   res.json({'status': 2, 'message': error});
  });
  stream.on('end', function() {
   console.log("VIN Stream end - " + vin + " Total records - " + records.length);
   records.sort(function(a,b){return parseInt(b.status_date) - parseInt(a.status_date)});
   res.json({'status': 1, 'data': records})
  });
});


#2

Hi Anand,

This is strange indeed. The code looks correct and I’m not able to reproduce the issue.

Can you check the server logs to see if there is a warning message from the sindex submodule when you issue the query from the Ruby client? Try grepping for WARN (sindex). That would give us more insight into why the server might be sending a generic index error.

Cheers, Jan


#3

Got it from the logs -

WARNING (sindex): (secondary_index.c::2259) Size of the bin name in bin list of sindex query is out of bounds. Size 15

One of the bins from the list is of length 15. Perhaps the error could be better worded to indicate that its the bin name issue from the client query and not a server side index issue as the “Index Error” probably indicates?

Regards, Anand


#4

Edited one of the bins from bins array in the ruby code above - “is_searchable” to “is_searchable_is” - which is 16 char long and that was causing the error.


#5

Glad you were able to pinpoint the issue after checking the server logs. I agree that the error message returned on the client side is not very helpful. The problem is that the server returns a generic index error. Maybe I’ll just add a message “Check server logs” in this case.


#6

Yeah. That would help - its difficult to guess that “Index Error” could possibly related to bin name length. Thanks for your help.