Skip to content

Commit 8bf2492

Browse files
committed
[FAB-4083] Fix filesize-related defaults for orderer
The `Producer.MaxMessageBytes` default we were setting on the Kafka producers was incorrectly set to Kafka's default value for `socket.request.max.bytes`. (I actually set it to a value that was just a byte shorter than this when I pushed in the refactor changeset a few days ago in order to silence the sarama logs, and added a FIXME note for this very reason.) This value is incorrect because it doesn't account for headers. This changeset assumes a too-generous 1MB for headers and decreates `Producer.MaxMessageBytes` accordingly. This changeset also updates the default value for AbsoluteMaxBytes in `configtx.yaml`. The current value is incorrect because it doesn't account for the wrapping of messages in the container `KafkaRegular` format. At a minimum, it should be decreased compared to `Producer.MaxMessageBytes` by an equal padding. This changeset does this for all `configtx.yaml` files currently in our codebase. Finally, it sets the default, suggested value for AbsoluteMaxBytes in the sampleconfig `configtx.yaml` file to a much more reasonable 10 MiB, well within the constraints we outlined above. The default check in `localconfig` has been updated accordingly. See the JIRA item for a detailed explanation of the issue. Change-Id: I8821982707282c5069c1a66dd2a121b894b3a3c8 Signed-off-by: Kostas Christidis <[email protected]>
1 parent 897ca82 commit 8bf2492

File tree

7 files changed

+14
-16
lines changed

7 files changed

+14
-16
lines changed

bddtests/dc-orderer-kafka-base.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ services:
2525
#
2626
# socket.request.max.bytes
2727
# The maximum number of bytes in a socket request. ATTN: If you set this
28-
# env var, you should make sure that the value assigned to
29-
# `brokerConfig.Producer.MaxMessageBytes` in `newBrokerConfig()` in
30-
# `fabric/orderer/kafka/util.go` matches it.
28+
# env var, make sure to update `brokerConfig.Producer.MaxMessageBytes` in
29+
# `newBrokerConfig()` in `fabric/orderer/kafka/config.go` accordingly.
3130
#- KAFKA_SOCKET_REQUEST_MAX_BYTES=104857600 # 100 * 1024 * 1024 B
3231
#
3332
# message.max.bytes

common/configtx/tool/localconfig/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ var genesisDefaults = TopLevel{
154154
BatchTimeout: 2 * time.Second,
155155
BatchSize: BatchSize{
156156
MaxMessageCount: 10,
157-
AbsoluteMaxBytes: 100000000,
157+
AbsoluteMaxBytes: 10 * 1024 * 1024,
158158
PreferredMaxBytes: 512 * 1024,
159159
},
160160
Kafka: Kafka{

examples/cluster/config/configtx.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Orderer: &OrdererDefaults
103103

104104
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
105105
# the serialized messages in a batch.
106-
AbsoluteMaxBytes: 99 MB
106+
AbsoluteMaxBytes: 98 MB
107107

108108
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
109109
# the serialized messages in a batch. A message larger than the preferred

examples/e2e_cli/configtx.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Orderer: &OrdererDefaults
117117

118118
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
119119
# the serialized messages in a batch.
120-
AbsoluteMaxBytes: 99 MB
120+
AbsoluteMaxBytes: 98 MB
121121

122122
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
123123
# the serialized messages in a batch. A message larger than the preferred

orderer/kafka/config.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ import (
1515
)
1616

1717
func newBrokerConfig(tlsConfig localconfig.TLS, retryOptions localconfig.Retry, kafkaVersion sarama.KafkaVersion, chosenStaticPartition int32) *sarama.Config {
18-
brokerConfig := sarama.NewConfig()
18+
// Max. size for request headers, etc. Set in bytes. Too big on purpose.
19+
paddingDelta := 1 * 1024 * 1024
1920

20-
// FIXME https://jira.hyperledger.org/browse/FAB-4136
21-
// Use retryOptions to populate `Net`
21+
brokerConfig := sarama.NewConfig()
2222

2323
brokerConfig.Consumer.Retry.Backoff = retryOptions.Consumer.RetryBackoff
2424

25-
// Allows us to retrieve errors that occur when consuming a channel, via the
26-
// channel's `listenForErrors` goroutine.
25+
// Allows us to retrieve errors that occur when consuming a channel
2726
brokerConfig.Consumer.Return.Errors = true
2827

2928
brokerConfig.Metadata.Retry.Backoff = retryOptions.Metadata.RetryBackoff
@@ -57,7 +56,7 @@ func newBrokerConfig(tlsConfig localconfig.TLS, retryOptions localconfig.Retry,
5756

5857
// Set equivalent of Kafka producer config max.request.bytes to the default
5958
// value of a Kafka broker's socket.request.max.bytes property (100 MiB).
60-
brokerConfig.Producer.MaxMessageBytes = int(sarama.MaxRequestSize) // FIXME https://jira.hyperledger.org/browse/FAB-4083
59+
brokerConfig.Producer.MaxMessageBytes = int(sarama.MaxRequestSize) - paddingDelta
6160

6261
brokerConfig.Producer.Retry.Backoff = retryOptions.Producer.RetryBackoff
6362
brokerConfig.Producer.Retry.Max = retryOptions.Producer.RetryMax

sampleconfig/configtx.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ Orderer: &OrdererDefaults
147147
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
148148
# the serialized messages in a batch. If the "kafka" OrdererType is
149149
# selected, set 'message.max.bytes' and 'replica.fetch.max.bytes' on the
150-
# Kafka brokers to a value that is equal to or larger than this one.
151-
AbsoluteMaxBytes: 99 MB
150+
# Kafka brokers to a value that is larger than this one.
151+
AbsoluteMaxBytes: 10 MB
152152

153153
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
154154
# the serialized messages in a batch. A message larger than the

test/feature/configs/configtx.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ Orderer: &OrdererDefaults
132132
# Absolute Max Bytes: The absolute maximum number of bytes allowed for
133133
# the serialized messages in a batch. If the "kafka" OrdererType is
134134
# selected, set 'message.max.bytes' and 'replica.fetch.max.bytes' on the
135-
# Kafka brokers to a value that is equal to or larger than this one.
136-
AbsoluteMaxBytes: 99 MB
135+
# Kafka brokers to a value that is larger than this one.
136+
AbsoluteMaxBytes: 98 MB
137137

138138
# Preferred Max Bytes: The preferred maximum number of bytes allowed for
139139
# the serialized messages in a batch. A message larger than the

0 commit comments

Comments
 (0)