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

Handle empty body messages #147

Merged
merged 17 commits into from
Aug 31, 2019
Merged

Handle empty body messages #147

merged 17 commits into from
Aug 31, 2019

Conversation

ghost
Copy link

@ghost ghost commented Aug 27, 2019

issue: #146

@ghost ghost added the do not merge block pr merging until notice label Aug 27, 2019
@coveralls
Copy link

coveralls commented Aug 27, 2019

Coverage Status

Coverage increased (+0.2%) to 75.983% when pulling 107f402 on handle_empty_body_messages into eef69fb on v1.x.

@ghost ghost removed the do not merge block pr merging until notice label Aug 27, 2019
@ghost ghost requested a review from rhinof August 27, 2019 16:55
tests/bus_test.go Outdated Show resolved Hide resolved
tests/bus_test.go Show resolved Hide resolved
tests/bus_test.go Outdated Show resolved Hide resolved
proceed <- true
return nil
})
err := b.HandleMessage(&Command3{}, func(invocation gbus.Invocation, message *gbus.BusMessage) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

try reverting back to use Command2 and see if it still raises that strange error. if there is some sort of fundamental bug I want us to identify it and fix. I am hoping that my prev PR fixes this issue as well.

Copy link
Author

Choose a reason for hiding this comment

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

when reverting back to svc1 it works.
But when reverting back to "Command1" I get :

panic: gob: registering duplicate names for *tests.Command1: "github.com/wework/grabbit/tests.Command1" != "*tests.Command1" [recovered]
	panic: gob: registering duplicate names for *tests.Command1: "github.com/wework/grabbit/tests.Command1" != "*tests.Command1"

Copy link
Contributor

Choose a reason for hiding this comment

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

@adiweiss A few obsurvations:

When running only the TestFailHandlerInvokeOfMessageWithEmptyBody test with &Command1 it passes
go test ./tests -run=TestFailHandlerInvokeOfMessageWithEmptyBody
But when running the entire test suite it fails with the above gob error.

When changing the test code to
b.HandleMessage(Command1,....) passing in the struct instead of pointer the test suite runs successfully.

Copy link
Author

Choose a reason for hiding this comment

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

well, I changed it and now the test pass. but still remains the question - why does it work when running just this test?!

Copy link
Contributor

@rhinof rhinof Aug 30, 2019

Choose a reason for hiding this comment

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

seems like what is going on is that the gob package has a bug when registering types that is maintained for backward compatibility.
see: encoding/gob/type.go#L847
and
encoding/gob/type.go#L824

So what is happening is that since all the tests run in the same context and the registered types in gob get carried over between test runs + the bug in gob then &Command1{} and Command1{} gets transformed to the same user type causes the panic.

you can reproduce using the following test

func TestGob(t *testing.T) {

	m1 := &Command1{}
	m2 := Command1{}

	gob.Register(m1)
	gob.Register(m2)
}

@ghost ghost added the do not merge block pr merging until notice label Aug 29, 2019
@ghost ghost removed the do not merge block pr merging until notice label Aug 29, 2019
@ghost ghost requested a review from rhinof August 29, 2019 20:07
Copy link
Contributor

@rhinof rhinof left a comment

Choose a reason for hiding this comment

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

well done

@rhinof rhinof merged commit e1ac9dc into v1.x Aug 31, 2019
@delete-merged-branch delete-merged-branch bot deleted the handle_empty_body_messages branch August 31, 2019 13:24
rhinof pushed a commit that referenced this pull request Sep 1, 2019
* add handler metrics to bus and saga (#101)

* add handler metrics to bus and saga + tests

* fix build

* add 0 to the default buckets to catch fast message handling

* PR correction - changed latency to summary(removed bucket configuration), add registration for saga handlers

* PR correction - getting logger as a param

* PR correction - new line in eof

* PR corrections message handler + sync.map + latency as summary

* add rejected messages metric

* dead letter handler should reject messages on failures and rollbacks and ack on commit success  (#105)

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* return an error from the saga store when deleting a saga if saga can not (#110)

be found

In order to deal with concurrent deletes of the sage saga instance we
would wan't to indicate that deleting the saga failed if the saga is not
stored so callers can take proper action

* Persisted timeouts (#107)

* decouple transaction manager from glue

* moved timeout manager to gbus/tx package

* initial commit in order to support persisted timeouts

* first working version of a mysql persisted timeout manager

* fixing ci lint errors

* refactored ensure schema of timeout manager

* cleanup timeout manager when bs shuts down

* fixing formatting issues

* changed logging level from Info to Debug when inserting a new timeout

* resusing timeouts tablename (PR review)

* renamed AcceptTimeoutFunction to SetTimeoutFunction on the
TimeoutManager interface (PR review)

* refactored glue to implement the Logged inetrface and use the GLogged
helper struct

* locking timeout record before executing timeout

In order to prevent having a timeout beeing executed twice due to two
concurrent grabbit instances running the same service a lock (FOR
UPDATE) has been placed on the timeout record  in the scope of the executing transaction

* Commiting the select transaction when querying for pending timeouts

* feat(timeout:lock): This is done in order to reduce contention and allow for parallel processing in case of multiple grabbit instances

* Enable returning a message back from the dead  to the queue (#112)

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* return to q

* return to q

* return to q

* return to q

* return dead to q

* allow no retries

* test - resend dead to queue

* test - resend dead to queue

* test - resend dead to queue

* test - resend dead to queue - fixes after cr

* test - resend dead to queue - fixes after cr

* test - resend dead to queue - fixes after cr

* added metric report on saga timeout (#114)

1) added reporting saga timeouts to the glue component
2) fixed mysql timeoutmanager error when trying to clear a timeout

* Added documentation for grabbit metrics (#117)

* added initial documentation for grabbit metrics

*  including metrics section in readme.md

* fixing goreportcard issues (#118)

* removed logging a warning when worker message channel returns an error (#116)

* corrected saga metrics name and added to metrics documentation (#119)

* corrected saga metrics name and added documentatio

* corrected saga metric name

* corrected typos

* removed non transactional bus mode (#120)

* remove fields

* remove fields

* go fmt and go lint error fixes to improve goreportcard (#126)

* go fmt on some files

* go fmt

* added comments on exported types

* cunsume the messages channel via ranging over the channel to prevent (#125)

empty delivreies

* Migrations functionality (#111)

* implement migrations

* implement migrations

* implement migrations

* implement migrations

* implement migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* fix tests error

* add migrations

* migrations - timeout table migration

* test - resend dead to queue - fixes after cr

* migraration to grabbit (use forked migrator)

* remove fields

* remove fields

* remove fields

* remove fields

* sanitize migrations table name (#130)

* more linting fixes for goreportcard (#129)

* added metrics on deadLetterHandler, refactored HandleDeadLetter inter… (#122)

* added metrics on deadLetterHandler, refactored HandleDeadLetter interface to receive new DeadLetterMessageHandler type

* fix dead letter test and a build error

* added documentation for DeadLetterMessageHandler, also fixed poison spelling throughout code

* retrigger build

* align migrations table name with grabbit convention (#140)

* Improved tracing and added documentation (#142)

* Support handling raw message (#138)

* added call to worker.span.Finish() when exiting processMessage (#145)

* bug fix - when a deadletterhandler panics grabbit fails to reject the… (#136)

* bug fix - when a deadletterhandler panics grabbit fails to reject the message

* bug fix - when a deadletterhandler panics grabbit fails to reject the message

* BPINFRA125 - MERGE MASTER INTO BRANCH

* calling channel.Cancel when worker is stopped (#149)

* Handle empty body messages (#147)

* fixing golint warnings from goreport card (#150)

* more golint fixes (#152)
rhinof pushed a commit that referenced this pull request Sep 19, 2019
* add handler metrics to bus and saga (#101)

* add handler metrics to bus and saga + tests

* fix build

* add 0 to the default buckets to catch fast message handling

* PR correction - changed latency to summary(removed bucket configuration), add registration for saga handlers

* PR correction - getting logger as a param

* PR correction - new line in eof

* PR corrections message handler + sync.map + latency as summary

* add rejected messages metric

* dead letter handler should reject messages on failures and rollbacks and ack on commit success  (#105)

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* dead letter handler should reject messages on failures and rollbacks

* return an error from the saga store when deleting a saga if saga can not (#110)

be found

In order to deal with concurrent deletes of the sage saga instance we
would wan't to indicate that deleting the saga failed if the saga is not
stored so callers can take proper action

* Persisted timeouts (#107)

* decouple transaction manager from glue

* moved timeout manager to gbus/tx package

* initial commit in order to support persisted timeouts

* first working version of a mysql persisted timeout manager

* fixing ci lint errors

* refactored ensure schema of timeout manager

* cleanup timeout manager when bs shuts down

* fixing formatting issues

* changed logging level from Info to Debug when inserting a new timeout

* resusing timeouts tablename (PR review)

* renamed AcceptTimeoutFunction to SetTimeoutFunction on the
TimeoutManager interface (PR review)

* refactored glue to implement the Logged inetrface and use the GLogged
helper struct

* locking timeout record before executing timeout

In order to prevent having a timeout beeing executed twice due to two
concurrent grabbit instances running the same service a lock (FOR
UPDATE) has been placed on the timeout record  in the scope of the executing transaction

* Commiting the select transaction when querying for pending timeouts

* feat(timeout:lock): This is done in order to reduce contention and allow for parallel processing in case of multiple grabbit instances

* Enable returning a message back from the dead  to the queue (#112)

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* enable sending raw messages

* return to q

* return to q

* return to q

* return to q

* return dead to q

* allow no retries

* test - resend dead to queue

* test - resend dead to queue

* test - resend dead to queue

* test - resend dead to queue - fixes after cr

* test - resend dead to queue - fixes after cr

* test - resend dead to queue - fixes after cr

* added metric report on saga timeout (#114)

1) added reporting saga timeouts to the glue component
2) fixed mysql timeoutmanager error when trying to clear a timeout

* Added documentation for grabbit metrics (#117)

* added initial documentation for grabbit metrics

*  including metrics section in readme.md

* fixing goreportcard issues (#118)

* removed logging a warning when worker message channel returns an error (#116)

* corrected saga metrics name and added to metrics documentation (#119)

* corrected saga metrics name and added documentatio

* corrected saga metric name

* corrected typos

* removed non transactional bus mode (#120)

* remove fields

* remove fields

* go fmt and go lint error fixes to improve goreportcard (#126)

* go fmt on some files

* go fmt

* added comments on exported types

* cunsume the messages channel via ranging over the channel to prevent (#125)

empty delivreies

* Migrations functionality (#111)

* implement migrations

* implement migrations

* implement migrations

* implement migrations

* implement migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* migrations

* fix tests error

* add migrations

* migrations - timeout table migration

* test - resend dead to queue - fixes after cr

* migraration to grabbit (use forked migrator)

* remove fields

* remove fields

* remove fields

* remove fields

* sanitize migrations table name (#130)

* more linting fixes for goreportcard (#129)

* added metrics on deadLetterHandler, refactored HandleDeadLetter inter… (#122)

* added metrics on deadLetterHandler, refactored HandleDeadLetter interface to receive new DeadLetterMessageHandler type

* fix dead letter test and a build error

* added documentation for DeadLetterMessageHandler, also fixed poison spelling throughout code

* retrigger build

* align migrations table name with grabbit convention (#140)

* Improved tracing and added documentation (#142)

* Support handling raw message (#138)

* added call to worker.span.Finish() when exiting processMessage (#145)

* bug fix - when a deadletterhandler panics grabbit fails to reject the… (#136)

* bug fix - when a deadletterhandler panics grabbit fails to reject the message

* bug fix - when a deadletterhandler panics grabbit fails to reject the message

* BPINFRA125 - MERGE MASTER INTO BRANCH

* calling channel.Cancel when worker is stopped (#149)

* Handle empty body messages (#147)

* fixing golint warnings from goreport card (#150)

* more golint fixes (#152)
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

Successfully merging this pull request may close these issues.

None yet

2 participants