Skip to content

Instantly share code, notes, and snippets.

  • Save normann/1151006 to your computer and use it in GitHub Desktop.
Save normann/1151006 to your computer and use it in GitHub Desktop.
From 9f3608aaa59627cfb9c7590343b35a147f8de38c Mon Sep 17 00:00:00 2001
From: Normann Lou <normannlou@gmail.com>
Date: Wed, 17 Aug 2011 18:28:04 +1200
Subject: [PATCH] BUGFIX: (ZD#6623) SearchBackgroundUpdateQueue broken in two
ways: 1. $dirty array should be populated no matter
$indexinstance->variantStateExcluded($state) is true or
false. 2. when the process is broken for long time, the
queued records are too much and every set of updating get
very large hence suffering from a maximal allowed memory.
---
solr/code/search/SearchBackgroundUpdateQueue.php | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/solr/code/search/SearchBackgroundUpdateQueue.php b/solr/code/search/SearchBackgroundUpdateQueue.php
index 2463f19..8f4f455 100644
--- a/solr/code/search/SearchBackgroundUpdateQueue.php
+++ b/solr/code/search/SearchBackgroundUpdateQueue.php
@@ -147,7 +147,7 @@ class SearchBackgroundUpdateQueue_Consume extends BuildTask {
$base = $set['base'];
$statekey = $set['statekey'];
$state = $set['state'];
- $ids = $set['ids'];
+ $ids = array_slice($set['ids'], 0, 500, true);
SearchVariant::activate_state($state);
@@ -155,15 +155,18 @@ class SearchBackgroundUpdateQueue_Consume extends BuildTask {
if ($objs) foreach ($objs as $obj) {
foreach ($ids[$obj->ID] as $index) {
$indexinstance = $indexes[$index];
- if (!$indexinstance->variantStateExcluded($state)) { $indexinstance->add($obj); $dirty[$index][] = $obj->ID; }
+ $dirty[$index][] = $obj->ID;
+ if (!$indexinstance->variantStateExcluded($state)) { $indexinstance->add($obj); }
}
unset($ids[$obj->ID]);
+ $obj->destroy();
}
foreach ($ids as $id => $fromindexes) {
foreach ($fromindexes as $index) {
$indexinstance = $indexes[$index];
- if (!$indexinstance->variantStateExcluded($state)) { $indexes[$index]->delete($base, $id, $state); $dirty[$index][] = $id; }
+ $dirty[$index][] = $id;
+ if (!$indexinstance->variantStateExcluded($state)) { $indexes[$index]->delete($base, $id, $state);}
}
}
--
1.7.5.4+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment