Skip to content

Conversation

@jfontan
Copy link
Contributor

@jfontan jfontan commented Mar 7, 2019

Some messages in borges returned the number of retries as an int64 number and this was generating errors.

It also rejects messages with malformed headers. If not the messages will be unacked and eventually block the channel.

It also rejects messages with malformed headers.

Signed-off-by: Javi Fontan <[email protected]>
@jfontan jfontan requested a review from mcarmonaa March 7, 2019 15:20
amqp/amqp.go Outdated
j.Retries = int32(r)

case int64:
j.Retries = int32(r)
Copy link

Choose a reason for hiding this comment

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

it won't work! you'll have overflow issue (see: https://play.golang.org/p/-1sXpyO-KCY)
for in64 just do .retries.(int32) or modulo, or check if the value is < math.MaxInt32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Retries in the job is an int32 so it cannot be bigger than that. This is done because the migration software converts all header integers to int64 but we don't expect them to be bigger that max_int32.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add the check just in case.

Copy link

Choose a reason for hiding this comment

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

ok, makes sense. you can also just in case do sth. like int32(r) & math.MaxInt32

return nil, ErrRetrievingHeader.New(DefaultConfiguration.RetriesHeader, d.MessageId)
}
switch r := retries.(type) {
case int16:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this case for int16?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The three integer formats supported by amqp library are int16, int32 and int64. There for completeness. It says that supports int but returns error if it is used.

https://godoc.org/github.com/streadway/amqp#Table

@jfontan
Copy link
Contributor Author

jfontan commented Mar 7, 2019

There's a problem with rabbitmq in windows. I've restarted the job in my appveyor account a couple of times and was not able to start the server (connect to the port). I'm merging as the changes should not be affecting windows.

@jfontan jfontan merged commit dc171cd into src-d:master Mar 7, 2019
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.

3 participants