Ensures luceneIndexer.WaitForIndexQueueOnShutdown is called even when not in MainDom
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Umbraco.Examine
|
||||
/// <remarks>
|
||||
/// This is not thread safe, use with care
|
||||
/// </remarks>
|
||||
internal static void UnlockLuceneIndexes(this IExamineManager examineManager, ILogger logger)
|
||||
internal static void ConfigureLuceneIndexes(this IExamineManager examineManager, ILogger logger, bool disableExamineIndexing)
|
||||
{
|
||||
foreach (var luceneIndexer in examineManager.Indexes.OfType<LuceneIndex>())
|
||||
{
|
||||
@@ -86,6 +86,8 @@ namespace Umbraco.Examine
|
||||
//that could end up halting shutdown for a very long time causing overlapping appdomains and many other problems.
|
||||
luceneIndexer.WaitForIndexQueueOnShutdown = false;
|
||||
|
||||
if (disableExamineIndexing) continue; //exit if not enabled, we don't need to unlock them if we're not maindom
|
||||
|
||||
//we should check if the index is locked ... it shouldn't be! We are using simple fs lock now and we are also ensuring that
|
||||
//the indexes are not operational unless MainDom is true
|
||||
var dir = luceneIndexer.GetLuceneDirectory();
|
||||
|
||||
@@ -30,8 +30,9 @@ namespace Umbraco.Web.Search
|
||||
private readonly IValueSetBuilder<IMedia> _mediaValueSetBuilder;
|
||||
private readonly IValueSetBuilder<IMember> _memberValueSetBuilder;
|
||||
private static bool _disableExamineIndexing = false;
|
||||
private static volatile bool _isConfigured = false;
|
||||
private static readonly object IsConfiguredLocker = new object();
|
||||
private static bool _isConfigured = false;
|
||||
private static object _configuredInit = null;
|
||||
private static object _isConfiguredLocker = new object();
|
||||
private readonly IScopeProvider _scopeProvider;
|
||||
private readonly ServiceContext _services;
|
||||
private static BackgroundTaskRunner<IBackgroundTask> _rebuildOnStartupRunner;
|
||||
@@ -91,7 +92,7 @@ namespace Umbraco.Web.Search
|
||||
|
||||
if (!examineShutdownRegistered)
|
||||
{
|
||||
_logger.Debug<ExamineComponent>("Examine shutdown not registered, this AppDomain is not the MainDom, Examine will be disabled");
|
||||
_logger.Info<ExamineComponent>("Examine shutdown not registered, this AppDomain is not the MainDom, Examine will be disabled");
|
||||
|
||||
//if we could not register the shutdown examine ourselves, it means we are not maindom! in this case all of examine should be disabled!
|
||||
Suspendable.ExamineEvents.SuspendIndexers(_logger);
|
||||
@@ -120,7 +121,7 @@ namespace Umbraco.Web.Search
|
||||
MediaCacheRefresher.CacheUpdated += MediaCacheRefresherUpdated;
|
||||
MemberCacheRefresher.CacheUpdated += MemberCacheRefresherUpdated;
|
||||
|
||||
EnsureUnlocked(_logger, _examineManager);
|
||||
ConfigureIndexes(_logger, _examineManager);
|
||||
|
||||
// TODO: Instead of waiting 5000 ms, we could add an event handler on to fulfilling the first request, then start?
|
||||
RebuildIndexes(_indexRebuilder, _logger, true, 5000);
|
||||
@@ -161,25 +162,24 @@ namespace Umbraco.Web.Search
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Must be called to each index is unlocked before any indexing occurs
|
||||
/// Called on startup to configure each index.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Indexing rebuilding can occur on a normal boot if the indexes are empty or on a cold boot by the database server messenger. Before
|
||||
/// either of these happens, we need to configure the indexes.
|
||||
/// Configuring also ensure the indexes are not locked.
|
||||
/// </remarks>
|
||||
private static void EnsureUnlocked(ILogger logger, IExamineManager examineManager)
|
||||
private static void ConfigureIndexes(ILogger logger, IExamineManager examineManager)
|
||||
{
|
||||
if (_disableExamineIndexing) return;
|
||||
if (_isConfigured) return;
|
||||
|
||||
lock (IsConfiguredLocker)
|
||||
{
|
||||
//double check
|
||||
if (_isConfigured) return;
|
||||
|
||||
_isConfigured = true;
|
||||
examineManager.UnlockLuceneIndexes(logger);
|
||||
}
|
||||
LazyInitializer.EnsureInitialized(
|
||||
ref _configuredInit,
|
||||
ref _isConfigured,
|
||||
ref _isConfiguredLocker,
|
||||
() =>
|
||||
{
|
||||
examineManager.ConfigureLuceneIndexes(logger, _disableExamineIndexing);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
#region Cache refresher updated event handlers
|
||||
@@ -800,7 +800,7 @@ namespace Umbraco.Web.Search
|
||||
if (_waitMilliseconds > 0)
|
||||
Thread.Sleep(_waitMilliseconds);
|
||||
|
||||
EnsureUnlocked(_logger, _indexRebuilder.ExamineManager);
|
||||
ConfigureIndexes(_logger, _indexRebuilder.ExamineManager);
|
||||
_indexRebuilder.RebuildIndexes(_onlyEmptyIndexes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user