Skip to content

Weird attribute caching bug brings values back from the deadΒ #1182

@david-macmahon

Description

@david-macmahon

Using HDF5.jl v0.17.2, attributes seem to have some weird caching problem that brings old values back from the dead. To recreate:

  1. Create/set an attribute to one value
  2. Delete the attribute
  3. Create/set the same attribute to a different value
  4. Reading the attribute value returns the originally written value, not the new value
  5. Closing and re-opening the file and re-reading the attribute gets the new value
julia> h5 = h5open("test.h5", "w")
πŸ—‚οΈ HDF5.File: (read-write) test.h5

julia> h5["data"] = rand(4,3);

julia> h5["data"]["attr"] = "foo"
"foo"

julia> h5
πŸ—‚οΈ HDF5.File: (read-write) test.h5
└─ πŸ”’ data
   └─ 🏷️ attr

julia> h5["data"]["attr"][]
"foo"

julia> delete_attribute(h5["data"], "attr")

julia> h5
πŸ—‚οΈ HDF5.File: (read-write) test.h5
└─ πŸ”’ data

julia> h5["data"]["attr"][]
ERROR: KeyError: key "attr" not found
Stacktrace:
 [1] getindex(dset::HDF5.Dataset, name::String)
   @ HDF5 ~/.julia/packages/HDF5/Z859u/src/attributes.jl:403
 [2] top-level scope
   @ REPL[119]:1

julia> h5["data"]["attr"] = "bar"
"bar"

julia> h5["data"]["attr"][] # Should return "bar"!!!
"foo"

julia> close(h5)

julia> h5 = h5open("test.h5")
πŸ—‚οΈ HDF5.File: (read-only) test.h5
└─ πŸ”’ data
   └─ 🏷️ attr

julia> h5["data"]["attr"][]
"bar"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions