IndexNotFoundException during application shutdown


Description

When Sitecore XP restarts, the shutdown message is received by the application, indexing is stopped and the indexes are disposed. The UpdateIndexTimestampTimerTick event handler might get executed after the search indexes are disposed, resulting in an IndexNotFoundException:

15:05:28 WARN  Hosting Environment Stop Requested : immediate=False
...
15:05:39 ERROR Custodian.UpdateIndexTimestampTimerTick. Update index last updated failed
Exception: Sitecore.ContentSearch.Exceptions.IndexNotFoundException
Message: Index sitecore_web_index was not found
Source: Sitecore.ContentSearch
   at Sitecore.ContentSearch.ContentSearchManager.GetIndex(String name)
   at Sitecore.ContentSearch.Maintenance.EventHub.UpdateIndexTimestampTimerTick(Object state)
...

Solution

The UpdateIndexTimestampTimerTick event handler is used to update the Last Updated index property.
The only place where this property is used is the Indexing Manager dialog:

Indexing Manager dialog

Once the application restarts the UpdateIndexTimestampTimerTick event handler continues to update the Last Updated index property. In other words, the error is harmless and is safe to ignore.