diff --git a/src/datastore/leveldb_shard.go b/src/datastore/leveldb_shard.go index 03a1ab320f1..690c74a191d 100644 --- a/src/datastore/leveldb_shard.go +++ b/src/datastore/leveldb_shard.go @@ -3,13 +3,10 @@ package datastore import ( "bytes" "cluster" - "code.google.com/p/goprotobuf/proto" - log "code.google.com/p/log4go" "common" "encoding/binary" "errors" "fmt" - "github.com/jmhodges/levigo" "math" "parser" "protocol" @@ -17,6 +14,10 @@ import ( "strings" "sync" "time" + + "code.google.com/p/goprotobuf/proto" + log "code.google.com/p/log4go" + "github.com/jmhodges/levigo" ) type LevelDbShard struct { @@ -137,8 +138,6 @@ func (self *LevelDbShard) DropDatabase(database string) error { log.Error("DropDatabase: ", err) } - seriesKey := append(DATABASE_SERIES_INDEX_PREFIX, []byte(database+"~")...) - wb.Delete(seriesKey) } return self.db.Write(self.writeOptions, wb) @@ -375,15 +374,17 @@ func (self *LevelDbShard) dropSeries(database, series string) error { wb := levigo.NewWriteBatch() defer wb.Close() - for _, name := range self.getColumnNamesForSeries(database, series) { - if err := self.deleteRangeOfSeriesCommon(database, series, startTimeBytes, endTimeBytes); err != nil { - return err - } + if err := self.deleteRangeOfSeriesCommon(database, series, startTimeBytes, endTimeBytes); err != nil { + return err + } + for _, name := range self.getColumnNamesForSeries(database, series) { indexKey := append(SERIES_COLUMN_INDEX_PREFIX, []byte(database+"~"+series+"~"+name)...) wb.Delete(indexKey) } + wb.Delete(append(DATABASE_SERIES_INDEX_PREFIX, []byte(database+"~"+series)...)) + // remove the column indeces for this time series return self.db.Write(self.writeOptions, wb) } diff --git a/src/integration/benchmark_test.go b/src/integration/benchmark_test.go index 6c56be28915..723de0d8b37 100644 --- a/src/integration/benchmark_test.go +++ b/src/integration/benchmark_test.go @@ -349,6 +349,7 @@ func (self *IntegrationSuite) TestExplainsWithPassthrough(c *C) { c.Assert(series[0].Points[0][6], Equals, float64(2.0)) } +// issue #342, #371 func (self *IntegrationSuite) TestDataResurrectionAfterRestart(c *C) { s := self.createPoints("data_resurrection", 1, 10) b, err := json.Marshal(s) @@ -387,6 +388,12 @@ func (self *IntegrationSuite) TestDataResurrectionAfterRestart(c *C) { err = json.Unmarshal(data, &series) c.Assert(err, IsNil) c.Assert(series, HasLen, 0) + data, err = self.server.RunQuery("list series", "s") + c.Assert(err, IsNil) + series = []*SerializedSeries{} + err = json.Unmarshal(data, &series) + c.Assert(err, IsNil) + c.Assert(series, HasLen, 0) } func (self *IntegrationSuite) TestExplainsWithPassthroughAndLimit(c *C) {