Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix postgres query msg size estimate#599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
eminano merged 3 commits intomainfromfix-postgres-query-msg-size
Nov 11, 2025

Conversation

@eminano
Copy link
Collaborator

@eminanoeminano commentedNov 11, 2025
edited
Loading

Description

This PR updates the postgres query msg size estimate so that the backpressure mechanism in the batch sender can work more accurately. Previous implementation was not factoring in the size of the query column values, which especially for large tables, can create a big gap between the estimate and the real allocated size.

⚠️ This is only an estimate and it intends to overestimate when possible to prevent OOM issues.

Related Issue(s)

Type of Change

Please select the relevant option(s):

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ⚡ Performance improvement

Testing

  • Unit tests added/updated
  • [] Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the size estimation for PostgreSQL query messages to improve the accuracy of the backpressure mechanism in the batch sender. The previous implementation only accounted for the SQL query string length, while the new implementation includes struct overhead, schema/table names, column names with their overheads, and query arguments with type-specific size estimations.

  • Updatedquery.Size() method to provide comprehensive memory size estimation
  • Added helper functionestimateArgSize() to calculate size of query arguments based on their types
  • Added comprehensive unit tests covering nil queries, empty queries, simple queries, and queries with parameters

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

FileDescription
pkg/wal/processor/postgres/postgres_query_msg.goEnhanced Size() method with detailed memory overhead calculations and added estimateArgSize() helper function
pkg/wal/processor/postgres/psotgres_query_msg_test.goAdded comprehensive test suite for query Size() method with multiple test cases

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

@github-actions
Copy link

Merging this branch willincrease overall coverage

Impacted PackagesCoverage Δ🤖
github.com/xataio/pgstream/pkg/wal/processor/postgres73.67% (+1.25%)👍

Coverage by file

Changed files (no unit tests)

Changed FileCoverage ΔTotalCoveredMissed🤖
github.com/xataio/pgstream/pkg/wal/processor/postgres/postgres_query_msg.go91.30% (+41.30%)23 (+15)21 (+17)2 (-2)🌟

Please note that the "Total", "Covered", and "Missed" counts above refer tocode statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/xataio/pgstream/pkg/wal/processor/postgres/postgres_query_msg_test.go

@eminanoeminano merged commitf360431 intomainNov 11, 2025
7 checks passed
@eminanoeminano deleted the fix-postgres-query-msg-size branchNovember 11, 2025 13:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@exekiasexekiasexekias approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Postgres Writer] Batch message size is not accurate

3 participants

@eminano@exekias

[8]ページ先頭

©2009-2025 Movatter.jp