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

non-positive interval for NewTicker #1638

Closed
soouCc opened this issue Mar 11, 2020 · 16 comments
Closed

non-positive interval for NewTicker #1638

soouCc opened this issue Mar 11, 2020 · 16 comments
Labels
stale Issues and pull requests without any recent activity

Comments

@soouCc
Copy link

soouCc commented Mar 11, 2020

Versions

Please specify real version numbers or git SHAs, not just "Latest" since that changes fairly regularly.

Sarama Kafka Go
v1.26.1 Amazon MSK 2.2.0 1.13.5
-- -- --

| | | |
panic: non-positive interval for NewTicker

ticker := time.NewTicker(c.client.config.Consumer.Offsets.CommitInterval)

// Deprecated: CommitInterval exists for historical compatibility
// and should not be used. Please use Consumer.Offsets.AutoCommit
CommitInterval time.Duration

How can I set this CommitInterval?

@cj-arnas-navasinskas
Copy link

cj-arnas-navasinskas commented Apr 7, 2020

seems like a bug, got similar issue. I've worked around it by doing this:
clusterConfig.Consumer.Offsets.CommitInterval = time.Second

@daniel-cohen
Copy link

I have the same issue. Seems like a regression in 1.26.1
Setting Consumer.Offsets.CommitInterval to 1 seems to get it running again.

@pathbox
Copy link

pathbox commented Jun 16, 2020

Me too. I use "github.com/bsm/sarama-cluster" with kafka consumer group feature

@soouCc
Copy link
Author

soouCc commented Jun 16, 2020

Use this github.com/bsm/sarama-cluster v2.1.15+incompatible

@d1egoaz
Copy link
Contributor

d1egoaz commented Jun 16, 2020

@soouCc have you tried using the following with a recent Sarama release?

	config.Consumer.Offsets.AutoCommit.Interval = 1 * time.Second

@pathbox
Copy link

pathbox commented Jun 17, 2020

@d1egoaz

  config.Consumer.Offsets.AutoCommit.Interval = 1 * time.Second

Hello, I try it, but it doesn't work.

  clusterConfig.Consumer.Offsets.CommitInterval = time.Second

This works

@dink10
Copy link

dink10 commented Aug 10, 2020

clusterConfig.Consumer.Offsets.CommitInterval is deprecated

You need to use next one for fixing problem

cfg.Consumer.Offsets.AutoCommit.Enable = true
cfg.Consumer.Offsets.AutoCommit.Interval = time.Second

@dink10
Copy link

dink10 commented Aug 10, 2020

@d1egoaz

  config.Consumer.Offsets.AutoCommit.Interval = 1 * time.Second

Hello, I try it, but it doesn't work.

  clusterConfig.Consumer.Offsets.CommitInterval = time.Second

This works

It works if you turn on flag cfg.Consumer.Offsets.AutoCommit.Enable = true

vachyuta added a commit to CiscoM31/sarama-cluster that referenced this issue Aug 13, 2020
    Fix for the regression caused from latest sarama versions
    Ref: IBM/sarama#1638

Change-Id: I0c3d5e45736707d5a095382371696ee34f365c00
@ghost
Copy link

ghost commented Mar 16, 2021

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur.
Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

@ghost ghost added the stale Issues and pull requests without any recent activity label Mar 16, 2021
@shub124
Copy link

shub124 commented Aug 15, 2021

I have run into the following error.
panic: non-positive interval for NewTicker.
Pls suggest something which could fix the issue.

@ghost ghost removed the stale Issues and pull requests without any recent activity label Aug 15, 2021
@Jason5Lee
Copy link

Jason5Lee commented Aug 19, 2021

I met this issue.
The panic result shows that

panic: non-positive interval for NewTicker

goroutine 43 [running]:
time.NewTicker(0x0, 0x0)
        <GOPATH>/src/time/tick.go:24 +0x151
github.com/Shopify/sarama.(*consumerGroup).loopCheckPartitionNumbers(0xc000196480, 0xc000238400, 0x1, 0x4, 0xc0002b2400)
        <GOPATH>/pkg/mod/github.com/!shopify/sarama@v1.26.1/consumer_group.go:442 +0x66
created by github.com/Shopify/sarama.(*consumerGroup).Consume
        <GOPATH>/pkg/mod/github.com/!shopify/sarama@v1.26.1/consumer_group.go:176 +0x259

The 176 line of the consumer_group.go is

pause := time.NewTicker(c.config.Metadata.RefreshFrequency)

After troubleshooting I found that a package is constructing sarama client using the following code:

saramaConfig = sarama.NewConfig()
saramaConfig.Consumer.Return.Errors = true
saramaConfig.ChannelBufferSize = defaultBufferSize
saramaConfig.Net.MaxOpenRequests = defaultConnectionNum
saramaConfig.Metadata.RefreshFrequency = 0 // disable metadata fetching; it will be re-fetched on-demand
saramaConfig.Version = sarama.V1_1_1_0

And the documentation of RefreshFrequency states:

How frequently to refresh the cluster metadata in the background. Defaults to 10 minutes. Set to 0 to disable. Similar to topic.metadata.refresh.interval.ms in the JVM version.

But it seems it doesn't handle the 0 case correctly.

@Jason5Lee
Copy link

#1999

@leiuniy
Copy link

leiuniy commented Oct 29, 2021

I'm using this library github.com/bsm/sarama-cluster After version 19 is not compatible, you must use force onconfig.Consumer.Offsets.CommitInterval = time.Second
cfc7e64aa46b4339ba96730532d254a

@rahulkarmore
Copy link

clusterConfig

In which file we need to set config.Consumer.Offsets.CommitInterval=time.Second

@github-actions
Copy link

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur.
Please check if the main branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

@github-actions github-actions bot added the stale Issues and pull requests without any recent activity label Aug 24, 2023
@dnwe
Copy link
Collaborator

dnwe commented Aug 24, 2023

Fixed by #2329

@dnwe dnwe closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues and pull requests without any recent activity
Projects
None yet
Development

No branches or pull requests