File tree Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Expand file tree Collapse file tree 4 files changed +22
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' hive ' : patch
3
+ ---
4
+
5
+ Adjust the Kafka message size estimation only when Kafka gives back ` MESSAGE_TOO_LARGE ` error
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ test('increase the defaultBytesPerOperation estimation by 5% when over 100 calls
34
34
limitInBytes : eventHubLimitInBytes ,
35
35
useEstimator : true ,
36
36
onRetry,
37
+ isTooLargePayloadError ( ) {
38
+ return true ;
39
+ } ,
37
40
calculateReportSize ( report ) {
38
41
return report . size ;
39
42
} ,
@@ -150,6 +153,9 @@ test('buffer should split the report into multiple reports when the estimated si
150
153
interval,
151
154
limitInBytes : eventHubLimitInBytes ,
152
155
useEstimator : true ,
156
+ isTooLargePayloadError ( ) {
157
+ return true ;
158
+ } ,
153
159
calculateReportSize ( report ) {
154
160
return report . size ;
155
161
} ,
@@ -262,6 +268,9 @@ test('buffer create two chunks out of one buffer when actual buffer size is too
262
268
interval,
263
269
limitInBytes : eventHubLimitInBytes ,
264
270
useEstimator : true ,
271
+ isTooLargePayloadError ( ) {
272
+ return true ;
273
+ } ,
265
274
calculateReportSize ( report ) {
266
275
return report . size ;
267
276
} ,
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ export function createKVBuffer<T>(config: {
131
131
calculateReportSize ( report : T ) : number ;
132
132
split ( report : T , numOfChunks : number ) : readonly T [ ] ;
133
133
onRetry ( reports : readonly T [ ] ) : void ;
134
+ isTooLargePayloadError ( error : unknown ) : boolean ;
134
135
sender (
135
136
reports : readonly T [ ] ,
136
137
estimatedSizeInBytes : number ,
@@ -254,8 +255,10 @@ export function createKVBuffer<T>(config: {
254
255
await flushBuffer ( reports , size , batchId ) ;
255
256
} catch ( error ) {
256
257
logger . error ( error ) ;
257
- // the payload size was most likely too big
258
- estimator . overflowed ( batchId ) ;
258
+ if ( config . isTooLargePayloadError ( error ) ) {
259
+ // the payload size was most likely too big
260
+ estimator . overflowed ( batchId ) ;
261
+ }
259
262
}
260
263
}
261
264
Original file line number Diff line number Diff line change @@ -156,6 +156,9 @@ export function createUsage(config: {
156
156
interval : config . kafka . buffer . interval ,
157
157
limitInBytes : 990_000 , // 1MB is the limit of a single request to EventHub, let's keep it below that
158
158
useEstimator : config . kafka . buffer . dynamic ,
159
+ isTooLargePayloadError ( error ) {
160
+ return error instanceof Error && 'type' in error && error . type === 'MESSAGE_TOO_LARGE' ;
161
+ } ,
159
162
calculateReportSize ( report ) {
160
163
return Object . keys ( report . map ) . length ;
161
164
} ,
You can’t perform that action at this time.
0 commit comments