apache / rocketmq

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
https://rocketmq.apache.org/
Apache License 2.0
21.19k stars 11.67k forks source link

Why does case SLAVE_NOT_AVALIABLE roll back when sending transaction messages #3617

Closed iamqq23ue closed 1 year ago

iamqq23ue commented 2 years ago

version:4.9.1

An abnormality of the broker slave will cause many messages to fail to be sent.

And because the client does not automatically resend the message, you need to write code to resend the message, so the message may still be sent to the abnormal broker.

panzhi33 commented 2 years ago

SLAVE_NOT_AVAILABLE is returned, the message is still sent successfully, and the client does not need to reissue

iamqq23ue commented 2 years ago

public TransactionSendResult sendMessageInTransaction

case SLAVE_NOT_AVAILABLE: localTransactionState = LocalTransactionState.ROLLBACK_MESSAGE; break;

According to the above code, the transaction message will be rolled back when SLAVE_NOT_AVAILABLE

panzhi33 commented 2 years ago

public TransactionSendResult sendMessageInTransaction case SLAVE_NOT_AVAILABLE: localTransactionState = LocalTransactionState.ROLLBACK_MESSAGE; break; According to the above code, the transaction message will be rolled back when SLAVE_NOT_AVAILABLE

yes,I didn't look carefully. I feel that the design here is not very reasonable. In org.apache.rocketmq.broker.processor.EndTransactionProcessor#sendFinalMessage, SLAVE_NOT_AVAILABLE is successful. And other message types are also successful by default. I think it needs to be unified here

shuangchengsun commented 2 years ago

I also noticed this. in the issue #1390 this problem has been discussed. However, this issue(#1390 ) did not attract attention at the time. Based on this situation, we fix this problem with a switch which controls the transaction message ignore slave error. maybe I can create a PR to fix it.

Git-Yang commented 2 years ago

IMO, for the client, SLAVE_NOT_AVAILABLE is returned when sending a transaction message. At this time, the message has been successfully written to the master, and the client can resend it after ROLLBACK_MESSAGE. For Broker, after receiving the commit message sent by the client, if SLAVE_NOT_AVAILABLE occurs, the commit message has been written to the master at this time, so it will automatically synchronize after the slave is restored, otherwise it will not make any sense to resend the commit after the return fails. .

iamqq23ue commented 2 years ago

I think that when the client receives a SLAVE_NOT_AVAILABLE, the client must resend the message, and it may still be sent to the abnormal broker. Therefore I think that the message should not be returned when SLAVE_NOT_AVAILABLE.

------------------ 原始邮件 ------------------ 发件人: "apache/rocketmq" @.>; 发送时间: 2021年12月14日(星期二) 下午2:42 @.>; @.**@.>; 主题: Re: [apache/rocketmq] Why does case SLAVE_NOT_AVALIABLE roll back when sending transaction messages (Issue #3617)

IMO, for the client, SLAVE_NOT_AVAILABLE is returned when sending a transaction message. At this time, the message has been successfully written to the master, and the client can resend it after ROLLBACK_MESSAGE. For Broker, after receiving the commit message sent by the client, if SLAVE_NOT_AVAILABLE occurs, the commit message has been written to the master at this time, so it will automatically synchronize after the slave is restored, otherwise it will not make any sense to resend the commit after the return fails. .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 3 days since being marked as stale.