Clarification needed for comment in storage/file/fd.c
Hi,
I came across this comment in storage/file/fd.c while I was trying to write an FDW.
" AllocateFile, AllocateDir, OpenPipeStream and OpenTransientFile arewrappers around fopen(3), opendir(3), popen(3) and open(2), respectively.They behave like the corresponding native functions, except that the handleis registered with the current subtransaction, and will be automaticallyclosed at abort. These are intended mainly for short operations likereading a configuration file; there is a limit on the number of files thatcan be opened using these functions at any one time. "
It states that it behaves as native functions with the handle registered to the current subtransaction.
If it is so, why is it intended for short operations?
Will it work if I open a file at the start of the transaction and close it at the end of the transaction?
What are the side effects/limitations of these functions?
Regards,
Samuel CC
Import Notes
Reference msg id not found: 440033612.1090913.1521112951096.ref@mail.yahoo.com
On Thu, Mar 15, 2018 at 11:22:31AM +0000, samuel cherukutty wrote:
It states that it behaves as native functions with the handle
registered to the current subtransaction.
If it is so, why is it intended for short operations?
Will it work if I open a file at the start of the transaction and
close it at the end of the transaction?
What are the side effects/limitations of these functions?
The maximum number of file descriptors can be tuned using
max_files_per_process, however the more concurrent operations you do,
the higher the risk to run out of them. Hence limiting them for
short-time operations it preferred to keep things stable. You actually
never need to hold them that long anyway, and you may want to rethink
what you are doing as well.
--
Michael