Skip to content

Commit 0710959

Browse files
committed
fix error
1 parent 65f3f47 commit 0710959

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
@@ -204,13 +204,25 @@ func (i *IndexingTask) recordCompletion(ctx context.Context, task itask, taskID
204204
return xerrors.Errorf("failed to update piece metadata and piece deal for deal %s: %w", task.UUID, err)
205205
}
206206

207-
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = TRUE, complete = TRUE WHERE uuid = $1`, task.UUID)
208-
if err != nil {
209-
return xerrors.Errorf("store indexing success: updating pipeline: %w", err)
210-
}
211-
if n != 1 {
212-
return xerrors.Errorf("store indexing success: updated %d rows", n)
207+
// If IPNI is disabled then mark deal as complete otherwise just mark as indexed
208+
if i.cfg.Market.StorageMarketConfig.IPNI.Disable {
209+
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = TRUE, complete = TRUE WHERE uuid = $1`, task.UUID)
210+
if err != nil {
211+
return xerrors.Errorf("store indexing success: updating pipeline: %w", err)
212+
}
213+
if n != 1 {
214+
return xerrors.Errorf("store indexing success: updated %d rows", n)
215+
}
216+
} else {
217+
n, err := i.db.Exec(ctx, `UPDATE market_mk12_deal_pipeline SET indexed = 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)
223+
}
213224
}
225+
214226
return nil
215227
}
216228

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)