gpt4 book ai didi

java - Mongodb 无法持久化事务状态,因为 session 事务集合丢失

转载 作者:行者123 更新时间:2023-12-02 10:40:02 25 4
gpt4 key购买 nike

我正在使用带有 Spring Boot 的 Mongodb 4 2.1.0-M4

以下代码在我的计算机上本地运行,但在开发环境中失败:

@Transactional
public void registerNewUser(UserRegistrationForm registrationForm)
throws IllegalArgumentException {

validator.validate(registrationForm);

User user = new User();
user.setEmail(registrationForm.email);
user.setPassword(encoder.encode(registrationForm.password));
user.setEnabled(false);
user.setGroups(Sets.newHashSet(ClientRoles.USER));

User saved = userRepository.save(user);

registrationService.sendInvitation(user.getEmail());
}

出现以下错误:

com.mongodb.MongoCommandException: Command failed with error 40527 (Location40527): 'Unable to persist transaction state because the session transaction collection is missing. This indicates that the config.transactions collection has been manually deleted.' on server mongodb-1-servers-vm-0:27017. The full response is { "operationTime" : { "$timestamp" : { "t" : 1540422989, "i" : 1 } }, "ok" : 0.0, "errmsg" : "Unable to persist transaction state because the session transaction collection is missing. This indicates that the config.transactions collection has been manually deleted.", "code" : 40527, "codeName" : "Location40527", "$clusterTime" : { "clusterTime" : { "$timestamp" : { "t" : 1540422994, "i" : 1 } }, "signature" : { "hash" : { "$binary" : "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "$type" : "00" }, "keyId" : { "$numberLong" : "0" } } } } at 

我不知道应该尝试调试什么,或者尝试什么,两个数据库都是相同的版本并且已初始化副本集。任何帮助表示赞赏。

最佳答案

实际上,这个错误是不言自明的。似乎由于某种原因,开发环境数据库中的 transactions 集合已被删除。修复方法很简单:

use config
db.createCollection("transactions",{})

关于java - Mongodb 无法持久化事务状态,因为 session 事务集合丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52979301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com