Can't delete index using build 616

45 views
Skip to first unread message

spokey

unread,
Feb 2, 2012, 5:05:12 PM2/2/12
to rav...@googlegroups.com
Using build 616 I can no longer delete indexes like this:

[TestMethod]
public void Can_delete_index()
{
    new AllDocs().Execute(DocStore);
    DocStore.DatabaseCommands.DeleteIndex("AllDocs");
}

private class AllDocs : AbstractIndexCreationTask<object>
{
    public AllDocs() {Map = docs => from doc in docs select new { }; }
}
/*
 Test method RavenDB.Examples.Test.Tests.Bugs.Failing.CanDeleteIndex.Can_delete_index threw exception:
Newtonsoft.Json.JsonSerializationException: Could not parse: [] ---> System.Exception: Error reading RavenJToken from JsonReader.
at Raven.Json.Linq.RavenJToken.ReadFrom(JsonReader reader) in c:\Builds\raven\Raven.Abstractions\Json\Linq\RavenJToken.cs: line 145
at Raven.Json.Linq.RavenJToken.Load(JsonReader reader) in c:\Builds\raven\Raven.Abstractions\Json\Linq\RavenJToken.cs: line 198
at Raven.Json.Linq.RavenJToken.Parse(String json) in c:\Builds\raven\Raven.Abstractions\Json\Linq\RavenJToken.cs: line 179
--- End of inner exception stack trace ---
at Raven.Json.Linq.RavenJToken.Parse(String json) in c:\Builds\raven\Raven.Abstractions\Json\Linq\RavenJToken.cs: line 183
at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() in c:\Builds\raven\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs: line 594
at Raven.Client.Connection.ServerClient.DirectDeleteIndex(String name, String operationUrl) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 725
at Raven.Client.Connection.ServerClient.<>c__DisplayClass3c.<DeleteIndex>b__3b(String operationUrl) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 718
at Raven.Client.Connection.ServerClient.<>c__DisplayClassa.<ExecuteWithReplication>b__9(String operationUrl) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 145
at Raven.Client.Connection.ServerClient.TryOperation(Func`2 operation, String operationUrl, Boolean avoidThrowing, ref T result) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 196
at Raven.Client.Connection.ServerClient.ExecuteWithReplication(String method, Func`2 operation) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 166
at Raven.Client.Connection.ServerClient.ExecuteWithReplication(String method, Action`1 operation) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 143
at Raven.Client.Connection.ServerClient.DeleteIndex(String name) in c:\Builds\raven\Raven.Client.Lightweight\Connection\ServerClient.cs: line 718
at RavenDB.Examples.Test.Tests.Bugs.Failing.CanDeleteIndex.Can_delete_index() in CanDeleteIndex.cs: line 17
 */

Fitzchak Yitzchaki

unread,
Feb 5, 2012, 3:04:30 AM2/5/12
to rav...@googlegroups.com
Hey,
I opened an issue for that: http://issues.hibernatingrhinos.com/issue/RavenDB-20.

Oren Eini (Ayende Rahien)

unread,
Feb 5, 2012, 11:02:29 AM2/5/12
to rav...@googlegroups.com
Thanks, fixed now.

On Fri, Feb 3, 2012 at 12:05 AM, spokey <jeffrey....@gmail.com> wrote:

Micha Schopman

unread,
Feb 16, 2012, 8:22:08 AM2/16/12
to ravendb
I've noticed this issue also, and just did an upgrade to build 648.
Deleting does not throw an exception anymore, but... the index is not
removed either. :)

For reproduction, this is my code:

public class EntityEntityIdPatch : AbstractIndexCreationTask<Entity>
{
private readonly IDocumentStore store;
public EntityEntityIdPatch(IDocumentStore store)
{
this.store = store;
Execute();
}

public EntityEntityIdPatch()
{
Map = docs => from doc in docs
select new { doc.Label };
}

public void Execute(){

// create index

IndexCreation.CreateIndexes(typeof(EntityEntityIdPatch).Assembly,
store);

// wait for the index
while
(store.DatabaseCommands.GetStatistics().StaleIndexes.Length != 0)
Thread.Sleep(10);

// execute the patch using the index

store.DatabaseCommands.UpdateByIndex("EntityEntityIdPatch",
new IndexQuery(),
new[] {new PatchRequest() {
Type = PatchCommandType.Rename,
Name = "EntityType",
Value = new RavenJValue("EntityTypeId")
}
},false);

// remove the index
store.DatabaseCommands.DeleteIndex("EntityEntityIdPatch");
}
}


Oren Eini (Ayende Rahien)

unread,
Feb 16, 2012, 9:24:22 AM2/16/12
to rav...@googlegroups.com
We are talking about deleting from the UI (the original) issue, or deleting via code?

Micha Schopman

unread,
Feb 16, 2012, 9:37:01 AM2/16/12
to ravendb
Hi Ayende, this is via code (store.DatabaseCommands.DeleteIndex). Via
the UI the deletion just works ok :)

I attached the code in my previous reply for reproduction purposes. :)


On Feb 16, 3:24 pm, "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
wrote:

Oren Eini (Ayende Rahien)

unread,
Feb 16, 2012, 10:30:53 AM2/16/12
to rav...@googlegroups.com
Your code make no sense to me. 
You shouldn't have ANY code inside the abstract indexing task. 

Here is a passing test:

public class Micha : RavenTest
{
public class Entity
{
public string Label { get; set; }
}

public class EntityEntityIdPatch : AbstractIndexCreationTask<Entity>
{
public EntityEntityIdPatch()
{
Map = docs => from doc in docs
 select new { doc.Label };
}
}

[Fact]
public void CanDeleteIndex()
{
using(var store = NewDocumentStore())
{
new EntityEntityIdPatch().Execute(store);

WaitForIndexing(store);

store.DatabaseCommands.UpdateByIndex("EntityEntityIdPatch",
                                    new IndexQuery(),
                                    new[]
                                    {
                                    new PatchRequest()
                                    {
                                    Type = PatchCommandType.Rename,
                                    Name = "EntityType",
                                    Value = new RavenJValue("EntityTypeId")
                                    }
                                    }, false);

store.DatabaseCommands.DeleteIndex("EntityEntityIdPatch");

Assert.False(store.DocumentDatabase.Statistics.Indexes.Any(x => x.Name == "EntityEntityIdPatch"));
Reply all
Reply to author
Forward
0 new messages