When deleting entities from index in subject function not $id variable should be used (it is undefined there), but $record->entity_id. Just look into the patch =)

Comments

Georgique’s picture

Version: 7.x-1.0-beta19 » 7.x-1.x-dev
pwolanin’s picture

yes, looks like a correct fix.

nick_vh’s picture

StatusFileSize
new2 KB

I changed the function a little bit more so it becomes more consistent. Would you be so kind to verify? :-)

nick_vh’s picture

Status: Needs review » Needs work
+++ b/apachesolr.index.incundefined
@@ -306,7 +306,7 @@ function _apachesolr_index_process_entity_get_document($entity, $entity_type) {
-  if (function_exists('drupal_get_path_alias')) {
+  if (function_exists('drupal_get_path_alias') && !empty($document->path)) {

Seems like I included a document->path change here. This is needed because not all the documents that are created by contrib modules provide the path in the document.

+++ b/apachesolr.index.incundefined
@@ -374,13 +374,13 @@ function apachesolr_index_get_entities_to_index($env_id, $entity_type, $limit) {
-          ->condition('entity_id', $id)
+          ->condition('entity_type', $record->entity_type)
+          ->condition('entity_id', $record->entity_id)

This is similar to the patch proposed, just a bit more consistent.

nick_vh’s picture

Status: Needs work » Needs review
Georgique’s picture

Status: Needs review » Reviewed & tested by the community

Seems like it works nice.
But there is and there was some strange thing: when I queue content for reindexing, I see 29 items queued. After indexing I see 1 doc pending deletion and 28 in index. It is because my status_callback returns false for 1 document. But is it right that it always queued for indexing and then pengind deletion? And from where it is deleted if it is not in index?

nick_vh’s picture

This could be correct, it copies all items that are published to the queue. Afterwards, bit by bit, it will validate if it can send the item to solr or not. If the status callback says no it will remove this item from the index (if exists) and it won't index the item again.

So, be careful with the re-index all button :-)

Georgique’s picture

Fine, thanks. So now I see that everything works nice and correct. =)

pwolanin’s picture

Status: Reviewed & tested by the community » Needs work

I don't think this is the right approach still.

We have duplicated code and we don't have any robustness in the case the call to delete from the index fails.

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new5.43 KB

marking #1524988: Incorrect side effect in function apachesolr_index_get_entities_to_index() as duplicate, since this patch removes the side effect at least in getting rows to index.

This also adds an attempt at making the removal of an entity from the index more robust. A good test is to shut down solr and then delete or unpublish a node and see if it's eventually removed from the index when you start Solr up again later.

pwolanin’s picture

The path fix should go in a different issue/patch if it's not related.

Status: Needs review » Needs work

The last submitted patch, 1519900-10.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new5.67 KB

Here's a more functional patch (i.e. I actually started testing it).

pwolanin’s picture

Ok, now I'm really confused as to why function apachesolr_get_index_bundles($env_id, $entity_type) depends on the env_id. We are, in general, deleting any excluded bundles from the tracking table, so it won't actually work to track indexing to 2 environemnts at once with different bundles allowed for each. This is a really big problem!

pwolanin’s picture

Priority: Major » Critical
pwolanin’s picture

StatusFileSize
new9.04 KB

I think the correct answer is that we should not be adding/removing rows based on excluded bundles, since we already handle that in the query to get entities to index.

Status: Needs review » Needs work

The last submitted patch, 1519900-16.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new9.8 KB

oops - that left a stray line in apachesolr_index_node_solr_reindex().

This fixes some logic errors in that the delete & reindex didn't rebuild the tracking table consistently with just marking all for reindex.

Georgique’s picture

@pwolanin Should I test it as you wrote in #10?

Georgique’s picture

I shut down Solr (tomcat7), then change one node (it should be removed from index by my status callback), after that start Solr. 1 node is remaining indexing. Pressed "Index" button, and this node moved to "Pending deletions". After 2 minutes it disappeared from search results.

nick_vh’s picture

StatusFileSize
new12.33 KB

Because this removal from the table could mess our indexing process up I rewrote a small part of the batch code :

It now shows the user the following message :

"100 items successfully processed. 98 documents successfully sent to Solr."

Georgique’s picture

>>> It now shows the user the following message :
When and where I can see it?

nick_vh’s picture

Whenever you do the "Index remaining items" and it completes successfully.

Georgique’s picture

But I applied patch and now only see "Apachesolr cron succesfully executed" message.

Georgique’s picture

Ah, I see. I should see it on batch indexing page. But I have too little documents to see it.

nick_vh’s picture

Ah, It's not the cron :-)
In the admin UI there's a button : Index all queued content. This button starts a batch process that shows you that message. There is no bug in the cron process afaik.

Georgique’s picture

Ah, I thought that difference between those two buttons is only in count of indexing documents.
Tried Index all queued, and see "1 item processed successfully.". But this 1 item is deleted and 40 were indexed. Think it is not right to write so.

nick_vh’s picture

Status: Needs review » Fixed

Committed to dev. Couldn't reproduce the error Georgique mentions.

nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Fixed » Patch (to be ported)
nick_vh’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new12.89 KB

Status: Needs review » Needs work

The last submitted patch, 1519900-30.patch, failed testing.

nick_vh’s picture

Status: Needs work » Needs review
StatusFileSize
new13.24 KB
nick_vh’s picture

Status: Needs review » Closed (fixed)

Committed to D6