Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix error on terminating experiments on restart #8837

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion master/internal/db/postgres_experiments.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ func (db *PgDB) TerminateExperimentInRestart(id int, state model.State) error {

// Terminate trials.
if _, err = tx.Exec(
`UPDATE trials SET state=$1, end_time=$2 WHERE experiment_id=$3 and end_time IS NULL`,
`UPDATE runs SET state=$1, end_time=$2 WHERE experiment_id=$3 and end_time IS NULL`,
state,
now,
id,
Expand Down
28 changes: 28 additions & 0 deletions master/internal/db/postgres_experiments_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,34 @@ func TestExperimentByIDs(t *testing.T) {
}
}

func TestTerminateExperimentInRestart(t *testing.T) {
ctx := context.Background()

require.NoError(t, etc.SetRootPath(RootFromDB))
db := MustResolveTestPostgres(t)
MustMigrateTestPostgres(t, db, MigrationsFromDB)
user := RequireMockUser(t, db)

exp := RequireMockExperiment(t, db, user)
trial0, _ := RequireMockTrial(t, db, exp)
trial1, _ := RequireMockTrial(t, db, exp)

require.NoError(t, db.TerminateExperimentInRestart(exp.ID, model.ErrorState))

actualExp, err := ExperimentByID(ctx, exp.ID)
require.NoError(t, err)
require.Equal(t, actualExp.State, model.ErrorState)
require.NotNil(t, actualExp.EndTime)
require.Nil(t, actualExp.Progress)

for _, trialID := range []int{trial0.ID, trial1.ID} {
actualTrial, err := TrialByID(ctx, trialID)
require.NoError(t, err)
require.Equal(t, actualTrial.State, model.ErrorState)
require.NotNil(t, actualTrial.EndTime)
}
}

func TestExperimentsTrialAndTaskIDs(t *testing.T) {
ctx := context.Background()

Expand Down
Loading