Skip to content

Disable go-metrics for Kafka to prevent memory leak#51

Merged
oskarszoon merged 2 commits into
bsv-blockchain:mainfrom
oskarszoon:bugfix/sarama-memory-leak
Oct 24, 2025
Merged

Disable go-metrics for Kafka to prevent memory leak#51
oskarszoon merged 2 commits into
bsv-blockchain:mainfrom
oskarszoon:bugfix/sarama-memory-leak

Conversation

@oskarszoon

@oskarszoon oskarszoon commented Oct 24, 2025

Copy link
Copy Markdown
Contributor
image

@ordishs ordishs self-requested a review October 24, 2025 10:23
@github-actions

github-actions Bot commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Status: Complete

Current Review:
No issues found. The PR correctly disables go-metrics across all Kafka client configurations:

  • Consumer group (kafka_consumer.go:421)
  • Health checker (kafka_health.go:57)
  • Sync producer - NewKafkaProducer (kafka_producer.go:124)
  • Sync producer - ConnectProducer (kafka_producer.go:208)
  • Async producer (kafka_producer_async.go:196)

The fix prevents the known Sarama memory leak from exponential decay sample heap growth. Test files use sarama.NewConfig() but don't need this fix as they create short-lived test instances.

History:

  • ✅ Fixed: Added config.MetricRegistry = nil to both sync producer functions (previously only async producer had the fix)

Comment thread util/kafka/kafka_producer_async.go
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@oskarszoon oskarszoon merged commit 8b5d7e8 into bsv-blockchain:main Oct 24, 2025
8 checks passed
torrejonv pushed a commit to torrejonv/teranode that referenced this pull request Oct 26, 2025
ordishs added a commit to ordishs/teranode that referenced this pull request Jan 12, 2026
Document that /api/v1/blocks/:hash?n=3 returns all blocks but concatenated:
- Binary format has no delimiters between blocks
- All requested blocks are present in the response
- Clients must parse blocks sequentially using block format spec
- Browser downloads may appear to show only first block
- Recommend using /json endpoint for easier inspection
- Add detailed parsing steps for binary format

Addresses issue bsv-blockchain#51 from teranode-review
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

Successfully merging this pull request may close these issues.

2 participants