Skip to content

Conversation

@eisenhauer
Copy link
Member

@eisenhauer eisenhauer commented Feb 7, 2026

When the writer's active flag is false, all metadata is in its final state. Close each metadata file descriptor individually once all of its data has been read into memory:

  • mmd.0: always read in full, closed immediately
  • md.idx: closed when ParseMetadataIndex has consumed all entries (respects the 16 MB streaming-mode limit across multiple calls)
  • md.0: closed once all index entries are parsed, since every metadata section they reference has already been read

This reduces file descriptor pressure on remote servers (e.g. XRootD) when many datasets are opened concurrently via campaign files.

Also adds an fstat retry loop for md.idx to handle filesystem metadata lag: after a writer closes a file, fstat() may briefly report a stale size. The loop polls until the reported size stabilizes.

Finally, it adds a test, counting open FDs to make sure that the metadata FDs are actually closed. This test only functions on non-windows platforms.

When the writer's active flag is false, all metadata is in its final
state. Close each metadata file descriptor individually once all of
its data has been read into memory:

- mmd.0: always read in full, closed immediately
- md.idx: closed when ParseMetadataIndex has consumed all entries
  (respects the 16 MB streaming-mode limit across multiple calls)
- md.0: closed once all index entries are parsed, since every
  metadata section they reference has already been read

This reduces file descriptor pressure on remote servers (e.g. XRootD)
when many datasets are opened concurrently via campaign files.

Also adds an fstat retry loop for md.idx to handle filesystem metadata
lag: after a writer closes a file, fstat() may briefly report a stale
size. The loop polls until the reported size stabilizes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines 1447 to +1448
m_MetadataIndex.Reset(true, false);
if (m_Comm.Rank() == 0)
m_MetadataIndex.m_Buffer.resize(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a reset of the metadata index without resizing the buffer to 0? In no, I would put the resize inside the reset function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the time we call Reset and want the buffer to survive. Here, the next bit of code needs to see the buffer as size zero, so we can't really move it inside (without adding something like a parameter to say we wanted the buffer to go away or something).

@eisenhauer eisenhauer merged commit 1f19100 into ornladios:master Feb 8, 2026
68 of 69 checks passed
@eisenhauer eisenhauer deleted the close-metadata-fds branch February 8, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants