Skip to content

fix(cascade): persist metadata-only first batch when no symbols selected#277

Open
j-rafique wants to merge 1 commit intomasterfrom
cascade-store-symbols-improvement
Open

fix(cascade): persist metadata-only first batch when no symbols selected#277
j-rafique wants to merge 1 commit intomasterfrom
cascade-store-symbols-improvement

Conversation

@j-rafique
Copy link
Contributor

@j-rafique j-rafique commented Mar 12, 2026

Summary

This PR fixes a first-batch persistence gap in cascade artefact storage.
Previously, storeCascadeSymbolsAndData only sent metadata (IDFiles) inside the symbol batching loop.
If no symbols were selected (len(keys) == 0), the loop never ran, but UpdateIsFirstBatchStored was still called.
That could mark the action as first-batch stored without actually persisting index/layout metadata to P2P.

What changed

  • Added an explicit metadata-only batch path in storeCascadeSymbolsAndData:
  • Triggered when len(keys) == 0 && len(metadataFiles) > 0
  • Sends metadata via p2p.StoreBatch(...)
  • Preserves timeout handling and structured logging
  • Updates byte accounting consistently
  • Existing first-batch flag update behavior now correctly happens only after successful metadata persistence.

Tests added

In supernode/adaptors/p2p_test.go:

TestStoreCascadeSymbolsAndData_MetadataOnlyBatchWhenNoSymbols

  • Verifies metadata is sent when no symbols are selected
  • Verifies call count and payload expectations
  • Verifies success path (no symbols stored, no total symbols)

TestStoreCascadeSymbolsAndData_MetadataOnlyBatchFailureSkipsFirstBatchFlag

  • Verifies metadata-only store errors are surfaced
  • Verifies first-batch flag is not updated when metadata store fails

Why this matters

Ensures first-batch completion semantics remain correct and durable by guaranteeing metadata is persisted even when symbol selection yields zero symbols.

@roomote-v0
Copy link

roomote-v0 bot commented Mar 12, 2026

Rooviewer Clock   Follow task

Reviewing your PR now. Feedback will be posted soon!

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.

1 participant