mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* test(mount): reproduce the #5289 mount abort on a late metadata event A metadata event that arrives after metaCache.Shutdown() reaches glog.Fatalf through FatalOnError, so the mount dumps every goroutine and exits 255 instead of unmounting cleanly — the signature reported in issue #5289, still reachable on current master. The subscriber has no way to stop: its context is rooted at context.Background() and util.RetryUntil always retries, while unmount closes the cache underneath it. glog.Fatalf cannot be intercepted from another package (glog's logExitFunc is unexported), so the reproduction runs the mount in a child process and reads its exit code. * mount,pb: stop following metadata when the cache closes The mount follows metadata with FatalOnError, so an event that arrives after metaCache.Shutdown() — which unmount guarantees, since the subscriber is never stopped — was logged as a fatal and aborted the process with a goroutine dump. Report a closed cache as pb.ErrStopFollowing, a class the follow loop ends on instead of routing through the per-event error modes. It is not a failed event but the end of the subscription: no later event can land either. SubscribeMetaEvents then leaves its retry loop rather than reconnecting onto a store that no longer exists. Also export the meta_cache sentinel as ErrClosed so consumers can tell a closed cache from a storage failure. * mount: end the metadata follow before closing the meta cache The subscription goroutine had no owner: its context was rooted at context.Background() and util.RetryUntil retried forever, while unmount closed the cache underneath it. Every unmount left a window in which a filer event landed on a closed store, and the mount survived it only because the previous commit demoted that error. Give the follow a context the mount owns, and stop it — cancel, then join — before metaCache.Shutdown() in both teardown paths. MetadataFollowOption takes a ParentContext so cancelling the caller ends the stream, which is the ordering the filer already got in #11363 and #11663; the mount had no equivalent. Verified that the new assertion catches the ordering on its own: making stopMetadataFollow a no-op fails it with the subscriber still running, even with the fatal path already demoted. * mount,pb: make a cancelled follow a stop, and cover the new seams Review findings on the previous commits: Cancelling the follow context surfaced as a bare gRPC Canceled, which matched neither terminal condition, so every clean unmount logged an ERROR, ran the retry callback — which wipes every cached listing on the assumption that events were missed — and slept a second before the loop stopped itself. Test the context instead of the error text. Also assert the two new weed/pb seams where they are defined rather than only through a mount exit code: ErrStopFollowing ends the stream without reaching the per-event error modes and leaves the cursor behind the event, and a cancelled ParentContext ends the stream. Publishing the cancel handle and bumping the WaitGroup happen under one lock, so a start racing a stop cannot let the join report success too early. All four new tests were mutation-checked: dropping the early return, ignoring ParentContext, removing stopMetadataFollow from ClearCacheDir, and making stopMetadataFollow a no-op each fail their own test. --------- Co-authored-by: whitefox <whitefox@mayflower.work>