HDF5 error: unable to lock file,Resource temporarily unavailable - c++

I have an application which writes a new HDF file at every 100th iteration of a loop.
There is normal output at steps 0, 100, 200, 300, and 400, but at step 500 i get
HDF5-DIAG: Error detected in HDF5 (1.10.5) thread 0:
#000: H5F.c line 444 in H5Fcreate(): unable to create file
major: File accessibilty
minor: Unable to open file
#001: H5Fint.c line 1567 in H5F_open(): unable to lock the file
major: File accessibilty
minor: Unable to open file
#002: H5FD.c line 1640 in H5FD_lock(): driver lock request failed
major: Virtual File Layer
minor: Can't update object
#003: H5FDsec2.c line 959 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
major: File accessibilty
minor: Bad file ID accessed
The error happens in the call to H5Fcreate.
No matter how many outputs i make before step 500 (e.g. output at every step, or no output at all, or one output at step 499) - all outputs are correct, but at step 500 i get the above error message.
I checked: all HDF files that get created, are closed again immediately after writing.
(all HDF5 calls go through wrapper functions which write to a logfile the handles of the files being created, opened and closed)
Under what circumstances does this error message occur?
Is there a probability to find out what exactly the problem is?

Related

ApplicationError: Solver (gurobi) did not exit normally

I'm using gurobi academic license and i've followed every steps to activate the license but i get the following error whenever i call the gurobi solver on model which i wrote in pyomo :
ERROR: Solver (gurobi) returned non-zero return code (1)
ERROR: Solver log: Restricted license - for non-production use only - expires
2023-10-25 Read LP format model from file /tmp/tmp6ssbilg6.pyomo.lp
Reading time = 0.02 seconds x2773: 2775 rows, 2773 columns, 19387 nonzeros
Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (linux64) Thread count: 2
physical cores, 4 logical processors, using up to 4 threads Traceback
(most recent call last):
File "<stdin>", line 5, in <module> File
"/home/ali_p/anaconda3/envs/py37_64/lib/python3.7/site-
packages/pyomo/solvers/plugins/solvers/GUROBI_RUN.py", line 114, in
gurobi_run
model.optimize()
File "src/gurobipy/model.pxi", line 864, in gurobipy.Model.optimize
gurobipy.GurobiError: Model too large for size-limited license; visit
https://www.gurobi.com/free-trial for a full license
As indicated in the error message, the license key was not found. Make sure to read the section of the Quick Start Guide called Retrieving and Setting Up a Gurobi License (Linux, Windows, Mac).

HDF5 throws errors, unless I inline subroutine

