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:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user