Skip to content

fix(storage): read CSR length via Column in getDegreeForOffset - #1295

Open
adsharma wants to merge 1 commit into
LadybugDB:mainfrom
adsharma:fix-1292-degree-for-offset
Open

adsharma wants to merge 1 commit into
LadybugDB:mainfrom
adsharma:fix-1292-degree-for-offset

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Fixes #1292.

Root cause: RelTable::getDegreeForOffset read the persistent CSR length directly from the ChunkedCSRNodeGroup's ColumnChunk (ChunkedCSRHeader::getCSRLength → ColumnChunk::getValue). Those header chunks are ResidencyState::ON_DISK, so their in-memory buffers are zero-size/not positionally valid — in release builds this reads out-of-bounds/uninitialized memory, producing garbage degrees (~1e14) or 0 for valid offsets. It also bypassed the scan-pin/retained-snapshot routing.

Fix:

  • Pin via captureScanPin(transaction) and scan the single length value through its Column (same pattern as forEachDegree/CountRelTable).
  • Read committed in-memory degrees from pin.index.
  • Count uncommitted local rels even when the node group has no committed CSR group (matches forEachDegree's local-only-group handling).

Tests: extended RelDegreeTest.MatchesCypherAcrossNodeGroupsAndStorageStates to assert getDegreeForOffset == degree for every expected entry across checkpointed, committed in-memory, and uncommitted states.

Persistent CSR length chunks are ResidencyState::ON_DISK, so reading them via ColumnChunk::getValue returns uninitialized memory (garbage degrees / 0). Scan the length through its Column like forEachDegree/CountRelTable instead, under captureScanPin so parked readers get their retained snapshot. Also count uncommitted local rels even when the node group has no committed CSR group.

Fixes LadybugDB#1292

This branch has not been deployed

No deployments
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.

getDegreeForOffset returns garbage/zero for valid offsets at plan time

1 participant