I recently started exploring the HDF5 library for Fortran, and I came across some curious behaviour that I don't understand. The code below compiles just fine, but when I try to run the code, I get a very long list of errors originating from the subroutine HDF_init_ot. When I place this subroutine inside the caller subroutine HDF_init (as I did in HDF_init2), everything works perfectly fine. Why does this happen?
The code:
!===============================================================================
! This subroutine makes a call to an external subroutine HDF_init_ot,
! which throws an error
!===============================================================================
subroutine HDF_init()
use hdf5
character(len=11), parameter :: filename = "output.hdf5"
character(len=2), parameter :: group_ot = "ot"
integer(HID_T) :: file_handle, ot_handle
integer :: error
! Create a new HDF file
call h5open_f(error)
call h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_handle, error)
! Create a new group
call h5gcreate_f(file_handle, group_ot, ot_handle, error)
! Call to subroutine
call HDF_init_ot(ot_handle)
! Close group
call h5gclose_f(ot_handle, error)
! Close file
call h5fclose_f(file_handle, error)
call h5close_f(error)
end subroutine HDF_init
!===============================================================================
! The culprit subroutine
!===============================================================================
subroutine HDF_init_ot(ot_handle)
use hdf5
character(len=1), parameter :: dset_t = "t"
integer(HID_T) :: ot_handle, ot_space_handle
integer(HID_T) :: data_handle
integer(HSIZE_T), dimension(1) :: ot_dims, ot_max_dims
integer :: error, rank
! Define rank and dimensions
rank = 1
ot_dims = (/0/)
ot_max_dims = (/H5S_UNLIMITED_F/)
! Create a data space
call h5screate_simple_f(rank, ot_dims, ot_space_handle, error, ot_max_dims)
! Create a data set within the space
call h5dcreate_f( ot_handle, dset_t, H5T_NATIVE_DOUBLE, ot_space_handle, &
data_handle, error)
! Close the data set
call h5dclose_f(data_handle, error)
! Close the data space
call h5sclose_f(ot_space_handle, error)
end subroutine HDF_init_ot
!===============================================================================
! When I inline HDF_init_ot into the subroutine below, everything works
!===============================================================================
subroutine HDF_init2()
use hdf5
character(len=11), parameter :: filename = "output.hdf5"
character(len=2), parameter :: group_ot = "ot"
character(len=1), parameter :: dset_t = "t"
integer(HID_T) :: file_handle, ot_handle, ot_space_handle, data_handle
integer(HSIZE_T), dimension(1) :: ot_dims, ot_max_dims
integer :: error, rank
rank = 1
ot_dims = (/0/)
ot_max_dims = (/H5S_UNLIMITED_F/)
call h5open_f(error)
call h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_handle, error)
call h5gcreate_f(file_handle, group_ot, ot_handle, error)
call h5screate_simple_f(rank, ot_dims, ot_space_handle, error, ot_max_dims)
call h5dcreate_f( ot_handle, dset_t, H5T_NATIVE_DOUBLE, ot_space_handle, &
data_handle, error)
call h5dclose_f(data_handle, error)
call h5sclose_f(ot_space_handle, error)
call h5gclose_f(ot_handle, error)
call h5fclose_f(file_handle, error)
call h5close_f(error)
end subroutine HDF_init2
!===============================================================================
! Main program
!===============================================================================
program test
implicit none
! This one throws errors
call HDF_init()
! This one does not
call HDF_init2()
end program test
The error:
HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 140274482874112:
#000: ../../../src/H5D.c line 194 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#001: ../../../src/H5Dint.c line 453 in H5D__create_named(): unable to create and link to dataset
major: Dataset
minor: Unable to initialize object
#002: ../../../src/H5L.c line 1638 in H5L_link_object(): unable to create new link to object
major: Links
minor: Unable to initialize object
#003: ../../../src/H5L.c line 1882 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object
#004: ../../../src/H5Gtraverse.c line 861 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found
#005: ../../../src/H5Gtraverse.c line 641 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed
#006: ../../../src/H5L.c line 1685 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object
#007: ../../../src/H5O.c line 3016 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object
#008: ../../../src/H5Doh.c line 293 in H5O__dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#009: ../../../src/H5Dint.c line 1056 in H5D__create(): unable to construct layout information
major: Dataset
minor: Unable to initialize object
#010: ../../../src/H5Dcontig.c line 422 in H5D__contig_construct(): extendible contiguous non-external dataset
major: Dataset
minor: Feature is unsupported
HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 140274482874112:
#000: ../../../src/H5D.c line 415 in H5Dclose(): not a dataset
major: Invalid arguments to routine
minor: Inappropriate type
HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 140274482874112:
#000: ../../../src/H5D.c line 194 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#001: ../../../src/H5Dint.c line 453 in H5D__create_named(): unable to create and link to dataset
major: Dataset
minor: Unable to initialize object
#002: ../../../src/H5L.c line 1638 in H5L_link_object(): unable to create new link to object
major: Links
minor: Unable to initialize object
#003: ../../../src/H5L.c line 1882 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object
#004: ../../../src/H5Gtraverse.c line 861 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found
#005: ../../../src/H5Gtraverse.c line 641 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed
#006: ../../../src/H5L.c line 1685 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object
#007: ../../../src/H5O.c line 3016 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object
#008: ../../../src/H5Doh.c line 293 in H5O__dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object
#009: ../../../src/H5Dint.c line 1056 in H5D__create(): unable to construct layout information
major: Dataset
minor: Unable to initialize object
#010: ../../../src/H5Dcontig.c line 422 in H5D__contig_construct(): extendible contiguous non-external dataset
major: Dataset
minor: Feature is unsupported
HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 140274482874112:
#000: ../../../src/H5D.c line 415 in H5Dclose(): not a dataset
major: Invalid arguments to routine
minor: Inappropriate type
Edit:
I found that when I remove ot_max_dims from the h5screate_simple_f call, everything runs as expected. Curiously, if I define ot_max_dims within HDF_init and pass this as an extra parameter to HDF_init_ot, things also work. This suggests to me that H5S_UNLIMITED_F is a parameter that is private to HDF_init(), possibly tied to the API instance (i.e. to h5open_f)?

What is the root cause of PyArrow HDFS IO error?

I'm running a Dask-YARN job that dumps a results dictionary into HDFS (code shown in traceback below) using PyArrow's HDFS IO library. However, the job intermittently runs into the error shown below, not every run, only sometimes. I'm unable to determine the root cause of this issue, anyone have any ideas?
File "/extractor.py", line 87, in __call__
json.dump(results_dict, fp=_UTF8Encoder(f), indent=4)
File "pyarrow/io.pxi", line 72, in pyarrow.lib.NativeFile.__exit__
File "pyarrow/io.pxi", line 130, in pyarrow.lib.NativeFile.close
File "pyarrow/error.pxi", line 87, in pyarrow.lib.check_status
pyarrow.lib.ArrowIOError: HDFS CloseFile failed, errno: 255 (Unknown error 255) Please check that you are connecting to the correct HDFS RPC port
Turns out this was being cause by duplication of computation of "dask.get" tasks on Delayed objects, which was leading to multiple processes attempting to write to the same file.

IO exception while copying 38GB of file from Local to HDFS

I am trying to load 38GB of file from local server to HDFS, I am getting below error while file transfer
hadoop fs -copyFromLocal filename.csv /
Exception in thread "main" org.apache.hadoop.fs.FSError: java.io.IOException: Input/output error
at org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileInputStream.read(RawLocalFileSystem.java:161)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at java.io.DataInputStream.read(DataInputStream.java:149)
at org.apache.hadoop.fs.FSInputChecker.readFully(FSInputChecker.java:436)
at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSInputChecker.readChunk(ChecksumFileSystem.java:252)
at org.apache.hadoop.fs.FSInputChecker.readChecksumChunk(FSInputChecker.java:276)
at org.apache.hadoop.fs.FSInputChecker.read1(FSInputChecker.java:228)
at org.apache.hadoop.fs.FSInputChecker.read(FSInputChecker.java:196)
at java.io.DataInputStream.read(DataInputStream.java:100)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:84)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:52)
at org.apache.hadoop.io.IOUtils.copyBytes(IOUtils.java:112)
at org.apache.hadoop.fs.shell.CommandWithDestination$TargetFileSystem.writeStreamToFile(CommandWithDestination.java:456)
at org.apache.hadoop.fs.shell.CommandWithDestination.copyStreamToTarget(CommandWithDestination.java:382)
at org.apache.hadoop.fs.shell.CommandWithDestination.copyFileToTarget(CommandWithDestination.java:319)
at org.apache.hadoop.fs.shell.CommandWithDestination.processPath(CommandWithDestination.java:254)
at org.apache.hadoop.fs.shell.CommandWithDestination.processPath(CommandWithDestination.java:239)
at org.apache.hadoop.fs.shell.Command.processPaths(Command.java:306)
at org.apache.hadoop.fs.shell.Command.processPathArgument(Command.java:278)
at org.apache.hadoop.fs.shell.CommandWithDestination.processPathArgument(CommandWithDestination.java:234)
at org.apache.hadoop.fs.shell.Command.processArgument(Command.java:260)
at org.apache.hadoop.fs.shell.Command.processArguments(Command.java:244)
at org.apache.hadoop.fs.shell.CommandWithDestination.processArguments(CommandWithDestination.java:211)
at org.apache.hadoop.fs.shell.CopyCommands$Put.processArguments(CopyCommands.java:263)
at org.apache.hadoop.fs.shell.Command.processRawArguments(Command.java:190)
at org.apache.hadoop.fs.shell.Command.run(Command.java:154)
at org.apache.hadoop.fs.FsShell.run(FsShell.java:287)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at org.apache.hadoop.fs.FsShell.main(FsShell.java:340)
Caused by: java.io.IOException: Input/output error
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:272)
at org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileInputStream.read(RawLocalFileSystem.java:154)
... 31 more
after issuing copyfromlocal command I am getting above exception.
Kindly help.
Issue got resolved, its a disk issue,

Can't write HDF5 file with vector bigger than 2^13

I'm using C++ & HDF5 to write a file. But run into problems with it. This is the code I use:
void fileRead::writeFile(string name, const vector<double>* data) {
int dimn = data->size();
hsize_t dim[1] = {data->size()}; //-> 2^13!!!
hid_t sid = H5Pcreate(H5P_DATASET_CREATE);
hid_t didProp = H5Screate_simple(1,dim,NULL);
H5Pset_layout(sid, H5D_COMPACT);
hid_t did = H5Dcreate(fid, name.c_str(),H5T_IEEE_F64LE, didProp, H5P_DEFAULT, sid,H5P_DEFAULT);
H5Dwrite (did, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &(data->at(0)));
H5Dclose(did);
H5Sclose(didProp);
H5Pclose(sid);
}
But this gives me this error message:
HDF5-DIAG: Error detected in HDF5 (1.8.10) thread 0: #000: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5D.c line 170 in H5Dcreate2(): unable to create dataset
major: Dataset
minor: Unable to initialize object #001: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Dint.c line 439 in H5D__create_named(): unable to create and link to dataset
major: Dataset
minor: Unable to initialize object #002: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5L.c line 1638 in H5L_link_object(): unable to create new link to object
major: Links
minor: Unable to initialize object #003: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5L.c line 1882 in H5L_create_real(): can't insert link
major: Symbol table
minor: Unable to insert object #004: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Gtraverse.c line 861 in H5G_traverse(): internal path traversal failed
major: Symbol table
minor: Object not found #005: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Gtraverse.c line 641 in H5G_traverse_real(): traversal operator failed
major: Symbol table
minor: Callback failed #006: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5L.c line 1685 in H5L_link_cb(): unable to create object
major: Object header
minor: Unable to initialize object #007: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5O.c line 3015 in H5O_obj_create(): unable to open object
major: Object header
minor: Can't open object #008: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Doh.c line 293 in H5O__dset_create(): unable to create dataset
major: Dataset
minor: Unable to initialize object #009: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Dint.c line 1044 in H5D__create(): unable to construct layout information
major: Dataset
minor: Unable to initialize object #010: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5Dcompact.c line 212 in H5D__compact_construct(): compact dataset size is bigger than header message maximum size
major: Dataset
minor: Unable to initialize object HDF5-DIAG: Error detected in HDF5 (1.8.10) thread 0: #000: /pub/devel/hdf5/hdf5-1.8.10-1/src/hdf5-1.8.10/src/H5D.c line 391 in H5Dclose(): not a dataset
major: Invalid arguments to routine
minor: Inappropriate type
This happens for all vector sizes >= 2^13 (8192). Which is puzzeling me since reading in is no problem with bigger files and 2^13 is still a rather small number so something must be fishi with my code.
Any help would be appreatiated.
yours
magu_
From the documentation for the H5D_COMPACT parameter for H5Pset_layout:
Store raw data in the dataset object header in file. This should only
be used for datasets with small amounts of raw data. The raw data size
limit is 64K (65520 bytes). Attempting to create a dataset with raw
data larger than this limit will cause the H5Dcreate call to fail.
So if your doubles are 8 bytes, you've run into that limit.
You need to use one of the other storage options, contiguous or chunked.