irmin icon indicating copy to clipboard operation
irmin copied to clipboard

[irmin-pack] dangling hash when using contents other than string

Open eWert-Online opened this issue 3 months ago • 2 comments

I had a look into irmin-pack (currently I am using irmin-fs.unix), but I wasn't able to get it running reliably. I am using the following configuration:

module Contents = struct
  type t =
    { name : string
    ; deck : string list
    ; reveal : [ `Everyone | `SpectatorsOnly ]
    }
  [@@deriving irmin]

  let merge = Irmin.Merge.(option (idempotent t))
end

module Conf = struct
  let entries = 32
  let stable_hash = 256
  let contents_length_header = Some `Varint
  let inode_child_order = `Seeded_hash
  let forbid_empty_dir_persistence = true
end

module Repo_config = struct
  let index_log_size = 2_500_000
  let merge_throttle = `Block_writes
  let indexing_strategy = Irmin_pack.Indexing_strategy.minimal
  let root = Filename.concat (Sys.getcwd ()) "db"
  let fresh = false

  let config =
    Irmin_pack.config ~fresh ~index_log_size ~merge_throttle ~indexing_strategy root
  ;;
end

module StoreMaker = Irmin_pack_unix.KV (Conf)
module Store = StoreMaker.Make (Contents)

Inserting data seems to be fine, but trying to read them again, yields the error message: Irmin.Tree.to_concrete: encountered dangling hash ab6a424af22507531d8e3ca6e98e5a885773b19f40743213ab5e55c7a8289360c6717881db7af0b7ff39e1b225d9e015605b5612de7d0c84fc5c6cc3d67df4e9.

When I switch the contents to be Irmin.Contents.String everything is working. Does irmin-pack only support string contents?

eWert-Online avatar Sep 24 '25 17:09 eWert-Online

Hello, Irmin_pack content's is not limited to Irmin.Contents.String, you should be able to use it with anything. I gave a look at your issue and it seems to stems from the indexing_strategy you have used. Not setting up at all or using any of the other strategies will work (even minimal_with_contents). I'll try to get some times to further look into it as it might a bug, but in the meantime, you should be able to use irmin-pack if you change it. Hope it was of help, do not hesitate if you meet further issues.

clecat avatar Sep 30 '25 14:09 clecat

(I also got issues with contents_length_header = Some `Varint not working properly, you might want to set it as None if you meet problems with Repr and out of bound indexes)

clecat avatar Sep 30 '25 14:09 clecat