Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] I hope the Scheduler can allow me to manually close connections when using shared connections, just like Server does. #993

Open
PterX opened this issue Dec 21, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@PterX
Copy link

PterX commented Dec 21, 2024

Is your feature request related to a problem? Please describe.
[A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]](asynq: pid=40565 2024/12/21 13:38:01.521847 ERROR: Failed to close redis client connection: redis connection is shared so the Client can't be closed through asynq)

Describe the solution you'd like

func (srv *Server) Shutdown() {
	srv.state.mu.Lock()
	if srv.state.value == srvStateNew || srv.state.value == srvStateClosed {
		srv.state.mu.Unlock()
		// server is not running, do nothing and return.
		return
	}
	...
	srv.wg.Wait()

	if !srv.sharedConnection {
		srv.broker.Close()
	}
func (s *Scheduler) Shutdown() {
	s.state.mu.Lock()
	....
	s.wg.Wait()

	s.clearHistory()
        // if sharedConnection did not close it
	if err := s.client.Close(); err != nil {
		s.logger.Errorf("Failed to close redis client connection: %v", err)
	}
	s.logger.Info("Scheduler stopped")
}

It can close redis connect after that

Describe alternatives you've considered

Additional context

@PterX PterX added the enhancement New feature or request label Dec 21, 2024
@kamikazechaser
Copy link
Collaborator

kamikazechaser commented Dec 23, 2024

I'm always frustrated when...redis connection is shared so the Client can't be closed through asynq

I assume you are talking about the bug affecting the Scheduler (See #975)? Try v0.25.1 if so.

@PterX
Copy link
Author

PterX commented Dec 24, 2024

I'm always frustrated when...redis connection is shared so the Client can't be closed through asynq

I assume you are talking about the bug affecting the Scheduler (See #975)? Try v0.25.1 if so.

I think is not the same, I was use NewSchedulerFromRedisClient create Scheduler, it is also shareconnection. But i want shutdown Scheduler before close share connection, It will post the error msg.

@PterX
Copy link
Author

PterX commented Dec 25, 2024

PterX@f8e1320

@kamikazechaser maybe fix like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants