Maria Abreu
Maria Abreu

Reputation: 75

How to corrupt a Raven Index

I am building a script that checks for corrupted indexes and resets them but I am having issues getting corrupted indexes locally.

Does anyone know how to force an index corruption for RavenDB?

Upvotes: 3

Views: 186

Answers (2)

Grisha Kotler
Grisha Kotler

Reputation: 457

To cause a corruption you can delete one of the header files (headers.one or headers.two or both) or delete one of the journal files (when the database is offline). The files are located under the relevant index folder.

Upvotes: 2

Danielle
Danielle

Reputation: 3839

You can simply divide by 0 and you will get index errors.
For example - define an index with:

from order in docs.Orders
select new
{
    order.Company,
    Total = order.Lines.Sum(l => (l.Quantity / 0))
}

Update:

Go to Debugging Index Errors To see how you can generate:

Index Compilation Errors -and/or-
Index Execution Errors

https://ravendb.net/docs/article-page/4.1/Csharp/indexes/troubleshooting/debugging-index-errors

Upvotes: 1

Related Questions