11 Replies Latest reply on Apr 19, 2011 7:22 PM by 852920

    data loss when reading v7 hashes with db 4.7.25

    657965
      On a v7 hash created with db_load from db 3.2.9, db_dump from 4.7.25 will corrupt the database file unless either -r or -R are specified. With a v8 btree, 4.7's db_dump -p will output correctly but a db_dump -d a will not. In either case, dumping the v8 btree does not appear to lead to data loss.

      4.7's db_verify on the v7 hash gives an error about an impossible max_buckets setting in the metadata page. It seems to do this because it clobbers the last_pgno setting
      and compares 1, for instance, against 0 instead of 2.

      This patch prevents the clobbering with a 0:

      diff --git a/btree/bt_open.c b/btree/bt_open.c
      index f03652d..d77c7d6 100644
      --- a/btree/bt_open.c
      +++ b/btree/bt_open.c
      @@ -314,7 +314,7 @@ __bam_read_root(dbp, ip, txn, base_pgno, flags)

      t->bt_meta = base_pgno;
      t->bt_root = meta->root;
      - if (PGNO(meta) == PGNO_BASE_MD && !F_ISSET(dbp, DB_AM_RECOVER))
      + if (PGNO(meta) == PGNO_BASE_MD && meta->dbmeta.last_pgno > 0 && !F_ISSET(dbp, DB_AM_RECOVER))
      __memp_set_last_pgno(mpf, meta->dbmeta.last_pgno);
      } else {
      DB_ASSERT(dbp->env,
      diff --git a/hash/hash_open.c b/hash/hash_open.c
      index f5e1d7f..769b583 100644
      --- a/hash/hash_open.c
      +++ b/hash/hash_open.c
      @@ -110,6 +110,7 @@ __ham_open(dbp, ip, txn, name, base_pgno, flags)
      if (F_ISSET(&hcp->hdr->dbmeta, DB_HASH_SUBDB))
      F_SET(dbp, DB_AM_SUBDB);
      if (PGNO(hcp->hdr) == PGNO_BASE_MD &&
      + hcp->hdr->dbmeta.last_pgno > 0 &&
      !F_ISSET(dbp, DB_AM_RECOVER))
      __memp_set_last_pgno(dbp->mpf,
      hcp->hdr->dbmeta.last_pgno);

      1) Is this a correct/good fix?
      2) Why is db_dump writing to database files?