Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
release-2.1: sqlmigrations: fix deadlock when ensuring privileges on Lease table #43633
Backport 1/1 commits from #43508.
This was a clean backport outside of the diff in 47f6af7#diff-87d7b6600bf9a8becfc52392f1cdd19d.
This commit resolves a deadlock that could occur when running the "ensure admin
This fix is needed in the release-19.1 branch and the release-2.1 branch. I'll
Release note (bug fix): Migrating the privileges on the system.lease
Closes #43497. This commit resolves a deadlock that could occur when running the "ensure admin role privileges in all descriptors" SQL migration. If the `system.lease` table needed to be migrated then the migration transaction would deadlock on an inner transaction that would query the system.lease table to enforce the "two leased versions" descriptor invariant. The solution to this is to use a timestamp from before the migration transaction to query the `system.lease` table, which ensures that the two transactions don't conflict. This fix is needed in the release-19.1 branch and the release-2.1 branch. I'll send a PR to patch the latter once this review is signed off on. Release note (bug fix): Migrating the privileges on the system.lease table no longer creates a deadlock during a cluster upgrade.