Loading ...
Sorry, an error occurred while loading the content.

DBM limitation ?

Expand Messages
  • Stephane Legrand
    Hello, The following program (see below), which indefinitely adds records in a DB file, fails every time with this error : Fatal error: exception
    Message 1 of 1 , Jul 27, 2002
    • 0 Attachment
      Hello,

      The following program (see below), which indefinitely adds records
      in a DB file, fails every time with this error :

      Fatal error: exception Dbm.Dbm_error("dbm_store failed")
      My problem is that i really can't see why it fails. The resulting
      DB file has a size around 160 Mb and there is more than 1 Gb free
      on the disk after the program fails so i can't see any reason why
      it could not add more records ? By the way, the DB file is nonetheless
      valid (it can be read by a Perl program).

      I use OCaml 3.04 and FreeBSD 4.6-stable.

      Any help will be welcome.
      Thanks.

      Stephane Legrand.

      (* ** *)

      let get_rnd_string nb_letters =
      let rec rnd_string s c =
      if (c <= nb_letters) then (
      let rnd = Random.int 26 in
      let rnd = rnd + 65 in
      let rnd_char = char_of_int rnd in
      let rnd_str = String.make 1 rnd_char in
      rnd_string (s ^ rnd_str) (c + 1)
      )
      else (s)
      in rnd_string "" 1;;

      let main file =
      let _ = Random.self_init () in
      let count = ref Int64.zero in
      let dbh = Dbm.opendbm file [Dbm.Dbm_rdwr; Dbm.Dbm_create] 0o644 in
      let close_db () =
      let _ = print_string ("count = " ^ Int64.to_string(!count) ^ "\n") in
      let _ = flush stdout in
      Dbm.close dbh
      in
      let _ = at_exit (close_db) in
      let add k v =
      count := Int64.succ !count;
      Dbm.replace dbh k v
      in
      let v = get_rnd_string 2048 in
      let _ = print_string("v= " ^ v ^ "\n"); flush stdout in
      while (true) do
      let k = get_rnd_string 64 in
      add k v
      done;;

      let _ = main "test-dbm";;

      (* ** *)


      --
      <stephane@...>
      <Stephane.Legrand@...>
      FreeBSD Francophone : http://www.freebsd-fr.org/
    Your message has been successfully submitted and would be delivered to recipients shortly.