Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed: fix blocking Close before gRPC server start #7848

Merged
merged 1 commit into from
May 2, 2017

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented May 1, 2017

If 'StartEtcd' returns before starting gRPC server
(e.g. mismatch snapshot, misconfiguration),
receiving from grpcServerC blocks forever. This patch
just closes the channel to not block on grpcServerC,
and proceeds to next stop operations in Close.

This was masking the issues in #7834

@xiang90
Copy link
Contributor

xiang90 commented May 1, 2017

can we add a test for it?

@gyuho gyuho added the WIP label May 1, 2017
@@ -83,6 +83,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come we don't close grpcServerC at here?

embed/etcd.go Outdated
// errored before starting gRPC server for serveCtx.grpcServerC
for _, sctx := range e.sctxs {
close(sctx.grpcServerC)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a helper function to close sctxs? I see that this code is called twice already.

embed/etcd.go Outdated
@@ -83,6 +83,10 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
return
}
if e.sctxs, err = startClientListeners(cfg); err != nil {
// errored before starting gRPC server for serveCtx.grpcServerC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just put these in the defer?

defer func() {
    if e == nil || err == nil {
        return
    }
    if !serving {
        for _, sctx := range e.sctxs { close(sctx.grpcServerC)
    }
    e.Close()
    e = nil
}()

@gyuho gyuho force-pushed the close-grpcc branch 2 times, most recently from c791d13 to 9cdee03 Compare May 1, 2017 22:59
@gyuho gyuho removed the WIP label May 1, 2017
@gyuho
Copy link
Contributor Author

gyuho commented May 1, 2017

PTLA.
Test case is added, on the same code path.

@heyitsanthony
Copy link
Contributor

lgtm thanks

@fanminshi
Copy link
Member

lgtm

If 'StartEtcd' returns before starting gRPC server
(e.g. mismatch snapshot, misconfiguration),
receiving from grpcServerC blocks forever. This patch
just closes the channel to not block on grpcServerC,
and proceeds to next stop operations in Close.

This was masking the issues in etcd-io#7834

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
@gyuho gyuho merged commit fdf445b into etcd-io:master May 2, 2017
@gyuho gyuho deleted the close-grpcc branch May 2, 2017 01:44
@codecov-io
Copy link

codecov-io commented May 2, 2017

Codecov Report

Merging #7848 into master will increase coverage by 0.46%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #7848      +/-   ##
=========================================
+ Coverage   75.54%     76%   +0.46%     
=========================================
  Files         332     332              
  Lines       26177   26183       +6     
=========================================
+ Hits        19776   19901     +125     
+ Misses       4970    4857     -113     
+ Partials     1431    1425       -6
Impacted Files Coverage Δ
embed/etcd.go 71.42% <100%> (+3.53%) ⬆️
etcdserver/api/v3election/election.go 64.7% <0%> (-2.95%) ⬇️
pkg/transport/timeout_conn.go 80% <0%> (ø) ⬆️
etcdserver/server.go 80.52% <0%> (+0.57%) ⬆️
auth/store.go 83.1% <0%> (+0.58%) ⬆️
proxy/grpcproxy/lease.go 89.42% <0%> (+0.96%) ⬆️
rafthttp/transport.go 83.05% <0%> (+1.12%) ⬆️
rafthttp/peer.go 91.6% <0%> (+1.52%) ⬆️
proxy/grpcproxy/watch.go 94.44% <0%> (+3.47%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1720b7...b0e9d24. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants