forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-22116 add debug method to delete document by etag
- Loading branch information
1 parent
83c5b18
commit be2539a
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Raven.Server.ServerWide.Context; | ||
using Voron.Data.Tables; | ||
|
||
namespace Raven.Server.Documents | ||
{ | ||
public partial class DocumentsStorage | ||
{ | ||
public Debugging ForDebug => new Debugging(this); | ||
|
||
public class Debugging | ||
{ | ||
private readonly DocumentsStorage _storage; | ||
|
||
public Debugging(DocumentsStorage storage) | ||
{ | ||
_storage = storage; | ||
} | ||
// Used to delete corrupted document from the JS admin console | ||
public void DeleteDocumentByEtag(long etag) | ||
{ | ||
using (_storage.ContextPool.AllocateOperationContext(out DocumentsOperationContext context)) | ||
using (var tx = context.OpenWriteTransaction()) | ||
{ | ||
var table = new Table(DocsSchema, context.Transaction.InnerTransaction); | ||
var index = DocsSchema.FixedSizeIndexes[AllDocsEtagsSlice]; | ||
|
||
if (table.FindByIndex(index, etag, out var reader)) | ||
{ | ||
var doc = _storage.TableValueToDocument(context, ref reader, DocumentFields.Id); | ||
_storage.Delete(context, doc.Id, DocumentFlags.None); | ||
tx.Commit(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters