Comments (6)
Do you mind giving a bit more info about the version of Kafka you're running? Also if you have some code to reproduce the issue in isolation that would be a good start for me to dig into the issue.
from kafka-go.
We're running kafka 2.11-1. The code I was testing with is as follows. Note that the data is snappy encoded. We originally inserted the data into kafka using kafkacat.
kafkacat -P -b kafka-1 -t server-invalid -z snappy
package main
import (
"bytes"
"context"
"encoding/binary"
"fmt"
"github.com/golang/snappy"
kafka "github.com/kafka-go"
)
var xerialHeader = []byte{130, 83, 78, 65, 80, 80, 89, 0}
// Decode decodes snappy data whether it is traditional unframed
// or includes the xerial framing format.
func Decode(src []byte) ([]byte, error) {
if !bytes.Equal(src[:8], xerialHeader) {
return snappy.Decode(nil, src)
}
var (
pos = uint32(16)
max = uint32(len(src))
dst = make([]byte, 0, len(src))
chunk []byte
err error
)
for pos < max {
size := binary.BigEndian.Uint32(src[pos : pos+4])
pos += 4
chunk, err = snappy.Decode(chunk, src[pos:pos+size])
if err != nil {
return nil, err
}
pos += size
dst = append(dst, chunk...)
}
return dst, nil
}
func main() {
r := kafka.NewReader(kafka.ReaderConfig{
Brokers: []string{"kafka-1:9092"},
Topic: "server-invalid",
Partition: 0,
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
})
r.SetOffset(46356099)
for {
m, err := r.ReadMessage(context.Background())
if err != nil {
fmt.Println(err)
break
}
data, err := Decode(m.Value)
if err != nil {
fmt.Println(err)
break
}
for i, c := range data {
fmt.Printf("%x ", c)
}
fmt.Printf("\n")
fmt.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(data))
break
}
r.Close()
}
from kafka-go.
Hey @newhook , are you still experiencing this issue ?
2.11-1 is probably the version of Scala used by Kafka but not the version of Kafka itself. The version of Kafka will be something like : 0.10.2.2
, 0.11.0.1
, 1.1.0
etc etc.
Note that kafka-go
will handle compression once #106 is merged.
from kafka-go.
Hey @Pryz, I work with @newhook and took another look at this issue this morning to see if we can still reproduce.
We're currently running kafka 1.0.1 w/ Scala 2.11
I ran the same code from before using the latest version of the kafka-go to reproduce the issue with leading characters:
joe@WASP-12b ~/src/github.com/segmentio/kafka-go $ git rev-parse --verify HEAD
48c37f796910d8154479aaa04ade5843ae4f55d0
joe@WASP-12b ~/src/github.com/segmentio/kafka-go $ git rev-parse --verify origin/master
48c37f796910d8154479aaa04ade5843ae4f55d0
joe@WASP-12b ~/src/github.com/customerio/x/kafka-test $ ./kafka-test > "output.log"
And the output still includes leading characters:
0 0 0 0 33 9c 1a 93 0 2 a8 3f 27 cf 51 a7 0 0 ff ff ff ff 0 2 a8 31
...
message at offset 865868659: = 3���?'�Q������1{"level":"info",
The code I ran with ./kafka-test
is the same as what was provided before on this issue.
I'll be taking a closer look to see if there's anything unusual with how we're encoding the kafka messages originally and inserting with kafkacat, however right now we're still able to reproduce the issue when using kafka-go.
from kafka-go.
Hey @joepurdy, I'm hitting the same issue.
The problem is that Kafka uses the idea of MessageSet
to be able to compress and uncompress payload more efficiently. A set is basically a message which wraps other messages so that Kafka can compress an entire batch of messages.
Note that RecordBatch
is replacing MessageSet
since Kafka 0.11 but the idea is the same.
We haven't implemented any of those in kafka-go yet and this is why you are having those leading characters (which are basically some message attributes).
from kafka-go.
This should be fixed by #135. Please re-open if you think it's still an issue.
from kafka-go.
Related Issues (20)
- Incorrect documentation in the code ReaderConfig.RetentionTime HOT 1
- suggestion: replace existing Log interface with log/slog
- The default value of fetch.max.wait.ms HOT 1
- `reader.Close()` stuck randomly HOT 1
- Make `(msg *Message) totalSize()` public
- Asynchronous mode in kafka package not working
- Duplicate consumption occurs when join a new consumer and CommitInterval is configured HOT 1
- After increasing partition count, consumer group is not assigned to the new partitions. HOT 1
- Observability : Kafka Consumer/Producer metrics and tracing.
- Subscribe topic on demand
- A new method for Batch called ReadIntoMessage
- authorization retries
- What is the difference between kafka.NewConsumerGroup and kafka.NewReader,
- What is QueueCapacity param ?
- Offset is going ahead and we are missing message with lag HOT 3
- How do I specify partition when producing messages,I want to implement ordered messages HOT 1
- AllowAutoTopicCreation does not exist in writer config, but only in the writer struct HOT 1
- Go1.16 cannot run tests HOT 2
- Feture request: logger with different levels HOT 1
- Issue: Getting half partitions while Consumer Group Migration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kafka-go.