Skip to content

Conversation

@StrathCole
Copy link

Added a flush threshold to prevent Pebble batch from exceeding 4 GB limit during write operations.
Cometbft-db just executes set and delete on the batches without checking for the size. Pebble has a hard-coded limit of batch sizes to 4GB
grafik

This can lead to node panic in case there is massive data compaction/migrations.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)

Added a flush threshold to prevent Pebble batch from exceeding 4 GB limit during write operations.
@StrathCole StrathCole requested review from a team as code owners October 23, 2025 05:58
@StrathCole StrathCole changed the title Implement flush threshold for Pebble batch operations fix(pebble.go): implement flush threshold for Pebble batch operations Oct 23, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.


// Prevent Pebble batch from exceeding 4 GB hard limit
if b.batch.Len() > flushThreshold {
if err := b.batch.Commit(pebble.Sync); err != nil {
Copy link

Choose a reason for hiding this comment

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

Bug: Batch Flush Sync Inconsistency

The automatic batch flush uses pebble.Sync, which is inconsistent with the pebble.NoSync used by the Write() method. This introduces unexpected synchronous writes during batch building, potentially causing performance slowdowns and violating user expectations.

Fix in Cursor Fix in Web

Copy link
Author

Choose a reason for hiding this comment

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

I would think this is necessary due to the location the commit is called, as it "interrupts" a normal batch operation, this should not simply continue until the batch is committed.

}
b.batch.Reset()
}

Copy link

Choose a reason for hiding this comment

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

Bug: Batch Size Check Timing Issue

The batch size check in pebbleDBBatch.Set and Delete happens before adding the operation. This means a large operation can push the batch over Pebble's 4GB hard limit, even if the current size is below the flushThreshold.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Author

Choose a reason for hiding this comment

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

In my opinion this would be unlikely to happen. Single operations normally are much smaller, just batching them can lead to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant