#2 Sdbm looses entries when storing large amounts of data.

closed-fixed
nobody
None
5
2003-05-19
2003-05-07
Anonymous
No

Attached is a tar ball that demonstrates the problem.
Unpack it, and execute via:

sh test.sh

The script calls a Test program which creates and
populates a database with 500K entries, each unique,
starting with key0000000=val0000000. It then checks to
see if each of the created entries actually exists, and
fails on the first miss.

The program continues on to run a binary search
algorithm, finding the point at which the database
first looses data.

I have verified that this behaviour does not exist in
Perl's SDBM_File, and I have tested this on linux
(RedHat 9.0),
Windows 2000 Server, and Solaris, each under JDK1.4.

If you have any questions, you can contact me at
sbrown@connecterra.net

Sheldon

Discussion

  • Nobody/Anonymous

    Test harness

     
    Attachments
  • Sheldon A. Brown

    Logged In: YES
    user_id=777965

    After further investigation, the java code is missing the
    equivalent of a memset. When the directory file size is
    increased, garbage may be introduced. Here's the diff of
    the fix:

    diff -c -4 sdbm-src/sdbm/src/org/solinger/sdbm/Sdbm.java
    patch/sdbm/src/org/s
    olinger/sdbm/Sdbm.java
    *** sdbm-src/sdbm/src/org/solinger/sdbm/Sdbm.java
    1999-11-28 20:27:57.0000
    00000 -0500
    --- patch/sdbm/src/org/solinger/sdbm/Sdbm.java 2003-05-13
    13:04:22.000000000 -0
    400
    ***************
    *** 511,518 ****
    --- 511,519 ----
    c = dbit / BITSINBYTE;
    dirb = c / DBLKSIZ;

    if (dirb != dirbno) {
    + clearByteArray(dirbuf);
    dirf.seek(OFF_DIR(dirb));
    readLots(dirf,dirbuf,0, DBLKSIZ);

    dirbno = dirb;
    ***************
    *** 580,585 ****
    --- 581,591 ----
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    + public static void clearByteArray(byte[] arr) {
    + for (int i=0;i<arr.length;i++) {
    + arr[i] = 0;
    + }
    + }

    }

     
  • Justin Chapweske

    • status: open --> open-fixed
     
  • Justin Chapweske

    Logged In: YES
    user_id=790

    Thanks for the patch! Incorporated into sdbm-1.0

     
  • Justin Chapweske

    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks