ravendb-go-client icon indicating copy to clipboard operation
ravendb-go-client copied to clipboard

TestSubscriptionsBasic flaky

Open kjk opened this issue 6 years ago • 7 comments

https://ci.appveyor.com/project/ravendb/ravendb-go-client/builds/23144627/job/ge467894jiqskbqv?fullLog=true#L4358

Could be just networking issue with the machine.

--- FAIL: TestSubscriptionsBasic (5.84s)
    subscriptions_basic_test.go:286: 
        	Error Trace:	subscriptions_basic_test.go:286
        	            				asm_amd64.s:1333
        	Error:      	Not equal: 
        	            	expected: "Adam"
        	            	actual  : "James"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-Adam
        	            	+James
        	Test:       	TestSubscriptionsBasic
    subscriptions_basic_test.go:286: 
        	Error Trace:	subscriptions_basic_test.go:286
        	            				asm_amd64.s:1333
        	Error:      	Not equal: 
        	            	expected: "David"
        	            	actual  : "Adam"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-David
        	            	+Adam
        	Test:       	TestSubscriptionsBasic
=== RUN   TestSuggestionsLazy

kjk avatar Mar 18 '19 03:03 kjk

Try logging all the previous values that you go there. It might have called this twice? Or there was an error and it retired?

ayende avatar Mar 18 '19 12:03 ayende

It looks like (sometimes) we don't get the first expected value, created before subscription.Run.

kjk avatar Mar 18 '19 22:03 kjk

In here: https://github.com/ravendb/ravendb-go-client/blob/master/tests/subscriptions_basic_test.go#L271

And: https://github.com/ravendb/ravendb-go-client/blob/master/subscription_worker.go#L427

You are putting the batch into a channel, but it looks like this instance is being reused, so you are getting data races. If this is a common setup in Go, this is probably a real pitfall and we need to make sure that we won't be re-using this instance.

ayende avatar Mar 19 '19 07:03 ayende

For that reason the callback receives a copy of SubscriptionBatch: https://github.com/ravendb/ravendb-go-client/blob/master/subscription_worker.go#L444

kjk avatar Mar 19 '19 08:03 kjk

But you are passing the Item instance, isn't that mutable?

ayende avatar Mar 19 '19 08:03 ayende

.Items gets re-created from scratch in each iteration in https://sourcegraph.com/github.com/ravendb/ravendb-go-client@master/-/blob/subscription_batch.go#L87 called from https://sourcegraph.com/github.com/ravendb/ravendb-go-client@2c2cde5258d42e531d03f95fa98713cb6e1b8135/-/blob/subscription_worker.go#L437

kjk avatar Mar 19 '19 08:03 kjk

Okay, make sense.

When you check the logs, see if you can also log what comes from the network. I think this is a Go client problem, not a server one

ayende avatar Mar 19 '19 08:03 ayende