Skip to content

Conversation

@AhmedSoliman
Copy link
Contributor

@AhmedSoliman AhmedSoliman commented Jan 7, 2026

Add a record size limit check at append time in Bifrost to validate that
individual records do not exceed a configured maximum size.

Important note: This configuration option is not going to be effective without implementing size estimation of records. At the moment, all typed records are assumed to be 2048 bytes in size which makes this check useless. Nevertheless,
This check is useful for the future when we implement size estimation of records.

Changes:

  • Add bifrost.record-size-limit configuration option that defaults to networking.message-size-limit (32 MiB) and is clamped to that value
  • Add BatchTooLarge/RecordTooLarge error variants to get notified when a record too large or when a batch is too large depending on whether you're using Appender or BackgroundAppender.
  • Add record size validation to all LogSender enqueue methods in BackgroundAppender to fail fast at enqueue time

This prevents oversized records from being written to the log, which could cause issues during replication and network transmission.

Part of #4130, #4132


Stack created with Sapling. Best reviewed with ReviewStack.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Test Results

  7 files  ± 0    7 suites  ±0   5m 16s ⏱️ + 2m 1s
 49 tests + 2   49 ✅ + 2  0 💤 ±0  0 ❌ ±0 
210 runs  +10  210 ✅ +10  0 💤 ±0  0 ❌ ±0 

Results for commit e08efaa. ± Comparison against base commit e1bc1d4.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@tillrohrmann tillrohrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for adding the record-size-limit guardrails to bifrost @AhmedSoliman. LGTM. +1 for merging :-)

Copy link
Contributor

@muhamadazmy muhamadazmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this PR! The changes looks good to me. I left couple of very minor comments below. +1 for merging

MetadataStoreError(#[from] Arc<ReadWriteError>),
#[error("record batch too large: {record_size} bytes exceeds limit of {limit} bytes")]
BatchTooLarge {
record_size: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this should be batch_size?

Suggested change
record_size: usize,
batch_size: usize,

let record_size = body.estimated_encode_size();
let limit = self.record_size_limit();
if body.estimated_encode_size() > self.record_size_limit().get() {
return Err(Error::BatchTooLarge { record_size, limit });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this should be a RecordTooLarge error instead?

Suggested change
return Err(Error::BatchTooLarge { record_size, limit });
return Err(Error::RecordTooLarge { record_size, limit });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, the appender only operates on batches.

#[error("error when self proposing")]
SelfProposer,
#[error("error when self proposing: {0}")]
SelfProposer(String),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we finally propagate the source error 😆! But maybe it's a good idea to use a Box<dyn Error + Send + Sync> or anyhow::Error ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted out from doing this because in various places we return EnqueueError(T) where T might not be Debug or Send+Sync.

@AhmedSoliman AhmedSoliman force-pushed the pr4139 branch 2 times, most recently from 11d2bc4 to e08efaa Compare January 8, 2026 10:03
Add a record size limit check at append time in Bifrost to validate that
individual records do not exceed a configured maximum size.

Important note: This configuration option is not going to be effective without implementing size estimation of records. At the moment, all typed records are assumed to be 2048 bytes in size which makes this check useless. Nevertheless,
This check is useful for the future when we implement size estimation of records.

Changes:
- Add `bifrost.record-size-limit` configuration option that defaults to `networking.message-size-limit` (32 MiB) and is clamped to that value
- Add `BatchTooLarge/RecordTooLarge` error variants to get notified when a record too large or when a batch is too large depending on whether you're using Appender or BackgroundAppender.
- Add record size validation to all `LogSender` enqueue methods in `BackgroundAppender` to fail fast at enqueue time

This prevents oversized records from being written to the log, which could cause issues during replication and network transmission.

Part of #4130, #4132
@AhmedSoliman AhmedSoliman merged commit c8ad011 into main Jan 8, 2026
13 of 16 checks passed
@AhmedSoliman AhmedSoliman deleted the pr4139 branch January 8, 2026 10:28
@github-actions github-actions bot locked and limited conversation to collaborators Jan 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants