I'm trying to write a utility that purges all attachments from a
RavenDB database. I'm running into exceptions on both build 888 and
952. I'm using the /static endpoint to get a list of attachments, and
trying to delete them by key.
On a tenant database using build 952, some of the attachments appeared
to be deleted. However, every time I now request
http://localhost:8080/databases/tenant-name/static, I get the
following exception returned:
System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at
Raven.Storage.Esent.StorageActions.DocumentStorageActions.<GetAttachmentsByReverseUpdateOrder>d__3.MoveNext()
in c:\Builds\RavenDB-Unstable\Raven.Storage.Esent\StorageActions
\DocumentStorageActions.cs:line 110
at System.Linq.Enumerable.<TakeIterator>d__3a`1.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at
Raven.Database.DocumentDatabase.<>c__DisplayClassb6.<GetAttachments>b__b5(IStorageActionsAccessor
actions) in c:\Builds\RavenDB-Unstable\Raven.Database
\DocumentDatabase.cs:line 1085
at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action`1
action) in c:\Builds\RavenDB-Unstable\Raven.Storage.Esent
\TransactionalStorage.cs:line 376
at Raven.Storage.Esent.TransactionalStorage.Batch(Action`1 action)
in c:\Builds\RavenDB-Unstable\Raven.Storage.Esent
\TransactionalStorage.cs:line 337
at Raven.Database.DocumentDatabase.GetAttachments(Int32 start,
Int32 pageSize, Nullable`1 etag) in c:\Builds\RavenDB-Unstable
\Raven.Database\DocumentDatabase.cs:line 1082
at Raven.Database.Server.Responders.Statics.Respond(IHttpContext
context) in c:\Builds\RavenDB-Unstable\Raven.Database\Server\Responders
\Statics.cs:line 26
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext
ctx) in c:\Builds\RavenDB-Unstable\Raven.Database\Server
\HttpServer.cs:line 550
at
Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)
in c:\Builds\RavenDB-Unstable\Raven.Database\Server\HttpServer.cs:line
316
If I try to retrieve attachment metadata using HeadAttachment(key) on
either the default database or tenant database using build 952, I get
the following exception:
Object reference not set to an instance of an object.
at Raven.Client.Connection.ServerClient.DirectGetAttachment(String
method, String key, String operationUrl) in c:\Builds\RavenDB-Unstable
\Raven.Client.Lightweight\Connection\ServerClient.cs:line 475
at
Raven.Client.Connection.ServerClient.<>c__DisplayClass1c.<HeadAttachment>b__1b(String
operationUrl) in c:\Builds\RavenDB-Unstable\Raven.Client.Lightweight
\Connection\ServerClient.cs:line 457
at Raven.Client.Connection.ServerClient.TryOperation[T](Func`2
operation, String operationUrl, Boolean avoidThrowing, T& result) in c:
\Builds\RavenDB-Unstable\Raven.Client.Lightweight\Connection
\ServerClient.cs:line 223
at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T]
(String method, Func`2 operation) in c:\Builds\RavenDB-Unstable
\Raven.Client.Lightweight\Connection\ServerClient.cs:line 193
at Raven.Client.Connection.ServerClient.HeadAttachment(String key)
in c:\Builds\RavenDB-Unstable\Raven.Client.Lightweight\Connection
\ServerClient.cs:line 457
at RavenPurgeAttachments.Program.PurgeAttachments(String url,
IEnumerable`1 keys) in C:\@Projects\celljournalist\celljournalist
\RavenPurgeAttachments\Program.cs:line 88
at RavenPurgeAttachments.Program.Main(String[] args) in C:\@Projects
\celljournalist\celljournalist\RavenPurgeAttachments\Program.cs:line 70