Skip to content

pgwire: handle negative scale#160499

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
dils2k:negative-scale-pgwire
Jan 6, 2026
Merged

pgwire: handle negative scale#160499
craig[bot] merged 1 commit intocockroachdb:masterfrom
dils2k:negative-scale-pgwire

Conversation

@dils2k
Copy link
Copy Markdown
Contributor

@dils2k dils2k commented Jan 5, 2026

The node could crash if it received a decimal with a negative scale value. This commit adds a check and returns an error instead.

Epic: CRDB-57539
Fixes: #158884

Release note (bug fix): CockroachDB could previously crash when handling decimals with negative scales via extended PGWire protocol and this has been fixed (an error is returned, similar to PG).

@dils2k dils2k requested review from a team as code owners January 5, 2026 20:58
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 5, 2026

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl bot added the O-community Originated from the community label Jan 5, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

Nice work!

@DrewKimball reviewed 2 files and all commit messages, and made 4 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @dils2k).


-- commits line 10 at r1:
nit: You don't need the "Informs" line when you already have "Fixes".


pkg/sql/pgwire/testdata/pgtest/decimal line 112 at r1 (raw file):

{"Type":"ReadyForQuery","TxStatus":"I"}

send

Let's add a comment to explain that this is a regression test for #158884.


pkg/sql/pgwire/testdata/pgtest/decimal line 125 at r1 (raw file):

{"Type":"ParseComplete"}
{"Type":"ErrorResponse","Code":"22P03"}
{"Type":"ReadyForQuery","TxStatus":"I"}

nit: Looks like you're missing a newline at the end of the file.

@dils2k dils2k force-pushed the negative-scale-pgwire branch from 83b150c to 124b549 Compare January 5, 2026 21:51
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 5, 2026

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@dils2k
Copy link
Copy Markdown
Contributor Author

dils2k commented Jan 5, 2026

@DrewKimball PTAL

@dils2k dils2k requested a review from DrewKimball January 5, 2026 23:17
Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

@DrewKimball reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @dils2k).

The node could crash if it received a decimal with a negative scale value.
This commit adds a check and returns an error instead.

Epic: CRDB-57539
Fixes: cockroachdb#158884

Release note (bug fix): CockroachDB could previously crash when handling
decimals with negative scales via extended PGWire protocol and this has
been fixed (an error is returned, similar to PG).
@yuzefovich yuzefovich force-pushed the negative-scale-pgwire branch from 124b549 to 65ee633 Compare January 6, 2026 15:34
@yuzefovich yuzefovich added backport-25.4.x Flags PRs that need to be backported to 25.4 backport-26.1.x Flags PRs that need to be backported to 26.1 labels Jan 6, 2026
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

I added the bug fix release note. Thanks for your contribution!

bors r=drewkimball,yuzefovich

@yuzefovich reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @dils2k).

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 6, 2026

🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set.

craig bot pushed a commit that referenced this pull request Jan 6, 2026
159819: cmd: add ghsearchdump and ghweeklysummary r=wenyihu6 a=wenyihu6

Epic: none 
Release note: none

---
**ghsearchdump**


---
**cmd/ghweeklysummary: add tool for generating weekly PR summaries**

```
Example usage:

# Last 1 week
go run ./pkg/cmd/ghweeklysummary --author wenyihu6 --weeks 1

# Specific date range
go run ./pkg/cmd/ghweeklysummary --author wenyihu6 --after 2025-01-01 --before 2025-02-01

# Save to file
go run ./pkg/cmd/ghweeklysummary --author wenyihu6 > weekly_summary.md
```

Release Notes: None
Epic: None

---
**cmd: move kv dev tools under pkg/cmd/kv/**

Move ghsearchdump and ghweeklysummary under pkg/cmd/kv/ for clearer
ownership. This seems okay given we already have pkg/cmd/allocsim.

```
Example usage:

❯ go run ./pkg/cmd/ghweeklysummary --author wenyihu6 --weeks 1

❯ go run ./pkg/cmd/kv/ghsearchdump \
  --search "repo:cockroachdb/cockroach author:wenyihu6" \
  --contribution-after 2025-12-12
tracking contributions from: [wenyihu6]
```



160459: kvserver: add tracing to TestStoreRangeSplitBackpressureWrites r=tbg a=stevendanna

In #160141 we observed this test fail. This test is rather stable but does depend on two goroutines sending batches to the KV server within a 100ms timeout. One suspicion is that very rarely we are too slow and this time-based coordination is not enough.

This test is rather stable and adding more sophisticated coordination will further complicate an already complicated test. Here, I add some tracing that will hopefully allow us to confirm the timing based theory if this ever happens again.

Fixes #160141

Release note: None

160499: pgwire: handle negative scale r=drewkimball,yuzefovich a=dils2k

The node could crash if it received a decimal with a negative scale value. This commit adds a check and returns an error instead.

Epic: CRDB-57539
Fixes: #158884

Release note (bug fix): CockroachDB could previously crash when handling decimals with negative scales via extended PGWire protocol and this has been fixed (an error is returned, similar to PG).

160526: sql: fix TestUnsplitRanges to work with external test tenants r=rafiss a=rafiss

Previously, TestUnsplitRanges was skipped in external test tenant mode because it scanned meta ranges directly and performed AdminSplit/ AdminUnsplit operations that external tenants cannot do.

This commit fixes the test by:
1. Using the system layer's DB for meta range operations (scanning meta ranges, checking sticky bits, splitting ranges) since tenants cannot access meta ranges directly.
2. Using the application layer's DB for table data operations which tenants can access.
3. Granting the CanAdminUnsplit capability to the external tenant so the GC job can unsplit ranges after dropping tables/indexes.

Resolves: #142388
Epic: CRDB-48944

Release note: None

Co-authored-by: Tobias Grieger <tobias.b.grieger@gmail.com>
Co-authored-by: wenyihu6 <wenyi@cockroachlabs.com>
Co-authored-by: Steven Danna <danna@cockroachlabs.com>
Co-authored-by: dils2k <dils.matchanov@gmail.com>
Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 6, 2026

Build failed (retrying...):

@craig craig bot merged commit f50ee9d into cockroachdb:master Jan 6, 2026
26 of 27 checks passed
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 6, 2026

Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.


Issue #158884: branch-release-25.4, branch-release-26.1.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 6, 2026

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 6, 2026

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 65ee633 to blathers/backport-release-25.4-160499: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 25.4.x failed. See errors above.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 65ee633 to blathers/backport-release-26.1-160499: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 26.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@yuzefovich
Copy link
Copy Markdown
Member

blathers backport release-26.1

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 6, 2026

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details.

error creating merge commit from 65ee633 to blathers/backport-release-26.1-160499: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch release-26.1 failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

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

Labels

backport-25.4.x Flags PRs that need to be backported to 25.4 backport-26.1.x Flags PRs that need to be backported to 26.1 backport-failed O-community Originated from the community v26.2.0-prerelease

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: negative scale in pgwire binary decimal format crashes node

4 participants