Skip to content

Commit b31c3b5

Browse files
frasertweedaleedewata
authored andcommitted
RHCS-6003: Revert "Use synchronous LWCA KeyRetriever"
This reverts commit 451cc4d. Making LWCA key retrieval causes hangs on servers to which lightweight CA keys have not yet been successfully retrieved (e.g. due to transient issue). The problem arises as follows: 1. AuthorityMonitor thread observes creation of new CA via LDAP replication. 2. AuthorityMonitor initialises the CertificateAuthority object. 3. At SigningUnit initialisation, observes absence of keys and initiates key retrieval (synchronously) 4. Key retrieval fails; enters exponential backoff loop 5. CertificateAuthority initialisation is stuck in key retrieval backoff loop; it does not get added to the CA registry. 6. Separately, `AuthorityService` / `AuthorityServlet` receives a request related to the CA (e.g. retrieve authority info or cert chain). 7. Lookup via `AuthorityRepository` locates the data, but no `CertificateAuthority` object exists for it. Starts the initialisation process afresh (and hangs). 8. Rinse, repeat. Eventually even unrelated functions can be impacted due to resource starvation (e.g. no available HTTP worker threads). The fix is to revert to asynchronous key retrieval. Happily, the earlier patch reverted cleanly. The change to synchronous retrieval was intended to resolve an [issue] with nondeterministic failures when creating many LWCAs in rapid succession. Further investigation of that issue hints that the issue may be resource limit related because LDAP connection failures affect both LWCA creation and key retrieval. We may need to do further investigation and experimentation to solve that issue in a different way. [issue]: dogtagpki#4677. Fixes: https://issues.redhat.com/browse/RHCS-6003
1 parent 952fb6f commit b31c3b5

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

base/ca/src/main/java/com/netscape/ca/CertificateAuthority.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public class CertificateAuthority extends Subsystem implements IAuthority, IOCSP
219219
private ResponderID mResponderIDByName = null;
220220
private ResponderID mResponderIDByHash = null;
221221

222-
private KeyRetrieverRunner keyRetrieverRunner;
222+
private Thread keyRetrieverThread;
223223

224224
/**
225225
* Internal constants
@@ -649,7 +649,7 @@ public synchronized void startKeyRetriever() throws EBaseException {
649649
return;
650650
}
651651

652-
if (keyRetrieverRunner != null) {
652+
if (keyRetrieverThread != null) {
653653
logger.info("CertificateAuthority: KeyRetriever already running for authority " + authorityID);
654654
return;
655655
}
@@ -687,16 +687,14 @@ public synchronized void startKeyRetriever() throws EBaseException {
687687
throw new EBaseException(e);
688688
}
689689

690-
// Use a synchronous KeyRetriever to ensure that the LWCA has
691-
// the signing key before it can be used.
692-
// https://github.com/dogtagpki/pki/issues/4677
690+
KeyRetrieverRunner runner = new KeyRetrieverRunner(keyRetriever, this);
693691

694-
keyRetrieverRunner = new KeyRetrieverRunner(keyRetriever, this);
695-
keyRetrieverRunner.run();
692+
keyRetrieverThread = new Thread(runner, "KeyRetriever-" + authorityID);
693+
keyRetrieverThread.start();
696694
}
697695

698696
public synchronized void removeKeyRetriever() {
699-
keyRetrieverRunner = null;
697+
keyRetrieverThread = null;
700698
}
701699

702700
public void initSigningUnits() throws Exception {

0 commit comments

Comments
 (0)