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

when i use demo of consumergroup got panic err #2398

Closed
pengtianyue025 opened this issue Dec 5, 2022 · 4 comments
Closed

when i use demo of consumergroup got panic err #2398

pengtianyue025 opened this issue Dec 5, 2022 · 4 comments
Labels
stale Issues and pull requests without any recent activity

Comments

@pengtianyue025
Copy link

pengtianyue025 commented Dec 5, 2022

Versions

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

Sarama Kafka Go
1.33 2.12-2.3.1 go16
Configuration

What configuration values are you using for Sarama and Kafka?

func (consumer *Consumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
	// NOTE:
	// Do not move the code below to a goroutine.
	// The `ConsumeClaim` itself is called within a goroutine, see:
	// https://github.com/Shopify/sarama/blob/main/consumer_group.go#L27-L29
	for {
		select {
		case message := <-claim.Messages():
			log.Printf("Message claimed: value = %s, timestamp = %v, topic = %s", string(message.Value), message.Timestamp, message.Topic)
			session.MarkMessage(message, "")

		// Should return when `session.Context()` is done.
		// If not, will raise `ErrRebalanceInProgress` or `read tcp <ip>:<port>: i/o timeout` when kafka rebalance. see:
		// https://github.com/Shopify/sarama/issues/1192
		case <-session.Context().Done():
			return nil
		}
	}
}
Logs
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x1016b77]

goroutine 307 [running]:
base.(*Consumer).ConsumeClaim(0xc0000c7290, 0x1714c28, 0xc000129500, 0x170cf78, 0xc002d8b7a0, 0xc, 0x1)
kafka.go:95 +0x1b7 # panic at log.Printf(same with demo)
Problem Description

this code may got nil with message? and then print cause panic

case message := <-claim.Messages():
@buddy-yao
Copy link

Same problem, any solutions?

@pengtianyue025
Copy link
Author

When i got a nil message, i just continue( maybe the consumer is close, just return is ok?).

@github-actions

This comment was marked as outdated.

@github-actions github-actions bot added the stale Issues and pull requests without any recent activity label Jul 18, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 17, 2023
@dnwe
Copy link
Collaborator

dnwe commented Aug 17, 2023

Sorry for the delay, this was fixed by #2479

@dnwe dnwe closed this as completed Aug 17, 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

3 participants