【Azure 事件中心】適用Mirror Maker生產(chǎn)數(shù)據(jù)發(fā)送到Azure Event Hub出現(xiàn)發(fā)送一段時間后Timeout Exception: Expiring 18 record(s)...

問題描述

根據(jù)“將 Apache Kafka MirrorMaker 與事件中心配合使用”一文宋舷,成功配置了Mirror Maker來發(fā)送數(shù)據(jù)到Event Hub中腌零。為什么只能成功運(yùn)行一會(10分鐘 ~ 2小時左右)就會出現(xiàn)Timeout Exception,然后Kafka MirrorMaker就會中斷退出呢?

異常消息為:

[2022-05-25 14:29:21,683] INFO [Producer clientId=mirror_maker_producer] Proceeding to force close the producer since pending requests could not be completed within timeout 0 ms. 
(org.apache.kafka.clients.producer.KafkaProducer)
[2022-05-25 14:29:21,683] DEBUG [Producer clientId=mirror_maker_producer] Kafka producer has been closed (org.apache.kafka.clients.producer.KafkaProducer)
[2022-05-25 14:29:21,683] ERROR Error when sending message to topic xxxxxxxxxxxx with key: 16 bytes, value: 875 bytes with error: 
(org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 18 record(s) for xxxxxxxxxxxx-4: 79823 ms has passed since last append
[2022-05-25 14:29:21,683] INFO Closing producer due to send failure. (kafka.tools.MirrorMaker$)
[2022-05-25 14:29:21,683] INFO [Producer clientId=mirror_maker_producer] Closing the Kafka producer with timeoutMillis = 0 ms. (org.apache.kafka.clients.producer.KafkaProducer)
[2022-05-25 14:29:21,683] INFO [Producer clientId=mirror_maker_producer] Proceeding to force close the producer since pending requests could not be completed within timeout 0 ms. 
(org.apache.kafka.clients.producer.KafkaProducer)
[2022-05-25 14:29:21,683] DEBUG [Producer clientId=mirror_maker_producer] Kafka producer has been closed (org.apache.kafka.clients.producer.KafkaProducer)
[2022-05-25 14:29:21,683] ERROR Error when sending message to topic xxxxxxxxxxxx with key: 16 bytes, value: 875 bytes with error: 
(org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Expiring 18 record(s) for xxxxxxxxxxxx-4: 79823 ms has passed since last append
[2022-05-25 14:29:21,683] INFO Closing producer due to send failure. (kafka.tools.MirrorMaker$)
[2022-05-25 14:29:21,683] INFO [Producer clientId=mirror_maker_producer] Closing the Kafka producer with timeoutMillis = 0 ms. (org.apache.kafka.clients.producer.KafkaProducer)

問題解析

根據(jù)錯誤消息 " Expiring 18 record(s) for xxxxxxxxxxxx-4: 79823 ms has passed since last append " 在網(wǎng)上進(jìn)行搜索喇聊,對發(fā)生問題的解釋有:

1) Stack Overflow上的解釋:https://stackoverflow.com/questions/56807188/how-to-fix-kafka-common-errors-timeoutexception-expiring-1-records-xxx-ms-has

The error indicates that some records are put into the queue at a faster rate than they can be sent from the client.

錯誤表示Mirror Maker中消息進(jìn)入Queue中的速度快于從當(dāng)前客戶端發(fā)送到服務(wù)端的速度(服務(wù)端是 Event Hub)

When your Producer sends messages, they are stored in buffer (before sending them to the target broker) and the records are grouped together into batches in order to increase throughput. When a new record is added to the batch, it must be sent within a -configurable- time window which is controlled by request.timeout.ms (the default is set to 30 seconds). If the batch is in the queue for longer time, a TimeoutException is thrown and the batch records will then be removed from the queue and won't be delivered to the broker.

當(dāng)Mirror Maker(生產(chǎn)者)發(fā)送消息時,它們被存儲在緩沖區(qū)中(在將它們發(fā)送到目標(biāo)代理之前),并且記錄被分組到一起以增加吞吐量。 將新記錄添加到批次時净捅,它必須在由 request.timeout.ms 控制的時間窗口內(nèi)發(fā)送(默認(rèn)設(shè)置為 30 秒)。 如果批處理在隊列中的時間較長邦鲫,則會引發(fā) TimeoutException灸叼,然后批處理記錄將從隊列中刪除并且不會傳遞給代理神汹。

Increasing the value of request.timeout.ms should do the trick for you.

增加 request.timeout.ms 的值應(yīng)該可以解決問題庆捺。

2) 博客園解釋:https://blog.csdn.net/weixin_43432984/article/details/109180842

