Skip to content

[Bug]: LocalETLFS writer cleanup test misses closed-directory sync failure #29427

Closed

Description

@slyunnn

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 -v

All 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:

  1. Creates LocalETLFS on a temporary root and obtains NewWriter("target").
  2. Writes one byte to the temporary writer.
  3. Opens the root directory, closes that descriptor, closes any existing cached descriptor, and stores the closed descriptor in dirFiles[parent].
  4. 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 after Rename; the final file may remain published because ownership has transferred.
  • If that injection cannot represent a real syncDir failure, 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

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 LocalFS and LocalETLFS independently 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

  1. added
    kind/bug
    on Sep 28, 2026
  2. added theissue type on Sep 28, 2026
  3. added this to the MO-202609 milestone on Sep 28, 2026
  4. changed the title [-][Bug]: Local ETL writer close hides cached directory sync failure[/-] [+][Bug]: LocalETLFS writer cleanup test misses closed-directory sync failure[/+] on Sep 28, 2026
  5. XuPeng-SH commented on Nov 5, 2026

    @XuPeng-SH
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions