diff --git a/internal/pgengine/bootstrap.go b/internal/pgengine/bootstrap.go index c393faf0..202031ae 100644 --- a/internal/pgengine/bootstrap.go +++ b/internal/pgengine/bootstrap.go @@ -67,8 +67,8 @@ type PgEngine struct { // where all IDs are the same across all running containers, e.g. 1 func (pge *PgEngine) Getsid() int32 { if pge.sid == 0 { - rand.Seed(time.Now().UnixNano()) - pge.sid = rand.Int31() + r := rand.New(rand.NewSource(time.Now().UnixNano())) + pge.sid = r.Int31() } return pge.sid } diff --git a/internal/pgengine/transaction.go b/internal/pgengine/transaction.go index 044a638b..d69338e4 100644 --- a/internal/pgengine/transaction.go +++ b/internal/pgengine/transaction.go @@ -172,7 +172,7 @@ func (pge *PgEngine) ExecuteSQLTask(ctx context.Context, tx pgx.Tx, task *ChainT } } - pge.SetCurrentTaskContext(ctx, execTx, task.TaskID) + pge.SetCurrentTaskContext(ctx, executor, task.TaskID) out, err = pge.ExecuteSQLCommand(ctx, executor, task.Script, paramValues) if err != nil && task.IgnoreError && !task.Autonomous { @@ -282,10 +282,10 @@ func (pge *PgEngine) ResetRole(ctx context.Context, tx pgx.Tx) { } // SetCurrentTaskContext - set the working transaction "pg_timetable.current_task_id" run-time parameter -func (pge *PgEngine) SetCurrentTaskContext(ctx context.Context, tx pgx.Tx, taskID int) { +func (pge *PgEngine) SetCurrentTaskContext(ctx context.Context, executor executor, taskID int) { l := log.GetLogger(ctx) l.Debug("Setting current task context to ", taskID) - _, err := tx.Exec(ctx, "SELECT set_config('pg_timetable.current_task_id', $1, true)", strconv.Itoa(taskID)) + _, err := executor.Exec(ctx, "SELECT set_config('pg_timetable.current_task_id', $1, true)", strconv.Itoa(taskID)) if err != nil { l.WithError(err).Error("Failed to set current task context", err) }