Skip to content

Commit 63c1892

Browse files
committed
mk20 GC
1 parent 7f9d6fe commit 63c1892

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

harmony/harmonydb/sql/20250505-market_mk20.sql

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ CREATE TABLE market_mk20_offline_urls (
154154
url TEXT NOT NULL,
155155
headers jsonb NOT NULL DEFAULT '{}',
156156
raw_size BIGINT NOT NULL,
157-
PRIMARY KEY (id, piece_cid, piece_size),
158-
CONSTRAINT market_mk20_offline_urls_id_fk FOREIGN KEY (id)
159-
REFERENCES market_mk20_pipeline (id)
160-
ON DELETE CASCADE
157+
PRIMARY KEY (id, piece_cid, piece_size)
161158
);
162159

163160
CREATE TABLE market_mk20_products (

tasks/gc/pipeline_meta_gc.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,9 @@ func (s *PipelineGC) cleanupUpgrade() error {
158158
}
159159

160160
func (s *PipelineGC) cleanupMK12DealPipeline() error {
161-
// Remove market_mk12_deal_pipeline entries where:
162-
// sealed is true and indexed is true
163161
ctx := context.Background()
164162

165-
// Execute the query
166-
// NOTE: pipelines can be complete before indexing finishes in case of reindexing pipeline tasks (created in CheckIndex task)
167-
_, err := s.db.Exec(ctx, `DELETE FROM market_mk12_deal_pipeline WHERE (should_index = FALSE OR indexed = TRUE) AND complete = TRUE;`)
163+
_, err := s.db.Exec(ctx, `DELETE FROM market_mk12_deal_pipeline WHERE complete = TRUE;`)
168164
if err != nil {
169165
return xerrors.Errorf("failed to clean up sealed deals: %w", err)
170166
}
@@ -177,6 +173,24 @@ func (s *PipelineGC) cleanupMK12DealPipeline() error {
177173
return nil
178174
}
179175

176+
func (s *PipelineGC) cleanupMK20DealPipeline() error {
177+
ctx := context.Background()
178+
179+
_, err := s.db.Exec(ctx, `DELETE FROM market_mk20_offline_urls
180+
WHERE id IN (
181+
SELECT id FROM market_mk20_pipeline WHERE complete = TRUE
182+
);
183+
184+
DELETE FROM market_mk20_pipeline
185+
WHERE complete = TRUE;
186+
`)
187+
if err != nil {
188+
return xerrors.Errorf("failed to clean up sealed deals: %w", err)
189+
}
190+
191+
return nil
192+
}
193+
180194
func (s *PipelineGC) cleanupUnseal() error {
181195
// Remove sectors_unseal_pipeline entries where:
182196
// after_unseal_sdr is true

0 commit comments

Comments
 (0)