Skip to content

calling isopen on a multi-file NCDataset returns true even after close is called #310

Description

@fergu

Describe the bug

If a multi-file dataset is opened, calling close(ds) and then querying the file using isopen(ds) returns true. Additionally, reads of the dataset still succeed even after calling close(ds). This may not be a big issue because (I think) the underlying NetCDF files aren't held open until they need to be accessed, but this is slightly unexpected behavior as compared to the single-file case.

To Reproduce

Please provide a minimal julia code example which reproduces the behavior (bug, performance regression, ...).

julia> using NCDatasets
julia> files = readdir("test/data/"; join=true)
2-element Vector{String}
 "test/data/test_001.nc"
 "test/data/test_002.nc"
julia> ds = NCDataset(files, "r"; aggdim="time")
julia> isopen(ds)
true
julia> close(ds)
julia> isopen(ds)
true
julia> ds["time"][:]
# Expected time vector is returned

As a note, test_xxx.nc are just test NC files that I've created for some unit tests in a package I'm writing. They were also created using NCDatasets.

Expected behavior

isopen(ds) should have returned false, and reads should not have succeeded, similar to the single-file case.

Environment

  • operating system: [e.g. Ubuntu XX.YY]: Red Hat Enterprise Linux 8.10
  • Julia version: [e.g. julia 1.1.1, official binaries from https://julialang.org/downloads/]: 1.12.5, via juliaup
  • Output of the julia command versioninfo():
Julia Version 1.12.5
Commit 5fe89b8ddc1 (2026-02-09 16:05 UTC)
Build Info:
    Official https://julialang.org release
Platform Info:
    OS: Linux (x86_64-linux-gnu)
    CPU: 112 x Intel(R) Xeon(R) Platinum 8180 CPU @ 2.50GHz
    WORD_SIZE: 64
    LLVM: libLLVM-18.1.7 (ORCJIT, skylake-avx512)
    GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 112 virtual cores)
  • NCDatasets version: v0.14.15
  • Output of using Pkg; Pkg.status(mode=PKGMODE_MANIFEST)
Status `~/code/julia/workspaces/NCTest/Manifest.toml`
  [179af706] CFTime v0.2.10
  [1fbeeb36] CommonDataModel v0.4.3
  [187b0558] ConstructionBase v1.6.0
  [864edb3b] DataStructures v0.19.5
  [3c3547ce] DiskArrays v0.4.21
  [692b3bcd] JLLWrappers v1.8.0
  [8ac3fa9e] LRUCache v1.6.2
  [3da0fdf6] MPIPreferences v0.1.12
  [85f8d34a] NCDatasets v0.14.15
  [6fe1bfb0] OffsetArrays v1.17.0
⌅ [bac558e1] OrderedCollections v1.8.2
  [21216c6a] Preferences v1.5.2
  [10745b16] Statistics v1.11.1
  [0b7ba130] Blosc_jll v1.21.7+0
  [6e34b625] Bzip2_jll v1.0.9+0
  [0234f1f7] HDF5_jll v2.1.2+0
  [e33a78d0] Hwloc_jll v2.13.0+1
  [94ce4f54] Libiconv_jll v1.18.0+0
  [5ced341a] Lz4_jll v1.10.1+0
  [b5ada748] MPIABI_jll v0.1.5+0
  [7cb0a576] MPICH_jll v5.0.1+0
  [f1f71cc9] MPItrampoline_jll v5.5.6+0
  [9237b28f] MicrosoftMPI_jll v10.1.4+3
  [7243133f] NetCDF_jll v401.1000.0+0
  [fe0851c0] OpenMPI_jll v5.0.11+0
⌅ [02c8fc9c] XML2_jll v2.13.9+0
  [ffd25f8a] XZ_jll v5.8.3+0
  [a65dc6b1] Xorg_libpciaccess_jll v0.19.0+0
  [3161d3a3] Zstd_jll v1.5.7+1
⌅ [2b3700d1] aws_c_auth_jll v0.9.6+0
  [70f11efc] aws_c_cal_jll v0.9.13+0
  [73048d1d] aws_c_common_jll v0.12.6+0
  [73a04cd5] aws_c_compression_jll v0.3.2+0
  [3254fc65] aws_c_http_jll v0.10.13+0
  [13c41daa] aws_c_io_jll v0.26.3+0
⌅ [bd1f34fb] aws_c_s3_jll v0.11.5+0
  [1282aa60] aws_c_sdkutils_jll v0.2.4+1
  [b2a88e68] aws_checksums_jll v0.2.10+0
  [c4b69c83] dlfcn_win32_jll v1.4.2+0
  [477f73a3] libaec_jll v1.1.7+0
  [337d8026] libzip_jll v1.11.3+0
  [9aeb927a] mpif_jll v0.1.7+0
  [cddc5d3d] s2n_tls_jll v1.7.3+0
  [0dad84c5] ArgTools v1.1.2
  [56f22d72] Artifacts v1.11.0
  [2a0f44e3] Base64 v1.11.0
  [ade2ca70] Dates v1.11.0
  [f43a241f] Downloads v1.7.0
  [7b1f6079] FileWatching v1.11.0
  [ac6e5ff7] JuliaSyntaxHighlighting v1.12.0
  [4af54fe1] LazyArtifacts v1.11.0
  [b27032c2] LibCURL v0.6.4
  [76f85450] LibGit2 v1.11.0
  [8f399da3] Libdl v1.11.0
  [37e2e46d] LinearAlgebra v1.12.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [a63ad114] Mmap v1.11.0
  [ca575930] NetworkOptions v1.3.0
  [44cfe95a] Pkg v1.12.1
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [f489334b] StyledStrings v1.11.0
  [fa267f1f] TOML v1.0.3
  [a4e569a6] Tar v1.10.0
  [cf7118a7] UUIDs v1.11.0
  [4ec0a83e] Unicode v1.11.0
  [e66e0078] CompilerSupportLibraries_jll v1.3.0+1
  [deac9b47] LibCURL_jll v8.15.0+0
  [e37daf67] LibGit2_jll v1.9.0+0
  [29816b5a] LibSSH2_jll v1.11.3+1
  [14a3606d] MozillaCACerts_jll v2025.11.4
  [4536629a] OpenBLAS_jll v0.3.29+0
  [458c3c95] OpenSSL_jll v3.5.4+0
  [83775a58] Zlib_jll v1.3.1+2
  [8e850b90] libblastrampoline_jll v5.15.0+0
  [8e850ede] nghttp2_jll v1.64.0+1
  [3f19e933] p7zip_jll v17.7.0+0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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