Skip to content

Commit e2d9c9a

Browse files
committed
fix error
1 parent 70ed4bf commit e2d9c9a

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

harmony/harmonydb/sql/20240823-ipni.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ CREATE TABLE ipni_task (
105105
reg_seal_proof INT NOT NULL,
106106
sector_offset BIGINT,
107107

108-
context_id BYTEA NOT NULL PRIMARY KEY,
108+
context_id BYTEA NOT NULL,
109109
is_rm BOOLEAN NOT NULL,
110110

111111
provider TEXT NOT NULL,

lib/paths/local_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/require"
1212

1313
"github.com/filecoin-project/curio/harmony/harmonydb"
14-
storiface "github.com/filecoin-project/curio/lib/storiface"
14+
"github.com/filecoin-project/curio/lib/storiface"
1515

1616
"github.com/filecoin-project/lotus/storage/sealer/fsutil"
1717
)
@@ -82,7 +82,9 @@ func TestLocalStorage(t *testing.T) {
8282
root: root,
8383
}
8484

85-
db, err := harmonydb.NewFromConfigWithITestID(t, "testlocalstorage")
85+
sharedITestID := harmonydb.ITestNewID()
86+
87+
db, err := harmonydb.NewFromConfigWithITestID(t, sharedITestID)
8688
require.NoError(t, err)
8789

8890
index := NewDBIndex(nil, db)

lib/paths/remote_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/filecoin-project/curio/lib/partialfile"
2626
"github.com/filecoin-project/curio/lib/paths"
2727
"github.com/filecoin-project/curio/lib/paths/mocks"
28-
storiface "github.com/filecoin-project/curio/lib/storiface"
28+
"github.com/filecoin-project/curio/lib/storiface"
2929
)
3030

3131
const metaFile = "sectorstore.json"
@@ -59,7 +59,9 @@ func createTestStorage(t *testing.T, p string, seal bool, att ...*paths.Local) s
5959
func TestMoveShared(t *testing.T) {
6060
logging.SetAllLoggers(logging.LevelDebug)
6161

62-
db, err := harmonydb.NewFromConfigWithITestID(t, "testlocalstorage")
62+
sharedITestID := harmonydb.ITestNewID()
63+
64+
db, err := harmonydb.NewFromConfigWithITestID(t, sharedITestID)
6365
require.NoError(t, err)
6466

6567
index := paths.NewDBIndex(nil, db)

tasks/indexing/task_indexing.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,25 @@ func (i *IndexingTask) recordCompletion(ctx context.Context, task itask, taskID
214214
return xerrors.Errorf("failed to update piece metadata and piece deal for deal %s: %w", task.UUID, err)
215215
}
216216

217-
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = TRUE, complete = TRUE WHERE uuid = $1`, task.UUID)
218-
if err != nil {
219-
return xerrors.Errorf("store indexing success: updating pipeline: %w", err)
220-
}
221-
if n != 1 {
222-
return xerrors.Errorf("store indexing success: updated %d rows", n)
217+
// If IPNI is disabled then mark deal as complete otherwise just mark as indexed
218+
if i.cfg.Market.StorageMarketConfig.IPNI.Disable {
219+
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = TRUE, complete = TRUE WHERE uuid = $1`, task.UUID)
220+
if err != nil {
221+
return xerrors.Errorf("store indexing success: updating pipeline: %w", err)
222+
}
223+
if n != 1 {
224+
return xerrors.Errorf("store indexing success: updated %d rows", n)
225+
}
226+
} else {
227+
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = TRUE WHERE uuid = $1`, task.UUID)
228+
if err != nil {
229+
return xerrors.Errorf("store indexing success: updating pipeline: %w", err)
230+
}
231+
if n != 1 {
232+
return xerrors.Errorf("store indexing success: updated %d rows", n)
233+
}
223234
}
235+
224236
return nil
225237
}
226238

tasks/indexing/task_ipni.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ func (I *IPNITask) TypeDetails() harmonytask.TaskTypeDetails {
317317

318318
func (I *IPNITask) schedule(ctx context.Context, taskFunc harmonytask.AddTaskFunc) error {
319319
// If IPNI is disabled then don't schedule any tasks
320+
// Deals should already be marked as complete by task_indexing
321+
// This check is to cover any edge case
320322
if I.cfg.Market.StorageMarketConfig.IPNI.Disable {
321323
return nil
322324
}

0 commit comments

Comments
 (0)