流水账-20240314

Linux系统删除文件后,磁盘大小没变化

  • lsof +L1|grep 删除的文件名
  • kill进程
    在这里插入图片描述

mysql事务和neo4j事务冲突误诊

org.springframework.transaction.CannotCreateTransactionException: Could not open Neo4j Session for transaction; nested exception is org.neo4j.driver.v1.exceptions.AuthenticationException: The client is unauthorized due to authentication failure.
	at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doBegin(Neo4jTransactionManager.java:203)
	at org.sp...
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.neo4j.driver.v1.exceptions.AuthenticationException: The client is unauthorized due to authentication failure.
	at org.neo4j.driver.internal.util.ErrorUtil.newNeo4jError(ErrorUtil.java:58)
	at org.neo4j.driver.internal.async.inbound.InboundMessageDispatcher.handleFailureMessage(InboundMessageDispatcher.java:142)
	at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$ReaderV1.unpackFailureMessage(PackStreamMessageFormatV1.java:337)
	at org.neo4j.driver.internal.messaging.PackStreamMessageFormatV1$ReaderV1.read(PackStreamMessageFormatV1.java:301)
	at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:83)
	at org.neo4j.driver.internal.async.inbound.InboundMessageHandler.channelRead0(InboundMessageHandler.java:35)
	at 

在这里插入图片描述

描述

在使用mybatis-plus提供的批量插入方法的时候,报了上面的neo4j的错,实际上并不涉及neo4j操作
在这里插入图片描述

解决方法

项目中配置了mysqlneo4j,怀疑是事务冲突导致的,然后走了一圈弯路,因为根本没用到neo4j,所以一直没管上面的报错(neo4j服务连不上),结果发现并不是事务冲突导致的,就是neo4j连不上导致的。重置neo4j密码,连接成功之后,问题解决。在事务提交阶段,可能会检查所有参与事务的数据源,是否都能正常提交,因此批量保存方法事务中,虽然只对 MySQL 执行了操作,但 Neo4j 连接有问题,也会在事务提交时,导致整个事务回滚!

网上提供的方法

  • 创建一个新的事务

    @Service
    public class YourService {
    
        @Autowired
        private DataSource mysqlDataSource; // 引入MySQL数据源
    
        @Autowired
        private PlatformTransactionManager transactionManager; // 引入事务管理器
    
        public void yourMethod(List<YourEntity> entities) {
            TransactionTemplate template = new TransactionTemplate(transactionManager);
            template.setIsolationLevel(TransactionDefinition.ISOLATION_DEFAULT);
            template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
            template.execute(new TransactionCallbackWithoutResult() {
                @Override
                protected void doInTransactionWithoutResult(TransactionStatus status) {
                    yourService.saveBatch(entities); // 调用带有@Transactional的方法
                }
            });
        }
    }
    
  • 确保注解@EnableTransactionManagement只作用在想要的数据源事务管理器上

  • 按照上面方法试了半天也没解决,因为压根不是事务冲突导致的,SpringBoot项目一般不需要配置这些,默认使用的事务就是配置的第一个数据源
    在这里插入图片描述
    在这里插入图片描述

重置Neo4j密码,成功解决问题

高版本
  • 停止 Neo4j 服务bin/neo4j stop
    在这里插入图片描述

  • 直接编辑 Neo4j 配置文件conf/neo4j.conf,找到 dbms.security.auth_enabled 参数,将其设置为 false 来禁用身份验证
    在这里插入图片描述

  • 启动 Neo4j 服务bin/neo4j start
    在这里插入图片描述

  • 登录页面
    通过浏览器访问 Neo4j 的图形界面(地址通常是 http://localhost:7474http://your_ip:7474),由于身份验证已禁用,可以直接进入。
    在这里插入图片描述

  • Cypher 语句修改密码

     ALTER USER neo4j SET PASSWORD 'new_password';
    
    CALL dbms.changePassword('neo4j', 'old_password', 'new_password');
    CALL dbms.changePassword('neo4j', '', 'new_password');
    

在这里插入图片描述

低版本

上面通过Cypher 语句修改密码失败,因为项目使用的Neo4j 3.5 版本,不支持Cypher 语句更改用户密码,通过以下替代方法修改:

  • 通过 REST API 删除原有用户(neo4j),然后再创建一个新的管理员用户,设置新密码
    在这里插入图片描述

    curl -X DELETE http://localhost:7474/user/neo4j
    
    curl -X POST -H "Content-Type: application/json" -d '{"password":"new_password", "username": "neo4j", "roles": ["admin"]}' http://localhost:7474/user
    
  • 直接清空 graph.db 目录(不建议,个人环境随意)

相关推荐

  1. 20240311

    2024-03-14 17:26:01       38 阅读
  2. 20240311按键输入实验

    2024-03-14 17:26:01       41 阅读
  3. 20240313 大模型快讯

    2024-03-14 17:26:01       38 阅读
  4. 每日学习总结20240313

    2024-03-14 17:26:01       43 阅读
  5. 20240313-设计模式

    2024-03-14 17:26:01       35 阅读
  6. 20240317Python练习代码

    2024-03-14 17:26:01       41 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-14 17:26:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-14 17:26:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-14 17:26:01       82 阅读
  4. Python语言-面向对象

    2024-03-14 17:26:01       91 阅读

热门阅读

  1. [ffmpeg] 获取编译配置信息

    2024-03-14 17:26:01       35 阅读
  2. ffmpeg 通过遍历视频流,对视频帧进行打标

    2024-03-14 17:26:01       29 阅读
  3. Lua速成(1)

    2024-03-14 17:26:01       41 阅读
  4. Spring 整合 MyBatis、Junit

    2024-03-14 17:26:01       44 阅读
  5. springboot使用EasyExcel实现Excel导入导出

    2024-03-14 17:26:01       38 阅读