您好,欢迎来到飒榕旅游知识分享网。
搜索
您的当前位置:首页java.io.IOException: Input/output error

java.io.IOException: Input/output error

来源:飒榕旅游知识分享网

现象:项目中创建文件时正常,但是想加锁再写入时,在加锁使用FileChannel.tryLock后发生如下异常

java.io.IOException: Input/output error
	at sun.nio.ch.FileDispatcherImpl.lock0(Native Method)
	at sun.nio.ch.FileDispatcherImpl.lock(FileDispatcherImpl.java:94)
	at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1114)
	at java.nio.channels.FileChannel.tryLock(FileChannel.java:1155)
	at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.onApplicationEvent(AnnotationAwareAspectJAutoProxyCreator.java:147)
	at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.onApplicationEvent(AnnotationAwareAspectJAutoProxyCreator.java:66)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
	at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:108)
	at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:77)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:330)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at 
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)

经过多轮排查发现是文件存储系统的问题,这里记录下排除方法,以防忘记

  • 通过命令查看存储磁盘的挂载参数
    mount | grep /data/cache/
    /data/cache 是存储位置

    不可加锁的参数是这样的

  • 可以加锁的参数是这样的 

  • 修改磁盘挂载参数,增加nolock或者local_lock,但是要注意local_lock会被nolock覆盖

        修改方式如下红色圈起来的部分     

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务