Skip to content

[MODEL] Wrong retrieval of records corresponding to indexed documents when querying multiple models. #369

@miguelff

Description

@miguelff

This has been shown in a production deployment of elasticsearch-model v0.17.0

In this commit some refactorings where made to the adapter for multiple records.

One of the refactorings was a reduction of the cyclomatic complexity (and renaming of __type_records):

changes

This change drove to the following

  • A user searches across several models. Along the search execution the code reaches the point above.
  • A certain klass (say for instance an ActiveRecord model) wont' match any of the cases on the case/when statement, entering in the default clause.
  • Then (line 60 on the right side) find will be invoked over klass which is an ActiveRecord, but unluckily ActiveRecord will respond to the message.
  • Due to eventual consistency, some of the records returned by ES, are no longer present in the DB.
  • So in this case, klass.find(ids) will raise an exception as no all the ids where found in the DB. 💥

I'm preparing a fix for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions