public void DeleteIndex(string name) { name = IndexDefinitionStorage.FixupIndexName(name); IndexDefinitionStorage.RemoveIndex(name); IndexStorage.DeleteIndex(name); //we may run into a conflict when trying to delete if the index is currently //busy indexing documents for (var i = 0; i < 10; i++) { try { TransactionalStorage.Batch(action => { action.Indexing.DeleteIndex(name); workContext.ShouldNotifyAboutWork(); }); return; } catch (ConcurrencyException) { Thread.Sleep(100); } } }
public void DeleteIndex(string name) { using (IndexDefinitionStorage.TryRemoveIndexContext()) { var instance = IndexDefinitionStorage.GetIndexDefinition(name); if (instance == null) { return; } // Set up a flag to signal that this is something we're doing TransactionalStorage.Batch(actions => actions.Lists.Set("Raven/Indexes/PendingDeletion", instance.IndexId.ToString(CultureInfo.InvariantCulture), (RavenJObject.FromObject(new { TimeOfOriginalDeletion = SystemTime.UtcNow, instance.IndexId, IndexName = instance.Name })), UuidType.Tasks)); // Delete the main record synchronously IndexDefinitionStorage.RemoveIndex(name); Database.IndexStorage.DeleteIndex(instance.IndexId); WorkContext.ClearErrorsFor(name); // And delete the data in the background StartDeletingIndexDataAsync(instance.IndexId, name); // We raise the notification now because as far as we're concerned it is done *now* TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() => Database.Notifications.RaiseNotifications(new IndexChangeNotification { Name = name, Type = IndexChangeTypes.IndexRemoved, })); } }
public void DeleteIndex(string name) { IndexDefinitionStorage.RemoveIndex(name); IndexStorage.DeleteIndex(name); //we may run into a conflict when trying to delete if the index is currently //busy indexing documents for (var i = 0; i < 10; i++) { try { TransactionalStorage.Batch(action => { action.Indexing.DeleteIndex(name); workContext.ShouldNotifyAboutWork(); }); return; } catch (EsentErrorException e) { if (e.Error == JET_err.WriteConflict) { Thread.Sleep(100); continue; } throw; } } }
public void DeleteIndex(string name) { name = IndexDefinitionStorage.FixupIndexName(name); IndexDefinitionStorage.RemoveIndex(name); IndexStorage.DeleteIndex(name); //we may run into a conflict when trying to delete if the index is currently //busy indexing documents, worst case scenario, we will have an orphaned index //row which will get cleaned up on next db restart. for (var i = 0; i < 10; i++) { try { TransactionalStorage.Batch(action => { action.Indexing.DeleteIndex(name); workContext.ShouldNotifyAboutWork(); }); return; } catch (ConcurrencyException) { Thread.Sleep(100); } } }
internal void DeleteIndex(IndexDefinition instance, bool removeByNameMapping = true, bool clearErrors = true, bool removeIndexReplaceDocument = true, bool isSideBySideReplacement = false) { using (IndexDefinitionStorage.TryRemoveIndexContext()) { if (instance == null) { return; } // Set up a flag to signal that this is something we're doing TransactionalStorage.Batch(actions => actions.Lists.Set("Raven/Indexes/PendingDeletion", instance.IndexId.ToString(CultureInfo.InvariantCulture), (RavenJObject.FromObject(new { TimeOfOriginalDeletion = SystemTime.UtcNow, instance.IndexId, IndexName = instance.Name, instance.IndexVersion })), UuidType.Tasks)); // Delete the main record synchronously IndexDefinitionStorage.RemoveIndex(instance.IndexId, removeByNameMapping); Database.IndexStorage.DeleteIndex(instance.IndexId); if (clearErrors) { WorkContext.ClearErrorsFor(instance.Name); } var isSideBySide = instance.IsSideBySideIndex || instance.Name.StartsWith(Constants.SideBySideIndexNamePrefix, StringComparison.OrdinalIgnoreCase); if (removeIndexReplaceDocument && isSideBySide) { Database.Documents.Delete(Constants.IndexReplacePrefix + instance.Name, null, null); } Database.IndexStorage.DeleteSuggestionsData(instance.Name); //remove the header information in a sync process TransactionalStorage.Batch(actions => actions.Indexing.PrepareIndexForDeletion(instance.IndexId)); //and delete the data in the background Database.Maintenance.StartDeletingIndexDataAsync(instance.IndexId, instance.Name); var indexChangeType = isSideBySideReplacement ? IndexChangeTypes.SideBySideReplace : IndexChangeTypes.IndexRemoved; // We raise the notification now because as far as we're concerned it is done *now* TransactionalStorage.ExecuteImmediatelyOrRegisterForSynchronization(() => Database.Notifications.RaiseNotifications(new IndexChangeNotification { Name = instance.Name, Type = indexChangeType, Version = instance.IndexVersion }) ); } }