koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.36k stars 237 forks source link

Feature: Ensure atomicity for database operations #1172

Open Hieuzest opened 1 year ago

Hieuzest commented 1 year ago

Describe the problem related to the feature request

此提案由以下两个issue引出:

Describe the solution you'd like

暂时没有特别好的思路。 朴素的想法是。对于1)由Koishi引入全局的同步管理机制;对于2)在minato侧添加完善$push等操作符

Describe alternatives you've considered

No response

Additional context

No response

purerosefallen commented 1 year ago

第一个问题我认为需要在 createUser 的情况加一个锁。第二个也可以用锁或者 transaction 的形式来解决。 其中一个思路就是引入 mutex api,这些操作之前进行加锁之后处理。 minato 其实也比较缺乏对 transaction 的支持。