Skip to content

Commit e6d6495

Browse files
hisundarchiyoung
authored andcommitted
MB-22046: forestdb_dump --key must work on deleted keys too
Don't dump full header if a specific key or specific kv store name is given. This is to aid testing code which is just examining if a given key made it to the storage end. Search by meta if search by key fails so that deleted keys can be point searched too. Change-Id: I460f663d5d7eab3ac89f814c12fb1be3c78c11ed Reviewed-on: http://review.couchbase.org/71618 Tested-by: buildbot <build@couchbase.com> Reviewed-by: abhinav dangeti <abhinav@couchbase.com>
1 parent c32c2fd commit e6d6495

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tools/forestdb_dump.cc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,14 @@ int scan_docs(fdb_kvs_handle *db, struct dump_option *opt, char *kvs_name)
193193
if (fs == FDB_RESULT_SUCCESS) {
194194
offset = fdoc->offset;
195195
print_doc(db, kvs_name, offset, opt);
196-
} else {
197-
return -1;
196+
} else { // MB-22046: Also need to be able to print deleted doc
197+
fs = fdb_get_metaonly(db, fdoc);
198+
if (fs == FDB_RESULT_SUCCESS) {
199+
offset = fdoc->offset;
200+
print_doc(db, kvs_name, offset, opt);
201+
} else {
202+
return -1;
203+
}
198204
}
199205
fdb_doc_free(fdoc);
200206
fdoc = NULL;
@@ -250,9 +256,12 @@ int process_file(struct dump_option *opt)
250256
printf("\nUnable to open %s\n", filename);
251257
return -3;
252258
}
253-
print_header(dbfile->getRootHandle());
254-
if (opt->print_header_only) {
255-
return 0;
259+
if (!opt->one_key && !opt->one_kvs) {
260+
// MB-22046: Avoid dumping header for specific kvs or specific key dump
261+
print_header(dbfile->getRootHandle());
262+
if (opt->print_header_only) {
263+
return 0;
264+
}
256265
}
257266

258267
kvs_config = fdb_get_default_kvs_config();
@@ -278,7 +287,10 @@ int process_file(struct dump_option *opt)
278287
}
279288

280289
ret = scan_docs(db, opt, name_list.kvs_names[i]);
281-
if (ret == -1) {
290+
if (ret == -1 && opt->one_kvs) {
291+
// Only print key not found if a specific key is accompanied by
292+
// a specific kv store.
293+
// Otherwise scan all kv stores for the same key..
282294
printf("KV store '%s': key not found\n", name_list.kvs_names[i]);
283295
}
284296
fdb_kvs_close(db);

0 commit comments

Comments
 (0)