diff --git a/backends/postgres/postgres_backend.go b/backends/postgres/postgres_backend.go index 4b2aa3d..9c9bb80 100644 --- a/backends/postgres/postgres_backend.go +++ b/backends/postgres/postgres_backend.go @@ -21,6 +21,7 @@ import ( "github.com/iancoleman/strcase" "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v5" + "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgxpool" "github.com/jsuar/go-cron-descriptor/pkg/crondescriptor" @@ -672,17 +673,17 @@ func (p *PgBackend) updateJob(ctx context.Context, jobErr error) (err error) { status := internal.JobStatusProcessed errMsg := "" - if jobErr != nil { - p.logger.Error("job failed", slog.Any("job_error", jobErr)) - status = internal.JobStatusFailed - errMsg = jobErr.Error() - } - var job *jobs.Job if job, err = jobs.FromContext(ctx); err != nil { return fmt.Errorf("error getting job from context: %w", err) } + if jobErr != nil { + p.logger.Error("job failed", slog.Int64("job_id", job.ID), slog.Any("job_error", jobErr)) + status = internal.JobStatusFailed + errMsg = jobErr.Error() + } + var tx pgx.Tx if tx, err = txFromContext(ctx); err != nil { return fmt.Errorf("error getting tx from context: %w", err) diff --git a/go.mod b/go.mod index a032414..62c2235 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/hibiken/asynq v0.24.1 github.com/iancoleman/strcase v0.3.0 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa - github.com/jackc/pgx/v5 v5.5.4 + github.com/jackc/pgx/v5 v5.6.0 github.com/jsuar/go-cron-descriptor v0.1.0 github.com/pkg/errors v0.9.1 github.com/robfig/cron v1.2.0 diff --git a/go.sum b/go.sum index 06deffd..4813819 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8= -github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jsuar/go-cron-descriptor v0.1.0 h1:Q97ujk+/xhcz1lA9nmUMq750FZV7RlV23TNyMB74xkQ= diff --git a/gomod2nix.toml b/gomod2nix.toml index b071390..b53cc17 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -44,8 +44,8 @@ schema = 3 version = "v0.0.0-20221227161230-091c0ba34f0a" hash = "sha256-rBtUw15WPPDp2eulHXH5e2zCIed1OPFYwlCpgDOnGRM=" [mod."github.com/jackc/pgx/v5"] - version = "v5.5.4" - hash = "sha256-T4nYUbDDiyN7v6BRhEkPJ9slatzUMrEyoGAyjfK9syI=" + version = "v5.6.0" + hash = "sha256-6Tx7UF6gWc4e572x6wBDLghoe0Inhef0cH2Fq5I8fX4=" [mod."github.com/jackc/puddle/v2"] version = "v2.2.1" hash = "sha256-Edf8SLT/8l+xfHm9IjUGxs1MHtic2VgRyfqb6OzGA9k="