Skip to content

Dependency updates and cleanup.#13

Merged
slr71 merged 9 commits into
cyverse-de:mainfrom
slr71:main
May 15, 2026
Merged

Dependency updates and cleanup.#13
slr71 merged 9 commits into
cyverse-de:mainfrom
slr71:main

Conversation

@slr71
Copy link
Copy Markdown
Member

@slr71 slr71 commented May 14, 2026

No description provided.

slr71 and others added 6 commits May 14, 2026 16:00
Updated all direct and indirect dependencies via `go get -u ./...` and `go mod tidy`.

Notable changes:
- github.com/cyverse-de/configurate: pseudo-version => v0.0.0-20260305004742-e3d1c1150f1e
- github.com/cyverse-de/go-mod/otelutils: v0.0.3 => v0.0.6
- github.com/lib/pq: v1.10.9 => v1.12.3
- github.com/sirupsen/logrus: v1.9.3 => v1.9.4
- github.com/spf13/viper: v1.18.2 => v1.21.0
- go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux: v0.49.0 => v0.68.0
- golang.org/x/sys: v0.42.0 => v0.44.0
- google.golang.org/grpc: v1.59.0 => v1.81.1
- Various other indirect dep upgrades (protobuf, genproto, etc.)

mapstructure migration: NOT triggered. mitchellh/mapstructure v1.5.0 remains
resolvable after go mod tidy; go-viper/mapstructure/v2 was added as an indirect
dep (pulled in by viper v1.21.0) but the direct import in statuschangetimeout.go
was not changed since the build succeeds without it.

The otel Jaeger exporter (go.opentelemetry.io/otel/exporters/jaeger) was removed
from go.mod by go mod tidy as it is no longer required by the updated otelutils
module; OTLP/gRPC exporter was added in its place as a new indirect dep.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@johnworth
Copy link
Copy Markdown

Code review

Found 1 issue:

  1. The new logutil.LogIfError helper logs every non-nil error, but the codebase uses the defer tx.Rollback() idiom across handlers that subsequently call tx.Commit(). After a successful commit, the deferred rollback returns sql.ErrTxDone, which the helper now logs at error level — so every successful write will emit a spurious error log. The prior // nolint:errcheck silently dropped this.

Helper (logs any non-nil error, no filter for sql.ErrTxDone):

https://github.com/cyverse-de/async-tasks/blob/5902e4873e267b647b9285c493a88e0e29db88ce/internal/logutil/logutil.go#L11-L17

Representative call site — DeleteByIdRequest defers a rollback (L120) then commits (L139); on success the deferred rollback fires and logs sql.ErrTxDone:

async-tasks/app.go

Lines 119 to 140 in 5902e48

}
defer logutil.LogIfError(log, tx.Rollback)
task, err := tx.GetTask(ctx, id, true)
if err != nil {
errored(writer, err.Error())
return
}
if task.ID == "" {
notFound(writer, "not found")
return
}
err = tx.DeleteTask(ctx, id)
if err != nil {
errored(writer, err.Error())
return
}
err = tx.Commit()
if err != nil {

Same pattern affects CreateTaskRequest, AddStatusRequest, AddBehaviorRequest in app.go, finishTask/deleteTask in updater.go, and processSingleTask. In Processor there is an additional explicit rollback after GetTasksByFilter followed by the deferred one, so even the read-only path logs sql.ErrTxDone on every tick:

}
defer logutil.LogIfError(log, tx.Rollback)
tasks, err := tx.GetTasksByFilter(ctx, filter, "end_date IS NOT NULL DESC")
if err != nil {
return err
}
logutil.LogIfError(log, tx.Rollback)

Suggested fix: have LogIfError (or a dedicated RollbackUnlessCommitted-style helper) skip sql.ErrTxDone, or track a committed flag and only roll back when the commit didn't happen.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@johnworth
Copy link
Copy Markdown

Re-review of 23567e9

The fix resolves the spurious-error-log issue I flagged. errorsToIgnore containing sql.ErrTxDone covers all the call sites I noted: the defer ... tx.Rollback + tx.Commit pattern in app.go/updater.go, and the explicit-then-deferred rollback pair in Processor. database/sql.Tx.Rollback() returns sql.ErrTxDone as a bare sentinel (no wrapping), so the map's value-equality lookup matches correctly for every affected path. Tests pass locally and the table-driven test auto-extends to any future entries in errorsToIgnore.

Optional nit, not a blocker: errors.Is(err, sql.ErrTxDone) is the more idiomatic check and would still match if anything ever wrapped the sentinel — switching to a slices/for-loop with errors.Is would future-proof it. The current map works for today's call sites either way.

LGTM.

🤖 Generated with Claude Code

@slr71
Copy link
Copy Markdown
Member Author

slr71 commented May 15, 2026

Good catch. I found myself wondering if I should make the errors to skip customizable for different cases, so I'll do that now.

Copy link
Copy Markdown

@johnworth johnworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slr71
Copy link
Copy Markdown
Member Author

slr71 commented May 15, 2026

Thanks for the reviews. 👍

@slr71 slr71 merged commit 76ee594 into cyverse-de:main May 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants