Skip to content

timer.go.I'm wondering if it's an nats issue. #880

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

Closed
sgof1d opened this issue Jan 9, 2022 · 6 comments
Closed

timer.go.I'm wondering if it's an nats issue. #880

sgof1d opened this issue Jan 9, 2022 · 6 comments
Assignees

Comments

@sgof1d
Copy link

sgof1d commented Jan 9, 2022

go 1.17.5, 1.17.6 . nats.go
github.com/nats-io/nats.go v1.13.1-0.20211018182449-f2416a8b1483

some time the time.Timer returned by globalTimerPool.Get(a Duration) was fired already
so request() will fail with "nats timeout" in 10us or less.

the issue disappears if I disable pool.

@kozlovic
Copy link
Member

@sgof1d Would you have a test case that reproduce this? The pool implementation does the right thing, I believe, in that when putting it back to the pool it stops the timer and if it can't (meaning it had fired), then it consumes from the channel:

func (tp *timerPool) Put(t *time.Timer) {
	if !t.Stop() {
		select {
		case <-t.C:
		default:
		}
	}

	tp.p.Put(t)
}

@sgof1d
Copy link
Author

sgof1d commented Jan 12, 2022

yes, It seems that pool does thing right.
reproduce rate is about 10%. if I enable pool.
reproduce rae is 0%, if I disable pool.
the test case is :
clients send websocket packet to api gateway
gateway call nats.request() in go routines.
backend server will response to these requests.

the issue happens in gateway.

I had tested that:
if affirm timer.C is REALLY empty before Get() return, the issue disappear.

so I'm wondering something is wrong in timer.Stop(), the go standard lib.

@kozlovic
Copy link
Member

I think I have seen some issue reports around that. Will try to reproduce with using simple timer/pool but outside of NATS and see... out of curiosity, which platform are you running on?

@moredure
Copy link
Contributor

moredure commented Jan 14, 2022

Probably related to golang/go#47859?

@sgof1d
Copy link
Author

sgof1d commented Jan 22, 2022

I think I have seen some issue reports around that. Will try to reproduce with using simple timer/pool but outside of NATS and see... out of curiosity, which platform are you running on?

alpine running in container.
macosx 12.1

@wallyqs
Copy link
Member

wallyqs commented Jan 17, 2023

Closing since looks like regression from Go that has been fixed since Go 1.16.

@wallyqs wallyqs closed this as completed Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants