Skip to content

chore: limit insert_records to 10 rows per transaction#1381

Merged
MicBun merged 1 commit into
mainfrom
chore/limit-insert-records-batch
May 15, 2026
Merged

chore: limit insert_records to 10 rows per transaction#1381
MicBun merged 1 commit into
mainfrom
chore/limit-insert-records-batch

Conversation

@MicBun
Copy link
Copy Markdown
Contributor

@MicBun MicBun commented May 15, 2026

resolves: https://github.com/truflation/website/issues/3887

Summary by CodeRabbit

  • chores
    • Enforced maximum batch size limit of 10 records per insert operation to prevent exceeding system constraints.
    • Automatic chunking now handles larger data operations by breaking them into multiple smaller batches.

Review Change Stack

@MicBun MicBun requested a review from pr-time-tracker May 15, 2026 12:23
@MicBun MicBun self-assigned this May 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0fef8333-87d8-4d44-b1ee-06ad535424be

📥 Commits

Reviewing files that changed from the base of the PR and between 5ec0392 and db324ee.

📒 Files selected for processing (3)
  • internal/migrations/003-primitive-insertion.prod.sql
  • internal/migrations/003-primitive-insertion.sql
  • tests/streams/utils/setup/primitive.go

📝 Walkthrough

Walkthrough

The PR enforces a hard maximum batch size of 10 records in the insert_records action by replacing commented-out guards with active runtime validation in both SQL migration schemas. The test harness is updated to chunk large batches and make multiple insert_records calls to stay within the limit, including pre-funding per-chunk fees.

Changes

Batch Size Enforcement

Layer / File(s) Summary
On-chain batch size enforcement
internal/migrations/003-primitive-insertion.prod.sql, internal/migrations/003-primitive-insertion.sql
Both SQL migration files replace the previously commented-out batch size guard with an active runtime check that errors when $num_records exceeds 10.
Test harness batching and multi-call logic
tests/streams/utils/setup/primitive.go
InsertPrimitiveDataMultiBatch defines insertRecordsMaxBatchSize constant and reworks the insertion flow to chunk large record sets per data provider group, compute required call counts, fund one write fee per chunk, and execute multiple insert_records calls using sliced arrays with improved error reporting per chunk.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • trufnetwork/node#1351: Both PRs enforce the same core change in internal/migrations/003-primitive-insertion.sql by adding a runtime guard to reject insert_records when the computed batch size ($num_records) exceeds 10.
  • trufnetwork/node#1246: Both PRs modify the insert_records action in internal/migrations/003-primitive-insertion.sql by adding runtime record-count-based guards/logic—main adds a hard batch-size cap (max 10), while the retrieved PR adds role-exempt fee charging computed from $num_records.
  • trufnetwork/node#1365: Both PRs modify the insert_records SQL action in internal/migrations/003-primitive-insertion.sql—main PR adds an enforced max batch size check, while the retrieved PR refactors the stream validation into validate_streams_for_write—so they are related at the same function level.

Suggested reviewers

  • pr-time-tracker
  • outerlook
  • williamrusdyputra

Poem

🐰 Ten at a time, the constraint is clear,
Batch limits reign, no more, no fear!
Chunks stack up through the testing night,
Records divided, fees funded right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: limiting insert_records to a 10-row maximum per transaction, which aligns perfectly with the changeset's core objective.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/limit-insert-records-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@holdex
Copy link
Copy Markdown

holdex Bot commented May 15, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h Update time May 15, 2026, 12:23 PM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

@MicBun
Copy link
Copy Markdown
Contributor Author

MicBun commented May 15, 2026

@holdex pr submit-time 4h

@MicBun MicBun merged commit 66a8293 into main May 15, 2026
9 checks passed
@MicBun MicBun deleted the chore/limit-insert-records-batch branch May 15, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant