This is a really helpful gem! I'm the author of GoodJob, which uses a lot of Advisory Locks. This gem (and rails-pg-extras) came up in an issue (https://github.com/bensheldon/good_job/issues/480).
For Advisory Locks in all_locks, the age isn't accurate because the query is fetching the time of the connection's last query, not necessarily the age of the Advisory Lock itself:
I wanted to suggest renaming it, maybe last_activity_age (naming is hard).
And, I also wanted to suggest including pg_stat_activity.application_name in the output. I think that application_name can provide high-context information that would be really useful for understanding what's happening with the locks.
@bensheldon thanks for suggestion, sorry I missed it. I'd rather not changing names because it would require a major release. But would be great if you would submit a PR adding application_name to locks.
This is a really helpful gem! I'm the author of GoodJob, which uses a lot of Advisory Locks. This gem (and
rails-pg-extras
) came up in an issue (https://github.com/bensheldon/good_job/issues/480).For Advisory Locks in
all_locks
, theage
isn't accurate because the query is fetching the time of the connection's last query, not necessarily the age of the Advisory Lock itself:https://github.com/pawurb/ruby-pg-extras/blob/1e2a33ea27ecb955ad09b75d1a7dcd20c8f9bc10/lib/ruby-pg-extras/queries/all_locks.sql#L10
I wanted to suggest renaming it, maybe
last_activity_age
(naming is hard).And, I also wanted to suggest including
pg_stat_activity.application_name
in the output. I think thatapplication_name
can provide high-context information that would be really useful for understanding what's happening with the locks.