Skip to content

feat: add lock name to SQL to trace the source#25

Closed
dkubb wants to merge 4 commits intoBetterment:mainfrom
dkubb:dkubb/main/add/lock-name-to-sql
Closed

feat: add lock name to SQL to trace the source#25
dkubb wants to merge 4 commits intoBetterment:mainfrom
dkubb:dkubb/main/add/lock-name-to-sql

Conversation

@dkubb
Copy link
Contributor

@dkubb dkubb commented Jul 17, 2025

Summary

Description

This branch adds the lock name to the SQL to allow the original lock name to be traced.

@dkubb dkubb force-pushed the dkubb/main/add/lock-name-to-sql branch 2 times, most recently from f2ba5df to c9c149a Compare July 17, 2025 19:42
@dkubb
Copy link
Contributor Author

dkubb commented Jul 17, 2025

question: @samandmoore not sure what the process is for PRs in this repo: Should I also bump the WithTransactionalLock::VERSION as part of this change?

@samandmoore
Copy link
Member

good question. i think yes. it's easiest to bump the version and update the changelog here and then i can merge it and do a release. i can do this

bumping a patch version since this is a backward compatible tiny change
Widget.with_transactional_lock('Widget.first') do
Widget.first.update!(name: 'once')

assert_pg_lock_comment do
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason you're preferring to wrap this around every test instead of making a single separate test case for this assertion?

Copy link
Contributor Author

@dkubb dkubb Aug 5, 2025

Choose a reason for hiding this comment

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

comment: That's a good question. The tests weren't structured in a way that made the preferred layout obvious to me. They are very special cased to exercise the uncontended and contended contexts. I couldn't see any familiar patterns in the code for which one way would be better than another, so I opted to run it all the time.

In retrospect I still think it's something you'd want to run in the contended and uncontended contexts because the side-effects (i.e. the addition of the comment) needs to be asserted for both cases. There's not really a good way to hook into both of the contexts. Maybe I could've done it with an around block so it doesn't need to be explicit but I'm not sure if that would be better or not.

@samandmoore
Copy link
Member

closing in to pull in after bigger change on main

samandmoore added a commit that referenced this pull request Aug 7, 2025
rebasing and tweaking #25 by @dkubb

/no-platform

---------

Co-authored-by: Dan Kubb <github@dan.kubb.ca>
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.

2 participants