rabbitmq / rabbitmq-server

Open source RabbitMQ: core server and tier 1 (built-in) plugins
https://www.rabbitmq.com/
Other
12.15k stars 3.91k forks source link

3.13.x only: fix timestamp when recovering x-death header #11608

Closed ansd closed 3 months ago

ansd commented 3 months ago

This commit fixes a bug present in 3.13.3 which was introduced by https://github.com/rabbitmq/rabbitmq-server/pull/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}]}]}
michaelklishin commented 3 months ago

This can be merged after Tanzu RabbitMQ 3.13.4 ships.