Skip to content

fix: reset int hashmap scratch before encoding - #32647

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/issue-32568-int-hmap-scratch
Nov 13, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
XuPeng-SH:codex/issue-32568-int-hmap-scratch

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #32568

What this PR does / why we need it:

IntHashMap reuses keys and keyOffs. In HashBuild's Insert -> Find -> Insert path, Find left the offset advanced for a BIGINT; the next Insert wrote beyond its key slot and corrupted runtime-filter cleanup state. The surviving CN then retained a runtime-filter allocation and suspended account admission.

Reset both scratch slices inside encodeHashKeys, at the unsafe encoder's ownership boundary, before every encoding. This removes call-order dependence by centralizing the existing per-operation clears at encoder entry; Insert moves its reset from the defer. It adds no clearing pass. Add a deterministic regression test for the sequence with distinct keys.

Validation:

  • go test ./pkg/common/hashmap -count=1 with Go 1.26.4.
  • Full cmd/mo-service build with Go 1.26.4 and CGO enabled.
  • Three-CN SQL reproduction with 100 prepared UPDATE clients over 1M rows; after pausing CN2 for 2 minutes, 85,373 updates succeeded with 0 errors. The table retained 1M rows and 1M distinct b values; no allocation-admission or panic signals appeared.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner November 12, 2026 20:21
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify

mergify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@XuPeng-SH

XuPeng-SH commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: ccbe616367401806b1ea9a144b90a5041e92b296

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: ccbe616367401806b1ea9a144b90a5041e92b296

Assessment: approve

Resetting scratch at encoder entry fixes the Find-to-Insert defect and removes duplicated clearing without adding allocations, synchronization or a clearing pass. No actionable findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Frozen-base control failed the new regression as expected: the second key reused the first group, followed by cleanup allocation-ownership underflow.

  • All 25 hashmap tests passed in normal and race modes; the regression passed 100 race repetitions. All 131 HashBuild tests passed without skips.

  • Build, vet, preflight, formatting, diff and source/native/receipt audits passed. Evidence is retained in validation-audit.json.

  • Reviewed the complete delta, linked issue and all three discussion entries.

Limitations:

  • Local checks used Linux/amd64 and Go 1.26.6. Supplied CI remained pending.

  • The reported three-CN SQL validation was not independently rerun; raw logs were unavailable.

This branch was previously deployed

1 inactive deployment
ci — ccbe6163 Deployed Nov 12, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants