Skip to content

Commit 195e2c7

Browse files
authored
Merge pull request #120 from afking/fix-singlenn
Fix rpc.resolveConnection() deadlock
2 parents 80906ea + 3a06ea5 commit 195e2c7

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

rpc/namenode.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ func (c *NamenodeConnection) resolveConnection() error {
151151
}
152152

153153
for _, host := range c.hostList {
154-
if c.host == host {
155-
continue
156-
}
157-
158154
if host.lastErrorAt.After(time.Now().Add(-backoffDuration)) {
159155
continue
160156
}

rpc/namenode_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package rpc
2+
3+
import (
4+
"io"
5+
"testing"
6+
"time"
7+
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestNamenodeConnection_resolveConnection(t *testing.T) {
12+
conn := getNamenode(t)
13+
conn.markFailure(io.EOF)
14+
15+
assert.Error(t, conn.resolveConnection())
16+
conn.host.lastErrorAt = time.Now().Add(-backoffDuration)
17+
assert.NoError(t, conn.resolveConnection())
18+
cachedNamenode = nil
19+
}

0 commit comments

Comments
 (0)