During some custom order import I noticed that ApacheSolr keeps writting delete info for each product in order which makes recent log entry full of such messages.
This is one sample message:

Deleted documents from index with query id:"moqjrr/uc_cart_item/155" OR sm_parent_document_id:"moqjrr/uc_cart_item/155"

So in custom import code I add order in te cart and then I clear cart and save order so products will be saved correctly too. But on each uc_cart_empty() its writing this info message quoted above.

While watchdog delete entry is a new feature that writes delete queries in watchdog, I m interested why Apachesolr is indexing, deleting or working at all with "uc_cart_item".

"uc_cart_item" entity is automagically created when uc_cart_add_item() is used. It is also deleted when uc_cart_empty() is used. But I never told ApacheSolr to have anything with uc_cart_item, I strictly set which content types and how it can work with.

So if this cart entity is created temporary does ApacheSolr automatically index it since there is no such entity on its interface to configure or? Is this a bug, feature? I would really like someone to explain me info message I keep receiveing and what it has to do with ApacheSolr. Naturally, ApacheSolr intervention during import and writing these messages in watchdog consumes some additional small time which, when you re working with huge data, can be priceless.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killes@www.drop.org’s picture

I've noticed this as well. Seems a bit strange.

Nick_vh’s picture

Status: Active » Postponed (maintainer needs more info)

And are you using some ubercart solr module? Apache Solr should only index node entities so if ubercart creates fake node entities on the fly, that seems like a very fatal thing for apachesolr and not something we can easily fix. I'd love some instructions on how to reproduce. Until that time I'm going to postpone it.

In any case, thanks for your contribution. It's very much appreciated and I hope you continue to contribute to our issue queue. We can use all the help we can get.

milovan’s picture

Hey Nick_vh, thanks for response.
Here is how you can reproduce it quickly:
login for example as customer on your site where you have Ubercart and Apachesolr. You should have Product content type, minimum one product for purchase and that's about it.

Steps to reproduce:

  1. Now as customer add product to your cart.
  2. As admin, watch your watchdog; it should not have anything special to show in this moment.
  3. As customer, go to your cart and click "Remove" button for product you added in step 1.
  4. As admin refresh watchdog and you will see entry quoted in initial post (pasting again as reminder)

Watchdog entry on minimal Drupal instance with Apachesolr and Ubercart:

Deleted documents from index with query id:"dx21rt/uc_cart_item/1" OR sm_parent_document_id:"dx21rt/uc_cart_item/1"

Every time product gets eliminated from cart, apachesolr reacts. I installed on this minimal test instance only following Apachesolr modules:

  • Apache Solr Access
  • Apache Solr framework
  • Apache Solr search
  • Search core module

As for the Ubercart, also minimal Ubercart setup. So, nothing extraordinary or custom.
Let me know if you need any more help, feedback, or any kind of testing.
Thanks again!

milovan’s picture

Status: Postponed (maintainer needs more info) » Active

Nick_vh, do you need any more information to reproduce? Did you manage to reproduce?

deja711’s picture

I have the same issue. Any progress?

torgosPizza’s picture

Title: uc_cart deleted documents from index » Entity delete implementation does not all respect 'indexable' property
Version: 7.x-1.3 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
1.03 KB

I am able to reproduce this with Commerce and Apachesolr.

The issue is that only the hook_entity_update() implementation respects whether a entity bundle/type is indexable. So for any other modules that implement hook_entity_delete() (and call other modules' implementations) the function apachesolr_entity_delete() gets called regardless if an entity type has been indexed or not.

In our case this lead to tons of queries to the Solr server as our site attempted to delete commerce_line_item and other entities that were never indexed (or indexable) in the first place.

Attached is a patch that adds if (apachesolr_entity_should_index($entity, $entity_type)) to this method which solves the problem for me.

Status: Needs review » Needs work

The last submitted patch, 6: 2033453-apachesolr-entity_delete-check.patch, failed testing.

torgosPizza’s picture

Title: Entity delete implementation does not all respect 'indexable' property » hook_entity_delete implementation does not respect 'indexable' property
torgosPizza’s picture

Status: Needs work » Needs review

Those failures don't have anything to do with the hook_entity_delete implementation.

Setting to needs review again.

torgosPizza’s picture

Patch has passed testbot. Anyone still suffering this issue, please give the patch a try. Hopefully @Nick_vh will consider committing it, as for sites like ours who maintain lots of entity bundles (and in Commerce, line_item entities are deleted many times during order/cart refreshes) it will help achieve some performance gains.