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

Fix possible server startup concurrency #108

Merged
merged 1 commit into from Aug 26, 2019

Conversation

@andrehp
Copy link
Contributor

commented Aug 23, 2019

The fix is done by initializing the service discovery
module as the last one, ensuring other modules have already
initialized correctly.

Sample of the crash that this commit aims to fix, caused by trying to access the bindingStorage client before it is initialized:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xb5c703]

goroutine 1683 [running]:
github.com/topfreegames/pitaya/modules.(*ETCDBindingStorage).GetUserFrontendID(0xc000152420, 0xc00051f0e0, 0x24, 0x11d5eaa, 0x9, 0x0, 0x1d22320, 0xc00203ec00, 0x85cbb5)
	/home/jenkins/golang/pkg/mod/github.com/topfreegames/pitaya@v0.14.6/modules/binding_storage.go:88 +0x103
github.com/topfreegames/pitaya/cluster.(*GRPCClient).SendPush(0xc000132a80, 0xc00051f0e0, 0x24, 0xc001dfbe40, 0xc0017cc300, 0x0, 0x0)
	/home/jenkins/golang/pkg/mod/github.com/topfreegames/pitaya@v0.14.6/cluster/grpc_rpc_client.go:213 +0x22b
github.com/topfreegames/pitaya.SendPushToUsers(0x1203ce1, 0x2a, 0x11807e0, 0xc001d315f0, 0xc00025da30, 0x1, 0x1, 0x11d5eaa, 0x9, 0x0, ...)
	/home/jenkins/golang/pkg/mod/github.com/topfreegames/pitaya@v0.14.6/push.go:60 +0x5a1
git.topfreegames.com/topfreegames/game-pitaya/servers/metagame/handler.sendOnlinePush(0x13b05a0, 0xc0003bed20, 0xc44725d3602227a9, 0xd62961a89305a9bf, 0xc001944620, 0x1, 0x1)
	/home/jenkins/golang/src/git.topfreegames.com/topfreegames/game-pitaya/servers/metagame/handler/friend.go:254 +0x2b6
created by git.topfreegames.com/topfreegames/game-pitaya/servers/metagame/handler.(*Friend).GetRelationships
	/home/jenkins/golang/src/git.topfreegames.com/topfreegames/game-pitaya/servers/metagame/handler/friend.go:235 +0x262
Fix possible server startup concurrency
The fix is done by initializing the service discovery
module as the last one, ensuring other modules have already
initialized correctly

@andrehp andrehp requested review from Henrod and felipejfc Aug 23, 2019

@coveralls

This comment has been minimized.

Copy link

commented Aug 23, 2019

Pull Request Test Coverage Report for Build 924

  • 4 of 6 (66.67%) changed or added relevant lines in 2 files are covered.
  • 8 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.08%) to 68.605%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app.go 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
agent/agent.go 2 81.4%
app.go 2 81.44%
cluster/etcd_service_discovery.go 4 79.66%
Totals Coverage Status
Change from base Build 920: 0.08%
Covered Lines: 4401
Relevant Lines: 6415

💛 - Coveralls
@felipejfc

This comment has been minimized.

Copy link
Contributor

commented Aug 24, 2019

good job @andrehp
LGTM

@andrehp andrehp merged commit d7bd48f into master Aug 26, 2019

4 checks passed

GolangCI No issues found!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.08%) to 68.605%
Details

@andrehp andrehp deleted the fix/sd_concurrency branch Aug 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.