Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/ServiceControl.RavenDB/IndexDeployment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public static async Task CreateIndexesAsync(IEnumerable<AbstractIndexCreationTas
var databaseDefault = await GetDatabaseSearchEngineType(store, cancellationToken);
var databaseDefaultIsLucene = string.Equals(databaseDefault, nameof(SearchEngineType.Lucene), StringComparison.OrdinalIgnoreCase);

Logger.LogInformation("Database {DatabaseName} static index search engine setting: {DatabaseDefault}", store.Database, databaseDefault ?? "not set, the server default applies");

foreach (var index in indexList)
{
var replacementName = Constants.Documents.Indexing.SideBySideIndexNamePrefix + index.IndexName;
Expand All @@ -43,6 +45,18 @@ public static async Task CreateIndexesAsync(IEnumerable<AbstractIndexCreationTas
var changes = existing == null ? IndexDefinitionCompareDifferences.None : RebuildChanges(existing, index, store);
var changed = changes != IndexDefinitionCompareDifferences.None;

if (existing?.LockMode is IndexLockMode.LockedIgnore or IndexLockMode.LockedError)
{
if (changed)
{
Logger.LogError("Index {IndexName} is locked ({LockMode}) and its definition changed ({Changes}). The change is not applied until the index is unlocked", index.IndexName, existing.LockMode, changes);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauroservienti and I have discussed that maybe it is even better to throw an exception here as some part of application depends on this change. If this part is not critical then maybe its not that important to throw but we align on that we should throw here.

}
else
{
Logger.LogWarning("Index {IndexName} is locked ({LockMode}). Definition changes from new versions are not applied until the index is unlocked", index.IndexName, existing.LockMode);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is, this message could raise support questions for no good reason. What about:

Suggested change
Logger.LogWarning("Index {IndexName} is locked ({LockMode}). Definition changes from new versions are not applied until the index is unlocked", index.IndexName, existing.LockMode);
Logger.LogWarning("Index {IndexName} is locked ({LockMode}). This version of ServiceControl doesn't contain index changes. Definition changes from new versions are not applied until the index is unlocked", index.IndexName, existing.LockMode);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, however, I would try to make it shorter...

Something like "Index XX is locked but definition is full compatible"?

}
}

// 1. A search engine set in our index definition always wins. It can be set through SearchEngineType or Configuration.
if (index.SearchEngineType.HasValue)
{
Expand Down Expand Up @@ -75,14 +89,17 @@ public static async Task CreateIndexesAsync(IEnumerable<AbstractIndexCreationTas
{
var reason = existing == null ? "is created" : $"is rebuilt because its definition changed ({changes})";

// A rebuild of a large index takes long and degrades ingestion, see docs.particular.net/servicecontrol/upgrades/#upgrades-that-rebuild-indexes
var level = changed ? LogLevel.Warning : LogLevel.Information;

if (databaseDefaultIsLucene)
{
Logger.LogInformation("Index {IndexName} {Reason} and inherits the Lucene search engine from the database", index.IndexName, reason);
Logger.Log(level, "Index {IndexName} {Reason} and inherits the Lucene search engine from the database", index.IndexName, reason);
}
else
{
index.Configuration[StaticSearchEngineTypeKey] = nameof(SearchEngineType.Lucene);
Logger.LogInformation("Index {IndexName} {Reason} with the Lucene search engine set on the index, the database setting is {DatabaseDefault}", index.IndexName, reason, databaseDefault ?? "not set");
Logger.Log(level, "Index {IndexName} {Reason} with the Lucene search engine set on the index, the database setting is {DatabaseDefault}", index.IndexName, reason, databaseDefault ?? "not set");
}

continue;
Expand Down
Loading