Skip to content

Conversation

@ansd
Copy link
Member

@ansd ansd commented Jul 3, 2024

This commit fixes a bug present in 3.13.3 which was introduced by #11339

When an AMQP 0.9.1 client re-publishes a message with the x-death header set, the time field was not converted from the AMQP 0.9.1 seconds resolution to the internal millisecond resolution of mc fields first_time and last_time.

Additionally, this commit will ignore invalid time fields sent in the x-death header from AMQP 0.9.1 clients as reported in https://rabbitmq.slack.com/archives/C1EDN83PA/p1719986557420719 which results in the following crash later on when the message gets consumed:

 supervisor: {<0.476725.0>,rabbit_channel_sup}
    errorContext: child_terminated
    reason: {badarith,
                [{erlang,'div',
                     [<<"2024-07-02T02:58:50.000-07:00">>,1000],
                     [{error_info,#{module => erl_erts_errors}}]},
                 {mc_amqpl,death_table,7,[{file,"mc_amqpl.erl"},{line,806}]},
                 {lists,map,2,[{file,"lists.erl"},{line,1559}]},
                 {mc_amqpl,deaths_to_headers,2,
                     [{file,"mc_amqpl.erl"},{line,764}]},
                 {mc_amqpl,protocol_state,2,
                     [{file,"mc_amqpl.erl"},{line,406}]},
                 {rabbit_channel,handle_deliver0,4,
                     [{file,"rabbit_channel.erl"},{line,2685}]},
                 {lists,foldl,3,[{file,"lists.erl"},{line,1594}]},
                 {rabbit_channel,handle_cast,2,
                     [{file,"rabbit_channel.erl"},{line,732}]}]}

This commit fixes a bug present in 3.13.3 which was introduced by
#11339

When an AMQP 0.9.1 client re-publishes a message with the x-death header
set, the `time` field was not converted from the AMQP 0.9.1 seconds
resolution to the internal millisecond resolution of `mc` fields
`first_time` and `last_time`.

Additionally, this commit will ignore invalid `time` fields sent in the
`x-death` header from AMQP 0.9.1 clients as reported in
https://rabbitmq.slack.com/archives/C1EDN83PA/p1719986557420719 which
results in the following crash later on when the message gets consumed:
```
 supervisor: {<0.476725.0>,rabbit_channel_sup}
    errorContext: child_terminated
    reason: {badarith,
                [{erlang,'div',
                     [<<"2024-07-02T02:58:50.000-07:00">>,1000],
                     [{error_info,#{module => erl_erts_errors}}]},
                 {mc_amqpl,death_table,7,[{file,"mc_amqpl.erl"},{line,806}]},
                 {lists,map,2,[{file,"lists.erl"},{line,1559}]},
                 {mc_amqpl,deaths_to_headers,2,
                     [{file,"mc_amqpl.erl"},{line,764}]},
                 {mc_amqpl,protocol_state,2,
                     [{file,"mc_amqpl.erl"},{line,406}]},
                 {rabbit_channel,handle_deliver0,4,
                     [{file,"rabbit_channel.erl"},{line,2685}]},
                 {lists,foldl,3,[{file,"lists.erl"},{line,1594}]},
                 {rabbit_channel,handle_cast,2,
                     [{file,"rabbit_channel.erl"},{line,732}]}]}
```
@ansd ansd added the bug label Jul 3, 2024
@michaelklishin michaelklishin added the backport-pending Use with PRs that are yet to be backported for any reason label Jul 3, 2024
@michaelklishin
Copy link
Collaborator

michaelklishin commented Jul 3, 2024

This can be merged after Tanzu RabbitMQ 3.13.4 ships.

@ansd ansd added this to the 3.13.5 milestone Jul 3, 2024
@michaelklishin michaelklishin changed the title Fix timestamp when recovering x-death header 3.13.x only: fix timestamp when recovering x-death header Jul 3, 2024
@michaelklishin michaelklishin changed the title 3.13.x only: fix timestamp when recovering x-death header DO NOT MERGE YET 3.13.x only: fix timestamp when recovering x-death header Jul 3, 2024
@michaelklishin michaelklishin changed the title DO NOT MERGE YET 3.13.x only: fix timestamp when recovering x-death header 3.13.x only: fix timestamp when recovering x-death header Jul 4, 2024
@michaelklishin michaelklishin merged commit db34223 into v3.13.x Jul 4, 2024
@michaelklishin michaelklishin deleted the v3.13.x-dead-letter-ts-fix branch July 4, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-pending Use with PRs that are yet to be backported for any reason bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants