You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/16 02:40:08 UTC
[GitHub] [pulsar-client-go] jack-tristan opened a new issue, #847: message add to batch failed: AddToBatchFailed
jack-tristan opened a new issue, #847:
URL: https://github.com/apache/pulsar-client-go/issues/847
#### Expected behavior
Settings: Schema=StringSchema, CompressionType=pulsar.LZ4[, DisableBatching=true]
pulsar-client-go version: v0.8.0 & v0.8.1
when: string size > 132000 and size < 5MB, producer can send message normally
#### Actual behavior
when string size > 132000, program will throw "unable to add message to batch" (message add to batch failed: AddToBatchFailed)
#### Steps to reproduce
```
func main(){
ProducerString(genStr(132000)) // when the string size > 132000,program will throw "unable to add message to batch" using pulsar-client-go version v0.8.0 & v0.8.1
}
// generate test string
func genStr(size int) string {
var builder strings.Builder
for i:=0; i < size; i++ {
builder.WriteString("a")
//builder.WriteString("abcdefghi,")
}
return builder.String()
}
// producer to send msg
func ProducerString(str string) {
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: pulsar://10.200.19.3:6650,
OperationTimeout: 30 * time.Second,
ConnectionTimeout: 30 * time.Second,
})
if err != nil {
utils.Logger.Fatal(err)
return
}
defer client.Close()
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: "persistent://test-zdh/test/pt-longstr-v1",
Schema: pulsar.NewStringSchema(nil),
CompressionType: pulsar.LZ4,
DisableBatching: true,
})
defer producer.Close()
msgID, err := producer.Send(context.Background(), &pulsar.ProducerMessage{
Value: str,
})
if err != nil {
utils.Logger.Fatal(err)
}
utils.Logger.Info(msgID)
}
```
#### System configuration
**Pulsar version**: v2.6.3
**pulsar-client-go bug version**: v0.8.0 & v0.8.1
**go version**: 1.15.12
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] labuladong commented on issue #847: message add to batch failed: AddToBatchFailed
Posted by GitBox <gi...@apache.org>.
labuladong commented on issue #847:
URL: https://github.com/apache/pulsar-client-go/issues/847#issuecomment-1248920510
Hi @jack-tristan, I can't reproduce your problem with pulsar version v2.6.3 and client-go version V0.8.1. Seems that these lines of code get `false` result, then throw a "unable to add message to batch" error:
https://github.com/apache/pulsar-client-go/blob/ea6eccf7ddad548a1ad977a0b72a61b894e6d248/pulsar/internal/batch_builder.go#L177-L199
Do you have more context information about this problem?
My test code:
```golang
package main
import (
"context"
"github.com/apache/pulsar-client-go/pulsar"
log "github.com/sirupsen/logrus"
"strings"
"time"
)
func main() {
ProducerString(genStr(199999)) // when the string size > 132000,program will throw "unable to add message to batch" using pulsar-client-go version v0.8.0 & v0.8.1
}
// generate test string
func genStr(size int) string {
var builder strings.Builder
for i := 0; i < size; i++ {
builder.WriteString("a")
//builder.WriteString("abcdefghi,")
}
return builder.String()
}
// ProducerString producer to send msg
func ProducerString(str string) {
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://192.168.50.117:6650",
OperationTimeout: 30 * time.Second,
ConnectionTimeout: 30 * time.Second,
})
if err != nil {
log.Error(err)
return
}
defer client.Close()
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: "pt-longstr-v1",
Schema: pulsar.NewStringSchema(nil),
CompressionType: pulsar.LZ4,
DisableBatching: true,
})
defer producer.Close()
msgID, err := producer.Send(context.Background(), &pulsar.ProducerMessage{
Value: str,
})
if err != nil {
log.Error(err)
}
log.Info("success: ", msgID)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-go] flowchartsman commented on issue #847: message add to batch failed: AddToBatchFailed
Posted by GitBox <gi...@apache.org>.
flowchartsman commented on issue #847:
URL: https://github.com/apache/pulsar-client-go/issues/847#issuecomment-1277658306
https://github.com/apache/pulsar-client-go/issues/447 perhaps?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org