Skip to content

Bug: Crash when existing corrupted DB file exists during CREATE #24

@keisuke-yanagisawa

Description

@keisuke-yanagisawa

During database creation (create subcommand), when an HDF5 file with the same name already exists, a WARNING log indicates that the file will be overwritten. However, the file appears to be opened in append mode instead. As a result, if the existing HDF5 file is corrupted for any reason, the process terminates abnormally with a file open error.

create サブコマンドを実行するときに、出力先のファイルが既に存在する場合には「上書きする」というWARNINGが表示される。しかし、実際には 追記 が行われるとのこと。その結果として、何らかの理由で HDF5 ファイルが壊れて再度実行しようとすると、ファイルを開く際に ERROR が発生する。

2026-01-17 01:48:05 - INFO     - fbdb - FBDB CLI started - Command: CREATE
2026-01-17 01:48:05 - INFO     - fbdb - [CREATE] Starting database creation ...
2026-01-17 01:48:05 - WARNING  - fbdb - Storage file already exists and will be overwritten: R200/CREATE/2025.02_Enamine_REAL_DB_10.4M_chunk_003-omega.sdf.gz.h5
2026-01-17 01:48:05 - ERROR    - fbdb - Unexpected error occurred:
Traceback (most recent call last):
  File "/frasco-vs/frasco/fbdb/FBDBv2/cli.py", line 53, in main
    args.func(args)
  File "/frasco-vs/frasco/fbdb/FBDBv2/cli_commands/create.py", line 16, in run_create
    storage = HDF5Storage(args.storage_path, mode="a")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/frasco-vs/frasco/fbdb/FBDBv2/storage/hdf5_storage.py", line 17, in __init__
    self._h5file = h5py.File(str(file_path), mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Miniforge3/lib/python3.12/site-packages/h5py/_hl/files.py", line 566, in __init__
    fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Miniforge3/lib/python3.12/site-packages/h5py/_hl/files.py", line 253, in make_fid
    fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5f.pyx", line 104, in h5py.h5f.open
OSError: Unable to synchronously open file (truncated file: eof = 96, sblock->base_addr = 0, stored_eof = 2048)
2026-01-17 01:48:05 - ERROR    - fbdb - -----------------------------------
2026-01-17 01:48:05 - ERROR    - fbdb - Total time until failure: 0.0167[s] (00:00:00)
2026-01-17 01:48:05 - ERROR    - fbdb - FBDB CLI terminated with errors - Command: CREATE
2026-01-17 01:48:05 - ERROR    - fbdb - -----------------------------------
Exception ignored in: <function Storage.__del__ at 0x1500c72d5da0>
Traceback (most recent call last):
  File "/frasco-vs/frasco/fbdb/FBDBv2/storage/base.py", line 17, in __del__
    self.close()
  File "/frasco-vs/frasco/fbdb/FBDBv2/storage/hdf5_storage.py", line 76, in close
    self._h5file.close()
    ^^^^^^^^^^^^
AttributeError: 'HDF5Storage' object has no attribute '_h5file'
time: 9.35 sec, usr: 1.77 sec, sys: 0.92 sec, memory: 162816 KB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions