liuis / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

DestroyDB() doesn't remove .ldb files #208

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
New LevelDB directories with .ldb files don't get properly cleaned up by a 
DestroyDB() which still seems to only be looking for .sst files. Everything 
else is properly removed, leaving only .ldb files.

(1.14.0)

Original issue reported on code.google.com by rod.v...@xprime.com.au on 9 Oct 2013 at 8:12

GoogleCodeExporter commented 9 years ago
Seems to be working for me on linux. On what platform are you seeing it?

You would see this behavior if you created a leveldb instance with 1.14.0 but 
tried to delete it with a previous version. Any chance that's what happened? 
(Sorry, I know nothing about node.js so don't know how possible that could be.)

Original comment by dgrogan@chromium.org on 9 Oct 2013 at 7:54

GoogleCodeExporter commented 9 years ago
I'll try and narrow down a small piece of code to reproduce what I'm seeing.

Original comment by rod.v...@xprime.com.au on 12 Oct 2013 at 1:47

GoogleCodeExporter commented 9 years ago
OK, so DestroyDB() works OK except when you run RepairDB before it, so perhaps 
this is a repair problem?

Try this and it'll delete everything but end up with a "lost" directory.

<code language="c++">
#include <leveldb/db.h>
#include <stdio.h>

int main (int argc, char** argv) {
  leveldb::DB* db;
  leveldb::Options options;
  options.create_if_missing = true;
  leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
  char key [10];
  for (int i = 0; i < 200000; i++) {
    sprintf(key, "%d key", i);
    db->Put(leveldb::WriteOptions(), key, "some long string used to fill up more than one sst");
  }
  delete db;

  leveldb::RepairDB("/tmp/testdb", leveldb::Options());

  leveldb::DestroyDB("/tmp/testdb", leveldb::Options());
}
</code>

Original comment by rod.v...@xprime.com.au on 22 Oct 2013 at 4:41