Repository navigation
Description
Summary
TestLocalWriterCloseCleanup/etl/sync_dir is a deterministic current-main failure on macOS. The test installs a deliberately closed parent-directory handle in LocalETLFS.dirFiles, then calls w.Close(). It expects the final parent-directory Sync to fail, but w.Close() returns nil.
This prevents the full pkg/fileservice suite from passing and leaves the durability-error test contract ambiguous: either the cached closed handle is not selected by syncDir, or the test is relying on an invalid injection assumption. The current evidence does not establish that ordinary production directory-sync failures are silently ignored.
Discovered during regression verification for #29267; it is unrelated to AWS/COS multipart cancellation.
Environment
- Branch:
main - Commit:
9b7c2c23dba737232d975d66bd04628199e1a436(fix(tae): reconcile replay promotion merge state before write (#29421)) - OS/architecture: macOS /
arm64 - Go:
1.26.5 - The suite was run with MatrixOne's repository CGo test environment and matching native dependencies.
Minimal reproduction
go test ./pkg/fileservice -run '^TestLocalWriterCloseCleanup/etl/sync_dir$' -count=3 -vAll three focused executions fail at pkg/fileservice/local_writer_cleanup_test.go:92:
Error: An error is expected but got nil.
Test: TestLocalWriterCloseCleanup/etl/sync_dir
The surrounding package run also fails at this same subtest.
Trigger sequence
TestLocalWriterCloseCleanup currently does the following:
- Creates
LocalETLFSon a temporary root and obtainsNewWriter("target"). - Writes one byte to the temporary writer.
- Opens the root directory, closes that descriptor, closes any existing cached descriptor, and stores the closed descriptor in
dirFiles[parent]. - Calls
w.Close().
The write is already published by Rename before the final syncDir(parent) call. The test verifies both that the descriptor is closed and that no .tmp.* files remain; for this scenario it also reads the final target back successfully.
Expected behavior
One of these contracts must hold deterministically:
- If
syncDir(parent)uses the injected closed descriptor,w.Close()returns that error afterRename; the final file may remain published because ownership has transferred. - If that injection cannot represent a real
syncDirfailure, the test must use a deterministic failure seam or must not assert an error.
In either case, the test must not make pkg/fileservice fail spuriously on a supported development platform.
Actual behavior
w.Close() returns nil in every focused run. A standalone macOS check confirms that (*os.File).Sync() on a directory handle after Close() returns file already closed, so the unexpected result occurs in the FileService test/path selection rather than in the basic OS operation.
Initial code analysis
LocalETLFS.NewWriter calls l.syncDir(parentDir) after a successful os.Rename and returns its error directly. syncDir obtains a handle from l.dirFiles[nativePath] when present and calls f.Sync().
Therefore the first investigation should verify that the test and production path compute exactly the same cache key/path and that the replacement handle is the one selected by syncDir. Do not assume error swallowing without that evidence.
The corresponding LocalFS.NewWriter uses the same final syncDir structure, so any correction should consider whether the test needs a shared deterministic injection method for both implementations.
Scope and related work
- The test was introduced by
9841d29e2f(fix: clean failed fulltext spill and ETL temp files (#29358)). - This is related to, but not a duplicate of, [Bug]: LocalETLFS.write leaves .tmp files behind when Close or Rename fails #29264. [Bug]: LocalETLFS.write leaves .tmp files behind when Close or Rename fails #29264 covered failed
Close/Renamepaths leaving.tmp.*files; it explicitly treated asyncDirfailure after a successfulRenameas a distinct condition because the final object is already published. - This report concerns the post-rename directory-sync error propagation/test-injection contract only. It does not change the
Fixedconclusion for [Bug]: canceled parallel multipart upload can return success and skip abort #29267.
Suggested resolution and regression coverage
- Establish a deterministic seam for the final directory sync, or correct the cache-key setup so the intended closed descriptor is actually used.
- Cover
LocalFSandLocalETLFSindependently for: successful close; close/ensure-dir/rename failure cleanup; and post-rename directory-sync failure with a published final object and no temporary-file leak. - Run the focused case on macOS and Linux before treating the full package suite as green.
Activity
[-][Bug]: Local ETL writer close hides cached directory sync failure[/-][+][Bug]: LocalETLFS writer cleanup test misses closed-directory sync failure[/+]test(ci): isolate shared fixtures and align observation barriers (#31938
XuPeng-SH commentedon Nov 5, 2026
Closing after checking current main (5792e1c): the test now derives the injected directory-cache key from the actual writer path via filepath.Split(f.Name()), covering the macOS symlinked temporary-root mismatch. This was merged in #30212 (18d5335). The follow-up #30137 reports a passing macOS/arm64 full fileservice suite and focused race test against the equivalent main implementation. I verified the merged ancestry and current source; I did not run a fresh macOS test in this environment.