llnl / llnl/UnifyFS

PnetCDF unlink race condition in nc_test

Open
#744 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pnetcdf
Dominant language
C
Stars
122
Forks
34
PR merge metrics
No merged PRs in 30d

Description

In PnetCDF, the nc_test has a number of quick running tests that each create a scratch file, execute I/O operations on that file, and then delete the scratch file. The consecutive sequence of tests shown here complete quickly and all use the same filename for the scratch file.

https://github.com/Parallel-NetCDF/PnetCDF/blob/6c71a30cd95f575c01025c0c926fc06dc9157774/test/nc_test/nc_test.c#L414-L420

The MPI_File_open() call of one of these tests fails when it attempts to sync extents with the server during an internal call to close(). ROMIO's MPI_File_open() calls both open() and close() on the file. The close() then tries to sync extents with the server because the file had been opened for writing.

https://github.com/Parallel-NetCDF/PnetCDF/blob/6c71a30cd95f575c01025c0c926fc06dc9157774/test/nc_test/test_write.m4#L394

The extent sync fails because the file has been deleted so that meta->fid (-1) != fid (2) at this check:

https://github.com/LLNL/UnifyFS/blob/a13edaf779c755b3314f1bd7ce7f798d532d9951/client/src/unifyfs_fid.c#L1086-L1096

This situation happens because the prior test deleted the scratch file via MPI_File_delete() -> unlink().

https://github.com/Parallel-NetCDF/PnetCDF/blob/6c71a30cd95f575c01025c0c926fc06dc9157774/test/nc_test/test_write.m4#L437

That unlink() invokes an unlink rpc from client-to-server, which induces a later server-to-client unlink callback rpc that comes back to the client from the server at some future point in time. In this case, the unlink callback fires in the middle of MPI_File_open's open() and close() calls. The open() successfully recreates the file, then it is deleted due to the unlink callback, and then the close() fails to sync extents, which causes MPI_File_open to return an error:

https://github.com/LLNL/UnifyFS/blob/a13edaf779c755b3314f1bd7ce7f798d532d9951/client/src/unifyfs-sysio.c#L2322-L2330

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading test/nc_test/nc_test.c around lines 414-420 and test/nc_test/test_write.m4 around lines 394 and 437, then inspect client/src/unifyfs_fid.c and client/src/unifyfs-sysio.c at the linked checks. Reproduce the consecutive scratch-file tests and trace the unlink callback during MPI_File_open. Done means the described nc_test sequence no longer fails during extent synchronization and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
distributed-systems, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.