Skip to content

[fix](be) Make prefix page encoding and geography tests portable - #71463

Open
morningman wants to merge 1 commit into
apache:masterfrom
morningman:fix/be-prefix-geography-portability
Open

morningman wants to merge 1 commit into
apache:masterfrom
morningman:fix/be-prefix-geography-portability

Conversation

@morningman

Copy link
Copy Markdown
Contributor

Background

PREFIX pages store the length shared by adjacent values and the remaining bytes. Doris uses them for string pages and Merge-on-Write primary key indexes. The GEOGRAPHY tests also exercise cases near the rounding limits of S2's spherical coordinates.

What problem does this PR solve?

Issue Number: None
Related PR: #71462 (recorded the failures), #68609 (page fixtures), #69032 (GEOGRAPHY tests)
PR Type: Bugfix

Problem Summary:

A shared byte such as 0xE4 can compare unequal to itself in the PREFIX builder when plain char is signed. That changes page boundaries and primary key index sizes between platforms. Two VGeo tests also relied on platform-dependent rounding for an almost collapsed ring and for the legacy WKB parser's treatment of a near-antipodal edge.

Details

  • Change map: A one-line encoder correction and a focused byte-level regression. Two page fixture files and 46 segment fixtures are regenerated. The VGeo test changes preserve proximity and typed shell admission coverage and give the legacy parser a stable exterior-hole case.
  • Frequency: Always when a signed-char build compares a shared high-bit byte. The original fixture comparisons exposed four Linux ARM64 failures, and two VGeo cases failed on macOS ARM64.
  • Root cause: BinaryPrefixPageBuilder compared a plain char with the previous entry's uint8_t. Integer promotion made the same high-bit octet compare unequal. The VGeo fixtures assumed that an extremely narrow polygon survives conversion to S2 and that legacy WKB rejects the same near-antipodal shell on each platform.
  • Why existing tests missed it: The basic BinaryPrefixPageTest values are ASCII. The storage fixtures check physical bytes, and their checked-in baseline came from the signed-char representation. SQL coverage such as test_primary_key_simple_case checks data and key semantics at readback.
  • Fix: Compare unsigned octets. The page format already supports either shared-prefix length, so the same decoder reads existing and new pages. Use a representable nearby ring for the VGeo proximity check. Keep the typed near-antipodal shell test and test legacy exterior-hole rejection separately.
  • Other paths and branches: String pages and primary key indexes share this builder. The same comparison is present on branches 3.1, 4.0, 4.1, and 4.2. This change targets master.

Testing

  • The new high-bit prefix regression failed on macOS ARM64 ASAN before the encoder change. The second entry stored both bytes instead of sharing 0xE4.
  • macOS ARM64 ASAN and Docker Linux ARM64 ASAN each passed the same 198 targeted tests in registration order and with shuffle seed 48256. All four runs had zero config diagnostics. The selection covers BinaryPrefixPageTest, PrimaryKeyIndexTest, PREFIX strings, page and segment fixtures, and the full VGeo suite.
  • Regeneration on the fixed Linux build produced all 8 page fixture files and all 148 segment fixtures byte for byte.

Release note

None

Check List (For Author)

  • Behavior changed: No
  • Does this need documentation: No
  • Pre-submission status: Ready

AI Disclosure

  • Tool: OpenAI Codex (GPT-6)
  • Generated: The fix, test changes, fixture generation and verification, and PR description.
  • Human review: not stated

### Background

PREFIX pages store the length shared by adjacent values and the remaining bytes. Doris uses them for string pages and Merge-on-Write primary key indexes. The GEOGRAPHY tests also exercise cases near the rounding limits of S2's spherical coordinates.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#71462 (recorded the failures), apache#68609 (page fixtures), apache#69032 (GEOGRAPHY tests)
PR Type: Bugfix

Problem Summary:

A shared byte such as `0xE4` can compare unequal to itself in the PREFIX builder when plain `char` is signed. That changes page boundaries and primary key index sizes between platforms. Two VGeo tests also relied on platform-dependent rounding for an almost collapsed ring and for the legacy WKB parser's treatment of a near-antipodal edge.

### Details

- **Change map:** A one-line encoder correction and a focused byte-level regression. Two page fixture files and 46 segment fixtures are regenerated. The VGeo test changes preserve proximity and typed shell admission coverage and give the legacy parser a stable exterior-hole case.
- **Frequency:** Always when a signed-char build compares a shared high-bit byte. The original fixture comparisons exposed four Linux ARM64 failures, and two VGeo cases failed on macOS ARM64.
- **Root cause:** `BinaryPrefixPageBuilder` compared a plain `char` with the previous entry's `uint8_t`. Integer promotion made the same high-bit octet compare unequal. The VGeo fixtures assumed that an extremely narrow polygon survives conversion to S2 and that legacy WKB rejects the same near-antipodal shell on each platform.
- **Why existing tests missed it:** The basic `BinaryPrefixPageTest` values are ASCII. The storage fixtures check physical bytes, and their checked-in baseline came from the signed-char representation. SQL coverage such as `test_primary_key_simple_case` checks data and key semantics at readback.
- **Fix:** Compare unsigned octets. The page format already supports either shared-prefix length, so the same decoder reads existing and new pages. Use a representable nearby ring for the VGeo proximity check. Keep the typed near-antipodal shell test and test legacy exterior-hole rejection separately.
- **Other paths and branches:** String pages and primary key indexes share this builder. The same comparison is present on branches 3.1, 4.0, 4.1, and 4.2. This change targets master.

### Testing

- The new high-bit prefix regression failed on macOS ARM64 ASAN before the encoder change. The second entry stored both bytes instead of sharing `0xE4`.
- macOS ARM64 ASAN and Docker Linux ARM64 ASAN each passed the same 198 targeted tests in registration order and with shuffle seed 48256. All four runs had zero config diagnostics. The selection covers `BinaryPrefixPageTest`, `PrimaryKeyIndexTest`, PREFIX strings, page and segment fixtures, and the full VGeo suite.
- Regeneration on the fixed Linux build produced all 8 page fixture files and all 148 segment fixtures byte for byte.

### Release note

None

### Check List (For Author)

- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Ready

### AI Disclosure

- Tool: OpenAI Codex (GPT-6)
- Generated: The fix, test changes, fixture generation and verification, and PR description.
- Human review: not stated

Co-Authored-By: OpenAI Codex <codex@openai.com>
@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

1 similar comment
@shuke987

shuke987 commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

run buildall

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.

2 participants