From b517db9f96bda1d517e14a7b90fb25b9eadd376c Mon Sep 17 00:00:00 2001 From: hamid ghaf Date: Thu, 30 Sep 2021 08:35:29 -0700 Subject: [PATCH 1/2] Fix a Deadlock on HA leadership transfer when standby was actively forwarding a request fixes GH #12601 --- vault/request_forwarding.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vault/request_forwarding.go b/vault/request_forwarding.go index bdd31a54f1733..b4a515f906c7e 100644 --- a/vault/request_forwarding.go +++ b/vault/request_forwarding.go @@ -329,6 +329,9 @@ func (c *Core) clearForwardingClients() { // ForwardRequest forwards a given request to the active node and returns the // response. func (c *Core) ForwardRequest(req *http.Request) (int, http.Header, []byte, error) { + // checking if the node is perfStandby here to avoid a deadlock between + // Core.stateLock and Core.requestForwardingConnectionLock + isPerfStandby := c.PerfStandby() c.requestForwardingConnectionLock.RLock() defer c.requestForwardingConnectionLock.RUnlock() @@ -372,7 +375,7 @@ func (c *Core) ForwardRequest(req *http.Request) (int, http.Header, []byte, erro // If we are a perf standby and the request was forwarded to the active node // we should attempt to wait for the WAL to ship to offer best effort read after // write guarantees - if c.PerfStandby() && resp.LastRemoteWal > 0 { + if isPerfStandby && resp.LastRemoteWal > 0 { WaitUntilWALShipped(req.Context(), c, resp.LastRemoteWal) } From 4f167da49d6a185da698a7970192c44bc72333a9 Mon Sep 17 00:00:00 2001 From: hamid ghaf Date: Thu, 30 Sep 2021 08:42:24 -0700 Subject: [PATCH 2/2] adding the changelog --- changelog/12691.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/12691.txt diff --git a/changelog/12691.txt b/changelog/12691.txt new file mode 100644 index 0000000000000..2a8efdc8001d6 --- /dev/null +++ b/changelog/12691.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fix a deadlock on HA leadership transfer +```