當(dāng)每一批消息滿了(batch.size)且 requestTimeoutMs < (now - this.lastAppendTime)) 這一批消息就會被標(biāo)記為過期且不會放到 RecordAccumulator 中(不會再次重試發(fā)送)

調(diào)大batch.size 參數(shù)和request.timeout.ms 參數(shù)可解決問題

3) 為什么一出現(xiàn)異常就馬上停止運(yùn)行呢?

因為Mirror Maker的配置參數(shù)屁魏,abort.on.send.failure 默認(rèn)為true滔以,決定生產(chǎn)者寫入失敗時的處理機(jī)制就是Abort,終止發(fā)送氓拼。

maybeExpire 函數(shù)的源碼中發(fā)現(xiàn)異常消息產(chǎn)生的根源:

image.png

所以根據(jù)以上的信息你画,只需要修改 batch.size 和 request.timeout.ms 參數(shù)即可。


**修改前:**
    request.timeout.ms = 60000
    batch.size = 16384 

 **修改后:**
    request.timeout.ms=180000
    batch.size=50000

使用修改后的參數(shù)運(yùn)行Mirror Maker桃漾,發(fā)送數(shù)據(jù)到Azure Event Hub正常坏匪,連續(xù)運(yùn)行2天沒見Timeout 異常彩郊。問題解決鲁猩!

參考資料

記一次Kafka Producer TimeoutException排查:https://blog.csdn.net/weixin_43432984/article/details/109180842

How to fix kafka.common.errors.TimeoutException: Expiring 1 record(s) xxx ms has passed since batch creation plus linger timehttps://stackoverflow.com/questions/56807188/how-to-fix-kafka-common-errors-timeoutexception-expiring-1-records-xxx-ms-has

將 Apache Kafka MirrorMaker 與事件中心配合使用:https://docs.azure.cn/zh-cn/event-hubs/event-hubs-kafka-mirror-maker-tutorial

kafka-mirror-maker.sh腳本: https://blog.csdn.net/qq_41154944/article/details/108282641

當(dāng)在復(fù)雜的環(huán)境中面臨問題,格物之道需:濁而靜之徐清钠怯,安以動之徐生恋追。 云中凭迹,恰是如此!

分類: 【Azure 事件中心】

標(biāo)簽: Azure Developer, 事件中心 Azure Event Hub, Kafka Mirror Maker, Expiring 18 record(s) for, xxxxxxx: 79823 ms has passed since last append, Timeout Exception:

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市苦囱,隨后出現(xiàn)的幾起案子嗅绸,更是在濱河造成了極大的恐慌,老刑警劉巖撕彤,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件鱼鸠,死亡現(xiàn)場離奇詭異,居然都是意外死亡羹铅,警方通過查閱死者的電腦和手機(jī)蚀狰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來睦裳,“玉大人造锅,你說我怎么就攤上這事×兀” “怎么了哥蔚?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵倒谷,是天一觀的道長。 經(jīng)常有香客問我糙箍,道長渤愁,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任深夯,我火速辦了婚禮抖格,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘咕晋。我一直安慰自己雹拄,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布掌呜。 她就那樣靜靜地躺著滓玖,像睡著了一般。 火紅的嫁衣襯著肌膚如雪质蕉。 梳的紋絲不亂的頭發(fā)上势篡,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天,我揣著相機(jī)與錄音模暗,去河邊找鬼禁悠。 笑死,一個胖子當(dāng)著我的面吹牛兑宇,可吹牛的內(nèi)容都是我干的碍侦。 我是一名探鬼主播,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼顾孽,長吁一口氣:“原來是場噩夢啊……” “哼祝钢!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起若厚,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤拦英,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后测秸,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體疤估,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年霎冯,在試婚紗的時候發(fā)現(xiàn)自己被綠了铃拇。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡沈撞,死狀恐怖慷荔,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情缠俺,我是刑警寧澤显晶,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布贷岸,位于F島的核電站,受9級特大地震影響磷雇,放射性物質(zhì)發(fā)生泄漏偿警。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一唯笙、第九天 我趴在偏房一處隱蔽的房頂上張望螟蒸。 院中可真熱鬧,春花似錦崩掘、人聲如沸七嫌。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽抄瑟。三九已至凡泣,卻和暖如春枉疼,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背鞋拟。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工骂维, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人贺纲。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓航闺,卻偏偏與公主長得像,于是被迫代替她去往敵國和親猴誊。 傳聞我的和親對象是個殘疾皇子潦刃,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,066評論 2 355

推薦閱讀更多精彩內(nèi)容