Skip to content

Comments

fix: FixRawSize CanAccept SQL array cast typo#1035

Merged
snadrus merged 1 commit intomainfrom
fix/rawsize-sql-typo
Feb 19, 2026
Merged

fix: FixRawSize CanAccept SQL array cast typo#1035
snadrus merged 1 commit intomainfrom
fix/rawsize-sql-typo

Conversation

@Reiers
Copy link
Contributor

@Reiers Reiers commented Feb 19, 2026

Summary

Fix PostgreSQL syntax error in FixRawSize.CanAccept() that breaks all FixRawSize task acceptance on v1.27.3-rc1.

Problem

tasks/storage-market/task_fix_rawSize.go:134 has:

WHERE f.task_id = ANY($1::[]bigint)

::[] is Go slice syntax, not valid PostgreSQL. The [ after :: triggers:

ERROR: syntax error at or near "[" (SQLSTATE 42601)

This fires on every 3s poll cycle, rejecting all FixRawSize tasks. The scheduler (IAmBored, 60s interval) keeps creating entries up to its cap of 100, none of which can ever be accepted.

Fix

- WHERE f.task_id = ANY($1::[]bigint)
+ WHERE f.task_id = ANY($1::bigint[])

Every other CanAccept rewrite in the codebase already uses the correct ::bigint[] form.

Root Cause

Introduced in #855 (improve canAccept() performance) — all other files in that PR use the correct cast; this one was missed.

$1::[]bigint is Go slice syntax, not PostgreSQL. Should be $1::bigint[].

Causes 'syntax error at or near "["' on every poll cycle, preventing
all FixRawSize tasks from being accepted.

Introduced in #855 (improve canAccept() performance) — every other
CanAccept rewrite in that PR uses the correct ::bigint[] form; this
one file was missed.
@Reiers Reiers requested a review from a team as a code owner February 19, 2026 19:00
@snadrus snadrus merged commit 5171e6d into main Feb 19, 2026
41 of 42 checks passed
@snadrus snadrus deleted the fix/rawsize-sql-typo branch February 19, 2026 19:32
Reiers added a commit that referenced this pull request Feb 19, 2026
The sector_location join uses mpd.miner_id, but market_piece_deal has no
miner_id column — it should be l.miner_id (sector_location.miner_id).

This causes: column mpd.miner_id does not exist (SQLSTATE 42703)

Matches the join pattern used by every other CanAccept (e.g. task_treed.go):
  INNER JOIN sector_location l ON p.sp_id = l.miner_id AND ...

Follow-up to #1035. Both bugs introduced in #855.
Reiers added a commit that referenced this pull request Feb 19, 2026
Three SQL bugs in task_fix_rawSize.go, all using nonexistent columns:

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

2. Do (line 43): mpd.sector_number → mpd.sector_num
   market_piece_deal column is sector_num, not sector_number. This bug
   was masked because CanAccept always fails first (task never accepted),
   so Do() was never reached.

3. Do (line 46) and CanAccept (line 132): same sector_number → sector_num
   fix in join conditions against sectors_meta and sector_location.

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

Full column audit performed against schema definitions in:
  - 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 queries in the file verified column-by-column.

Follow-up to #1035 (array cast fix). All bugs introduced in #855.
Reiers added a commit that referenced this pull request 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).
snadrus pushed a commit that referenced this pull request 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).
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