servicecomb-pack icon indicating copy to clipboard operation
servicecomb-pack copied to clipboard

alpha的akka模式下,事务条目是否有写入redis

Open chensk0601 opened this issue 2 years ago • 12 comments

看设计图,akka模式下,事务条目信息是有追加到redis中的,但是实现上并没有看到,只有看到事务结束后才把数据写入ES

chensk0601 avatar Feb 02 '22 15:02 chensk0601

Akka Persistence Redis Plugin is a plugin for Akka persistence

coolbeevip avatar Feb 03 '22 04:02 coolbeevip

这是来自QQ邮箱的假期自动回复邮件。   将在最快的时间回复

chensk0601 avatar Feb 03 '22 04:02 chensk0601

明白了,还有一个疑问,如果将这个akka persistence用于生产系统,已经完成的事务数据怎么进行老化处理,有没有这方面的一些经验和实践

chensk0601 avatar Feb 08 '22 02:02 chensk0601

你说的老化是redis的数据老化,还是ES的数据老化?

WillemJiang avatar Feb 08 '22 02:02 WillemJiang

两者都是,怎么老化处理

---原始邮件--- 发件人: "Willem @.> 发送时间: 2022年2月8日(周二) 上午10:59 收件人: @.>; 抄送: @.>;"State @.>; 主题: Re: [apache/servicecomb-pack] alpha的akka模式下,事务条目是否有写入redis (Issue #732)

你说的老化是redis的数据老化,还是ES的数据老化?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you modified the open/close state.Message ID: @.***>

chensk0601 avatar Feb 08 '22 03:02 chensk0601

老化处理是什么意思?

coolbeevip avatar Feb 10 '22 05:02 coolbeevip

就是数据怎么清理的意思

2022年2月10日 下午1:36,Lei Zhang @.***> 写道:

老化处理是什么意思?

— Reply to this email directly, view it on GitHub https://github.com/apache/servicecomb-pack/issues/732#issuecomment-1034512367, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVDS4QFTZDHKSOHW6XWXTTU2NFFJANCNFSM5NMM3IZA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.

chensk0601 avatar Feb 10 '22 05:02 chensk0601

就是数据怎么清理的意思 2022年2月10日 下午1:36,Lei Zhang @.***> 写道: 老化处理是什么意思? — Reply to this email directly, view it on GitHub <#732 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVDS4QFTZDHKSOHW6XWXTTU2NFFJANCNFSM5NMM3IZA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.

actor 在停止后会调用以下方法清理 Redis 中的数据和快照 https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L458-L459

但是 highestSequenceNr 不会自动清理,你可以看这个注释(我在注释里提供了一个 Lua 脚本用来清理)

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L419-L457

ES 中的数据你可以根据 事务数据持久化 中的数据样例了解JSON 接口,可以使用 ES API 自行删除不需要的数据

coolbeevip avatar Feb 10 '22 06:02 coolbeevip

OK,另外,下面这一行的这个SataTimeoutEvent事件类型,我在omega侧并没有发现有发送这种事件类型的。

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/fsm/GrpcSagaEventService.java#L126

chensk0601 avatar Feb 10 '22 06:02 chensk0601

这里有一个事件定义文档

还有一个状态机设计

你可以了解一下,SataTimeoutEvent 时间不是由 omega 发起的,我印象中是使用了 Akka 的 goTo()...forMax() 实现的,在相关状态 goto 的时候都要超时设置

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L91

通过内置 StateTimeout() 实现超时后发送状态机停止事件,并挂起事物

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L126

coolbeevip avatar Feb 10 '22 07:02 coolbeevip

你说的这个forMax超时的时候,应该是.event(Collections.singletonList(StateTimeout())

2022年2月10日 下午3:40,Lei Zhang @.***> 写道:

这里有一个事件定义文档 https://github.com/apache/servicecomb-pack/blob/master/docs/fsm/design_fsm_zh.md#%E4%BA%8B%E4%BB%B6%E5%AE%9A%E4%B9%89 还有一个状态机设计 https://github.com/apache/servicecomb-pack/blob/master/docs/fsm/design_fsm_zh.md#%E7%8A%B6%E6%80%81%E6%9C%BA%E8%AE%BE%E8%AE%A1 你可以了解一下,SataTimeoutEvent 时间不是由 omega 发起的,我印象中是使用了 Akka 的 goTo()...forMax() 实现的,在相关状态 goto 的时候都要超时设置

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L91 https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L91 — Reply to this email directly, view it on GitHub https://github.com/apache/servicecomb-pack/issues/732#issuecomment-1034587480, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVDS4REIYGK6RACPDM7LH3U2NTX3ANCNFSM5NMM3IZA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.

chensk0601 avatar Feb 10 '22 09:02 chensk0601

你说的这个forMax超时的时候,应该是.event(Collections.singletonList(StateTimeout()) 2022年2月10日 下午3:40,Lei Zhang @.***> 写道: 这里有一个事件定义文档 https://github.com/apache/servicecomb-pack/blob/master/docs/fsm/design_fsm_zh.md#%E4%BA%8B%E4%BB%B6%E5%AE%9A%E4%B9%89 还有一个状态机设计 https://github.com/apache/servicecomb-pack/blob/master/docs/fsm/design_fsm_zh.md#%E7%8A%B6%E6%80%81%E6%9C%BA%E8%AE%BE%E8%AE%A1 你可以了解一下,SataTimeoutEvent 时间不是由 omega 发起的,我印象中是使用了 Akka 的 goTo()...forMax() 实现的,在相关状态 goto 的时候都要超时设置 https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L91 https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/main/java/org/apache/servicecomb/pack/alpha/fsm/SagaActor.java#L91 — Reply to this email directly, view it on GitHub <#732 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVDS4REIYGK6RACPDM7LH3U2NTX3ANCNFSM5NMM3IZA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you modified the open/close state.

是的,时间比较长了,我还有点印象不太深了,你可以跑以下单元测试

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/test/java/org/apache/servicecomb/pack/alpha/fsm/SagaActorTest.java#L809

和这个集成测试

https://github.com/apache/servicecomb-pack/blob/441a6adc14b8b2d6568411bcba56391649e6be5b/alpha/alpha-fsm/src/test/java/org/apache/servicecomb/pack/alpha/fsm/SagaIntegrationTest.java#L255

coolbeevip avatar Feb 10 '22 09:02 coolbeevip