Skip to content

Comments

fix: FixRawSize SQL column name, join, and filetype bugs#1037

Merged
snadrus merged 1 commit intomainfrom
fix/rawsize-join-bug
Feb 19, 2026
Merged

fix: FixRawSize SQL column name, join, and filetype bugs#1037
snadrus merged 1 commit intomainfrom
fix/rawsize-join-bug

Conversation

@Reiers
Copy link
Contributor

@Reiers Reiers commented Feb 19, 2026

Summary

Complete fix for all SQL bugs in FixRawSize (task_fix_rawSize.go). Follow-up to #1035 (array cast fix). All bugs introduced in #855.

Bugs Fixed (4)

1. CanAccept: wrong table alias in join

- INNER JOIN sector_location l ON mpd.sp_id = mpd.miner_id
+ INNER JOIN sector_location l ON mpd.sp_id = l.miner_id

market_piece_deal has no miner_id column → column mpd.miner_id does not exist (SQLSTATE 42703)

2. Do() + CanAccept: wrong column name sector_number

- mpd.sector_number
+ mpd.sector_num

market_piece_deal column is sector_num, not sector_number. Bug in Do() was masked because CanAccept() always fails first — task is never accepted, Do() is never reached.

3. Do(): same column name bug in sectors_meta join

- INNER JOIN sectors_meta m ON mpd.sp_id = m.sp_id AND mpd.sector_number = m.sector_num
+ INNER JOIN sectors_meta m ON mpd.sp_id = m.sp_id AND mpd.sector_num = m.sector_num

4. CanAccept: wrong sector_filetype constant

- l.sector_filetype = 4
+ l.sector_filetype = 1

Restored to FTUnsealed (1), which was the original value before #855. The task reads piece data via ReadPiece() which requires unsealed sector data, not cache. The existing panic guard (storiface.FTUnsealed != 1) on line 116 confirms the original intent. Changed to 4 (FTCache) during the #855 rewrite by copying the pattern from task_treed.go (which correctly uses FTCache for its own purposes).

Verification

Every other query against market_piece_deal in the codebase correctly uses sector_num:

  • tasks/indexing/task_check_indexes.go
  • lib/cachedreader/cachedreader.go
  • web/api/webrpc/market.go

Full column-by-column audit against schema definitions:

  • 20260211-fix-raw-size-table.sql (market_fix_raw_size)
  • 20240731-market-migration.sql (market_piece_deal)
  • 20240425-sector_meta.sql (sectors_meta)
  • 20230712-sector_index.sql (sector_location, storage_path)

All 7 SQL queries in the file verified.

@Reiers Reiers requested a review from a team as a code owner February 19, 2026 19:55
@Reiers Reiers force-pushed the fix/rawsize-join-bug branch from 277bc49 to bbdc4cc Compare February 19, 2026 19:59
@Reiers Reiers changed the title fix: FixRawSize CanAccept join references wrong table alias fix: FixRawSize SQL column name and join bugs Feb 19, 2026
Four SQL bugs in task_fix_rawSize.go, all introduced in #855:

1. CanAccept: mpd.miner_id → l.miner_id
   market_piece_deal has no miner_id column; join should reference
   sector_location.miner_id.
   Error: column mpd.miner_id does not exist (SQLSTATE 42703)

2. Do + CanAccept: mpd.sector_number → mpd.sector_num
   market_piece_deal column is sector_num, not sector_number.
   Masked in Do() because CanAccept always fails first.

3. Do: same sector_number fix in sectors_meta join condition.

4. CanAccept: sector_filetype = 4 → sector_filetype = 1
   Restored to FTUnsealed (original value before #855). The task reads
   piece data via ReadPiece() which requires unsealed sector data, not
   cache. The existing panic guard (storiface.FTUnsealed != 1) confirms
   the original intent. Changed to 4 (FTCache) during the #855 rewrite
   by copying the pattern from task_treed.go (which correctly uses
   FTCache for its own purposes).

Every other query against market_piece_deal in the codebase correctly
uses sector_num (task_check_indexes.go, cachedreader.go, market.go).

Full column-by-column audit performed against schema definitions in:
  20260211-fix-raw-size-table.sql, 20240731-market-migration.sql,
  20240425-sector_meta.sql, 20230712-sector_index.sql.

All 7 queries in the file verified.

Follow-up to #1035 (array cast fix).
@Reiers Reiers force-pushed the fix/rawsize-join-bug branch from bbdc4cc to 0db0e95 Compare February 19, 2026 20:02
@Reiers Reiers changed the title fix: FixRawSize SQL column name and join bugs fix: FixRawSize SQL column name, join, and filetype bugs Feb 19, 2026
@snadrus snadrus merged commit 539cf29 into main Feb 19, 2026
22 checks passed
@snadrus snadrus deleted the fix/rawsize-join-bug branch February 19, 2026 21:56
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