Closed pixelspark closed 3 weeks ago
It appears from the outside the worker thread somehow locks the database, or uses the same database connection as the web UI?
@pixelspark let me know if the PR alleviates the problem...
Weirdly I am now getting this error:
{"time":"2024-09-01T14:48:44.080766679Z","level":"ERROR","msg":"SQL logic error: ambiguous column name: route_segments.dirty (1)","app":"workout-tracker","version":"master","sha":"a95dd20866dac422de9d84f43f760dfb31df38fb","module":"database","error":"SQL logic error: ambiguous column name: route_segments.dirty (1)","query":"UPDATE `route_segments` SET `updated_at`=\"2024-09-01 14:48:44.08\" FROM `route_segments` WHERE `route_segments`.`dirty` = true AND `route_segments`.`deleted_at` IS NULL AND `id` = 6","duration":409115,"rows":0,"file":"/app/pkg/database/route_segments.go:177"}
{"time":"2024-09-01T14:48:44.080789317Z","level":"ERROR","msg":"Worker error saving route segment: SQL logic error: ambiguous column name: route_segments.dirty (1)","app":"workout-tracker","version":"master","sha":"a95dd20866dac422de9d84f43f760dfb31df38fb","module":"app","module":"worker"}
{"time":"2024-09-01T14:48:44.080801886Z","level":"ERROR","msg":"Worker errors during matching: SQL logic error: ambiguous column name: route_segments.dirty (1)\nSQL logic error: ambiguous column name: route_segments.dirty (1)","app":"workout-tracker","version":"master","sha":"a95dd20866dac422de9d84f43f760dfb31df38fb","module":"app","module":"worker"}
This seems to happen here:
for _, rs := range routeSegments {
rs.Dirty = false
if err := rs.Save(tx); err != nil {
errs = errors.Join(errs, err)
l.Error("Worker error saving route segment: " + err.Error())
}
}
This looks like gorm generating a query that is not quite right:
UPDATE `route_segments` SET `updated_at`=\"2024-09-01 14:48:44.08\" FROM `route_segments` WHERE `route_segments`.`dirty` = true AND `route_segments`.`deleted_at` IS NULL AND `id` = 6
The fix seems to be easy however: https://github.com/jovandeginste/workout-tracker/compare/master...pixelspark:workout-tracker:feature/batch-matching
Can you re-merge the PR?
I created a new PR and merged it.
Excellent! I haven't yet managed to make the app hang this time, definitely an improvement!
Hi,
After upgrading to master on my 'production' system (which has a few hundred workouts) I tried to use the route segments feature. After creating the first workout, it apparently starts a matching process in the background. When I try to create another segment however, the whole server appears to freeze. Relevant log messages:
It's also reporting a few slow queries... and I can see why they would be slow: