fix: resolve current entry unlocked in try_refresh_matching no-hint branch

Follow-up to the #62614 salvage: try_refresh_matching (added by the
#69843 salvage after this PR's base) calls self.current() while already
holding the now-locking non-reentrant pool lock — a guaranteed deadlock
that git merges silently (no textual conflict). Use _current_unlocked()
and cover the method in the no-deadlock test.
This commit is contained in:
Teknium
2026-07-23 08:36:11 -07:00
parent 769381fb3e
commit d9165d7a67
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -1907,7 +1907,7 @@ class CredentialPool:
None,
)
else:
entry = self.current() or self._select_unlocked(refresh=False)
entry = self._current_unlocked() or self._select_unlocked(refresh=False)
if entry is None:
return None
self._current_id = entry.id
+5
View File
@@ -3619,6 +3619,11 @@ class TestCredentialPoolQueryLocking:
assert pool.resolve_target("cred-1")[1] is not None
# (env may seed extra singleton entries; just assert ours are present)
assert {"cred-1", "cred-2"} <= {e.id for e in pool.entries()}
# try_refresh_matching's no-hint branch resolves the current entry
# while already holding the lock — must use _current_unlocked(), not
# current(), or it deadlocks on the non-reentrant lock (found when
# rebasing this fix over the #69843 salvage which added the method).
pool.try_refresh_matching()
@pytest.mark.parametrize(
"method,get_args",