Nacos: Error creating cache directory at startup time [starting the time register to create a cache directory error]

Created on 11 Sep 2019  ·  7Comments  ·  Source: alibaba/nacos

Issue Description

Type: bug report

Describe what happened (or what feature you want)

Error creating cache directory at startup time
启动时报建立缓存目录错误

Describe what you expected to happen

Occasionally reporting cache creation errors at startup,The error message is as follows:
启动时偶发性报建立缓存错误,错误信息如下:

java.lang.IllegalStateException: failed to create cache dir: /root/nacos/naming/public

at com.alibaba.nacos.client.naming.cache.DiskCache.makeSureCacheDirExists(DiskCache.java:155) ~[nacos-client-1.0.0.jar!/:na]

at com.alibaba.nacos.client.naming.cache.DiskCache.write(DiskCache.java:45) ~[nacos-client-1.0.0.jar!/:na]

How to reproduce it (as minimally and precisely as possible)

启动

Tell us your environment

centos 7、java8

Anything else we need to know?

com.alibaba.nacos.client.naming.cache.DiskCache类里面
第49行第50行的注释做了多实例冲突的优化处理,然而第153行同样的场景却未做同样的优化处理。
Inside the com.alibaba.nacos.client.naming.cache.DiskCache class
The comment in line 49, line 50, optimizes multi-instance conflicts, but the same scenario in line 153 does not.

kinbug

Most helpful comment

Virgo, it's not good to see any mistakes.

All 7 comments

Hi @lcg72, we detect non-English characters in the issue. This comment is an auto translation from @nacos-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Error creating cache directory at startup time [starting the time register to create a cache directory error]

Issue Description

Type: bug report

Describe what happened (or what feature you want)

Error creating cache directory at startup time
Start time register to create cache directory error

Describe what you expected to happen

Occasionally reporting cache creation errors at startup,The error message is as follows:
A sporadic report creates a cache error at startup, and the error message is as follows:

java.lang.IllegalStateException: failed to create cache dir: /root/nacos/naming/public

at com.alibaba.nacos.client.naming.cache.DiskCache.makeSureCacheDirExists(DiskCache.java:155) ~[nacos-client-1.0.0.jar!/:na]

at com.alibaba.nacos.client.naming.cache.DiskCache.write(DiskCache.java:45) ~[nacos-client-1.0.0.jar!/:na]

How to reproduce it (as minimally and precisely as possible)

start up

Tell us your environment

centos 7、java8

Anything else we need to know?

Inside the com.alibaba.nacos.client.naming.cache.DiskCache class
The comment on line 49 and line 50 does the optimization of the multi-instance conflict, but the same scenario on line 153 does not do the same optimization.
Inside the com.alibaba.nacos.client.naming.cache.DiskCache class
The comment in line 49, line 50, optimizes multi-instance conflicts, but the same scenario in line 153 does not.

I think this might happen rarely and only happen at first time(the directory /root/nacos/naming/public not exists).

Has it happened to you many times?

My application runs in docker, so every update will create a new docker container, and this error is often visible.

Virgo, it's not good to see any mistakes.

When the application of the new docker container restarts, there will be multiple configuration information to be cached. Example A first determines whether the directory exists or not, and then creates the directory if it does not exist. This takes a little time. When instance A has not built the directory yet, Example B judges that the directory does not exist, and also does the operation of creating the directory. Failure to create directories

I suppose this is thread conflicted at first, but now i think that is JVM conflicted .

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaostart977 picture xiaostart977  ·  7Comments

zscboy picture zscboy  ·  4Comments

837414750 picture 837414750  ·  4Comments

mark-wk picture mark-wk  ·  7Comments

yanlinly picture yanlinly  ·  6Comments