AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/servicecontrol/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

RavenDB search engine

Component:
ServiceControl

RavenDB supports two search engines for indexes: Corax and Lucene. The selected engine determines how RavenDB builds and queries an index. The choice of engine is made when creating a database or index, and while it can be changed later, doing so triggers a full index rebuild.

The ServiceControl error and audit databases have a specific workload: messages are ingested continuously, expired messages are deleted continuously by the retention process, and the data is queried only occasionally, when ServicePulse is used. Load testing of this workload showed that, for the index definitions ServiceControl uses, Lucene indexes:

  • take up less storage
  • use less memory
  • keep up with ingestion and deletion with less index lag
  • query faster

Meanwhile, Corax demonstrated more performance and stability issues on large ServiceControl databases. Because of this, starting with ServiceControl version 6.20, new databases default to using Lucene, and migrating existing databases to Lucene is recommended.

Default search engine per version

ServiceControl versionSearch engine for new databasesExisting databases
5.x and 6.0–6.19CoraxKeep the engine they were created with
6.20 and laterLuceneKeep the engine they were created with

As the table above illustrates, upgrading ServiceControl does not impact the search engine of existing databases. This is because changing the engine triggers a full rebuild of every index which, depending on the available computing power, can take days on very large databases. In addition, while the rebuild runs, the ingestion and indexing rates are degraded. Thus, migration should be planned and scheduled for each environment. See Should existing indexes be migrated? and Migrating existing indexes to Lucene for more details.

Detecting indexes that use Corax

Available in version 6.20

Error and audit instances report indexes using Corax in two ways:

  • A custom check named Error Database Search Engine (error instance) or Audit Database Search Engine (audit instance), visible in ServicePulse. The check fails when at least one index uses Corax. It is evaluated hourly.
  • A warning in the instance log at every start-up.

Both list the affected indexes and contain the following message:

The following RavenDB index(es) use the Corax search engine: <database>/<index>. Lucene indexes are smaller, use less memory and perform better for ServiceControl workloads, and are the default for new databases. Consider switching these indexes to Lucene. Note that switching triggers a full rebuild of the index: on very large databases this can take days depending on the available compute, and while the rebuild is running ingestion and indexing rates can be degraded. Plan the switch accordingly.

The search engine of an index can also be inspected in RavenDB Studio, on the Configuration tab of the index, or in the Indexes list where each index shows its engine.

Should existing indexes be migrated?

Yes. Migrating existing error and audit databases to Lucene is recommended for all instances. Corax has shown performance and stability issues on large ServiceControl databases, and these issues get worse as the database grows. Migrating proactively, while the database is small and the instance is healthy, keeps the rebuild short and efficient. This avoids a more complicated migration when the instance is already struggling.

Migrate as soon as possible when the instance shows one or more of the following symptoms. They indicate that the Corax indexes can no longer keep up with the load:

Instances without these symptoms should be migrated in the next planned maintenance window. Because the rebuild requires downtime or degraded ingestion, plan the migration separately for each environment. Migrate development and test instances first to estimate the rebuild duration for production. The Error Database Search Engine or Audit Database Search Engine custom check continues to fail until all indexes use Lucene.

Migrating existing indexes to Lucene

The migration is performed per index in RavenDB Studio.

The indexes with the highest load, and therefore the ones that benefit most, are:

InstanceIndex
ErrorFailedMessageViewIndex, MessagesViewIndex
AuditMessagesViewIndex or MessagesViewIndexWithFullTextSearch (depending on whether full-text search on message bodies is enabled)

Other indexes can be migrated using the same procedure. Migrate one index at a time and wait for it to become non-stale before migrating the next one to limit the impact on ingestion.

1. Access the RavenDB Studio

  • Windows deployment: Start the instance in maintenance mode and click Launch RavenDB Studio.
  • Container deployment: Stop the ServiceControl container and open RavenDB Studio on port 8080 of the database container.
  • External RavenDB server: Open RavenDB Studio for the server that hosts the ServiceControl database.

Running the migration while the instance is stopped (maintenance mode) is recommended. It avoids ingestion competing with the rebuild for CPU and I/O and prevents the instance from resetting the index before it has been locked. Messages will accumulate in the error and audit queues while the instance is stopped; ensure the queues have enough capacity for the expected duration.

2. Change the search engine of the index

  1. In RavenDB Studio, select the ServiceControl database and open Indexes > List of Indexes.
  2. Click the index to edit it.
  3. Open the Configuration tab.
  4. Change Search engine from Corax or Corax (inherited) to Lucene.
  5. Click Save.

RavenDB creates a replacement index that uses Lucene and runs side-by-side with the existing Corax index. The existing index will keep serving queries until the replacement has caught up.

3. Swap the indexes

In the List of Indexes, the index shows the replacement being built. Once the replacement is no longer stale, RavenDB swaps it in automatically and deletes the Corax index. RavenDB Studio also offers swap now:

  • Swapping immediately frees the storage of the Corax index right away but queries return stale results until the Lucene index has been fully rebuilt.
  • Waiting for the automatic swap keeps queries accurate but temporarily requires storage for both indexes.

4. Lock the index

While still in RavenDB Studio, click the 🔓 Unlocked button of the migrated index and change it to 🔒 Locked (ignore) (lock modes). RavenDB Studio confirms with Lock mode was set to: Locked (ignore).

A locked index is left untouched when ServiceControl recreates its index definitions at start-up, so the index stays on Lucene.

5. Restart the instance

Stop maintenance mode or start the ServiceControl container. The next start-up no longer logs a warning for the migrated index, and the Error Database Search Engine / Audit Database Search Engine custom check passes once all indexes use Lucene.

Migrating the whole database

Instead of migrating indexes one by one, the database default can be changed so that all indexes, including future ones, use Lucene without locking:

  1. In RavenDB Studio, open Settings > Database Settings for the ServiceControl database.
  2. Set both Indexing.Static.SearchEngineType and Indexing.Auto.SearchEngineType to Lucene and save.
  3. Reload the database when prompted.
  4. Reset each index (List of Indexes > index menu > Reset) so that it is rebuilt with the new engine.

Resetting an index deletes it and rebuilds it from scratch; queries against it return stale results until the rebuild completes. Because all indexes are rebuilt, this approach causes a longer period of degraded performance than migrating individual indexes, but does not require indexes to be locked and applies to indexes added by future ServiceControl versions as well. Because the custom check only passes once all indexes use Lucene, this approach is the most direct way to complete the migration.

Related Articles