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

Nil reference on subscription dropped #32

Closed
kmacmcfarlane opened this issue Oct 2, 2019 · 3 comments
Closed

Nil reference on subscription dropped #32

kmacmcfarlane opened this issue Oct 2, 2019 · 3 comments

Comments

@kmacmcfarlane
Copy link

I have an application that is connecting to event store and listening on a persistent subscription. I have observed a failure mode where the subscription seems to "hang". When I look at the event store web UI, I can see my application is connected but the status icon is red, and the current event number is less than the known event number.

Trying to get the application to re-connect, I tried updating the persistent subscription in the event store UI without changing any of the values. As expected, this triggered the eventstore to close any open connections, but the client code in your library experiences a panic while trying to call my SubscriptionDroppedHandler. I believe the issue stems from dto.Reason being a nill pointer.

The questions remain, what causes the client to get hung up and stop processing messages? Also, why is the dto.Reason field nil when handling the subscription dropping?

Attached is my stack trace the application throws.

[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x74a1bb]
goroutine 21 [running]:
foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions.(*connectToPersistentSubscription).inspectPackage(0xc00007db90, 0xc0000a0140, 0x1ffffff, 0xa1fe50, 0xc0001a5b78, 0x53fa50)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions/connect_to_persistent_subscription.go:104 +0x49b
foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions.(*connectToPersistentSubscription).inspectPackage-fm(0xc0000a0140, 0x75c501, 0x414f84, 0x7f4fb0e044c0, 0x414ecf)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions/connect_to_persistent_subscription.go:37 +0x34
foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions.(*subscriptionBase).InspectPackage(0xc000088aa0, 0xc0000a0140, 0x0, 0x0, 0x0)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/subscriptions/subscription.go:134 +0x52
foo/bar/vendor/github.com/jdextraze/go-gesclient/internal.(*connectionLogicHandler).handleTcpPackage(0xc000408000, 0xa93b40, 0xc00001e5f0, 0x144a2e98, 0x28834a7e3c93938e)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/internal/connection_logic_handler.go:553 +0xa41
foo/bar/vendor/github.com/jdextraze/go-gesclient/internal.(*connectionLogicHandler).handleTcpPackage-fm(0xa93b40, 0xc00001e5f0, 0x9, 0xc0001ec188)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/internal/connection_logic_handler.go:140 +0x3e
foo/bar/vendor/github.com/jdextraze/go-gesclient/internal.(*simpleQueuedHandler).processQueue(0xc0001b2260)
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/internal/simple_queued_handler.go:40 +0x102
created by foo/bar/vendor/github.com/jdextraze/go-gesclient/internal.newSimpleQueuedHandler
	/go/src/foo/bar/vendor/github.com/jdextraze/go-gesclient/internal/simple_queued_handler.go:19 +0xa7

This application is being run in docker on Alpine 3.8 against Event Store 4.1.4, which is also in docker.

@kmacmcfarlane
Copy link
Author

I think I've identified a fix and may have a PR sometime next week. A simple nil-check on dto.Reason before dereferencing will likely do the trick.

@kmacmcfarlane
Copy link
Author

Update: I have forked this repo, and I am testing a fix that seems to prevent the pre-mature panic in certain cases.

@jdextraze
Copy link
Owner

Sorry for the late answer.

The DTO is generated by protobuf and the proto file define the enum field with a default value which come as a Nil.

message SubscriptionDropped {

	enum SubscriptionDropReason {
		Unsubscribed = 0;
		AccessDenied = 1;
		NotFound=2;
		PersistentSubscriptionDeleted=3;
		SubscriberMaxCountReached=4;
	}
	
	optional SubscriptionDropReason reason = 1 [default = Unsubscribed];
}

So instead of *dto.Reason it should be dto.GetReason() because the get method handles the default value case.

Fixed in master.

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

No branches or pull requests

2 participants