Skip to content

Reporting fatal error during shutdown process (even from async goroutine) deadlocks #9824

@bogdandrutu

Description

@bogdandrutu

The problem is that during shutdown the otelcol no longer looks for updates on the asyncErrorChannel, and if any component will try to write to that channel will get into a deadlock.

func (r *receiver) Start(_ context.Context, _ component.Host) error {
	r.server := &http.Server{
		Addr:           ":8080",
		Handler:        myHandler,
	}
	go func() {
		if err := r.server.ListenAndServe(); err != nil {
			// This is a small bug since err == http.ErrServerClosed is expected.
			r.settings.ReportStatus(component.NewFatalErrorEvent(err))
		}
	}()
	return nil
}

func (r *receiver) Shutdown(context.Context) error {
	if r.server == nil {
		return nil
	}
	return r.server.Close()
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions