Could not lock user prefs unix error code 2

The following appears in the atlassian-jira.log about every 30 seconds:

Symptoms

The following appears in the atlassian-jira.log about every 30 seconds:

Dec 14, 2011 9:28:51 AM java.util.prefs.FileSystemPreferences syncWorld
WARNING: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Dec 14, 2011 9:29:21 AM java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode
WARNING: Could not lock User prefs. Unix error code 2.

Cause

This occurs when the user being used to run a JIRA application doesn’t have a writeable home directory (for example:  /home/jira or ~jira didn’t exist). It is possible for a plugin to use the prefs module, which defaults to write to ~/.jira/

(info) It is possible the home directory was not created as part of the installation as process, as tracked under 

JRA-33595

Getting issue details…
STATUS

.

Resolution

  1. Create the user home directory. This is not $JIRA_HOME, it is the Linux user directory, for example /home/jira.
  2. Make sure the user running JIRA application has the proper permissions to access this direct
  3. If changing the permissions didn’t have any effect, add the following JVM parameter:
     -Djava.util.prefs.userRoot=/<some-writable-directory>

Last modified on Nov 1, 2018

Related content

  • No related content found

Problem

The following appears in the atlassian-confluence.log about every 2 milliseconds:

2014-09-28 13:24:33,960 WARN [Timer-10] [java.util.prefs] syncWorld Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username
2014-09-28 13:25:03,958 WARN [Timer-10] [java.util.prefs] checkLockFile0ErrorCode Could not lock User prefs.  Unix error code 2.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username
2014-09-28 13:25:03,960 WARN [Timer-10] [java.util.prefs] syncWorld Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username
2014-09-28 13:25:33,958 WARN [Timer-10] [java.util.prefs] checkLockFile0ErrorCode Could not lock User prefs.  Unix error code 2.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username
2014-09-28 13:25:33,960 WARN [Timer-10] [java.util.prefs] syncWorld Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username
2014-09-28 13:26:03,958 WARN [Timer-10] [java.util.prefs] checkLockFile0ErrorCode Could not lock User prefs.  Unix error code 2.
 -- referer: https://my.site.com | url: /display/SPACE/my+wiki | userName: username

Cause

This occurs when the user being used to run Confluence does not have a writeable home directory (for example:  /home/confluence or ~confluence didn’t exist). It is possible for a plugin to use the preferences module, which defaults to write to ~/.confluence/

Resolution

  1. Create the confluence user home directory. This is not $CONFLUENCE_HOME, it is the Linux user directory, for example /home/confluence.
  2. Make sure the user running Confluence has the proper permissions to access this directory. You may use the following commands:

    chown -R <user_running_confluence> <path-of-user_home>
    chmod -R u+rwX <path-of-user_home>
  3. If changing the permissions didn’t have any effect, add the following JVM parameter:

    -Djava.util.prefs.userRoot=/<some-writable-directory>

Last modified on Nov 2, 2018

Related content

  • No related content found

Problem

Warning message issued during the non-root or root startup of WebSphere stating that it can not lock the user or system preferences.

Symptom

The following message can be seen in the systemout.log:

[9/11/11 18:03:19:921 EDT] 00000001 prefs W java.util.prefs.FileSystemPreferences syncWorld Couldn’t flush user prefs: java.util.prefs.BackingStoreException: Couldn’t get file lock.
[9/11/11 18:03:49:929 EDT] 00000001 prefs W java.util.prefs.FileSystemPreferences checkLockFile0ErrorCode Could not lock User prefs. Unix error code 2.

Cause

The non-root ID that is being used to start WebSphere Application Server does not have a user_home directory. Therefore this non-root ID is unable to access the root user’s «/etc/.java/.systemPrefs». This produces the aforementioned warning messages every 30 seconds in the profile_root/logs/server_name/systemout.log.

The root ID used to start Websphere Application Server can not find the Java system pref file.

Diagnosing The Problem

For non-root, you can confirm this issue by trying to start WebSphere using the «root» ID. Review the Websphere_Home/profiles/<profile_name>/logs/<failing server_name/systemout.log to verify that you no longer see the warning messages.

For root, verify if the /etc/.java/.systemPrefs exists

Resolving The Problem

For non-root :

Create a User_Home directory for this non-root user and restart WebSphere Application Server. If this does not resolve the issue use the following 2 suggestions below :

NOTE : The «dot» in front of the directories below represent that these are «hidden» directories. So the «dot» must be in front of the directory name to go into the directory or to access them.

1. Try giving 755 permission for /home/wasadmin/.java/.userPrefs

2. Add «-Djava.util.prefs.userRoot=/home/wasadmin/preps» as a SDK generic jvm argument

To set the argument on the SDK:

  1. In the administrative console, click Servers > Server Types > WebSphere application servers , and select the server that you want to add the generic argument to..
  2. Then, in the Server Infrastructure section, click Java and process management > Process definition > Java virtual machine.
  3. Specify -Djava.util.prefs.userRoot=/home/wasadmin/preps for the Generic JVM Arguments property, and click OK .
  4. Click Save to save your changes.
  5. Restart the application server.

For root :

  1. Create a Java system pref directory
    sudo mkdir -p /etc/.java/.systemPrefs
  2. Restart the application server.

[{«Product»:{«code»:»SSEQTP»,»label»:»WebSphere Application Server»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud & Data Platform»},»Component»:»General»,»Platform»:[{«code»:»PF002″,»label»:»AIX»},{«code»:»PF010″,»label»:»HP-UX»},{«code»:»PF016″,»label»:»Linux»},{«code»:»PF027″,»label»:»Solaris»}],»Version»:»8.5.5;8.5;8.0;7.0;6.1″,»Edition»:»Base;Developer;Express;Network Deployment»,»Line of Business»:{«code»:»LOB45″,»label»:»Automation»}}]

@Chinthor

After finally creating a few working servers, the new ones I make give me these errors every 30 seconds in the server console, one right after the other:

WARNING: Could not lock User prefs. Unix error code 2.
WARNING: Couldn’t flush user prefs: java.util.prefs.BackingStoreException: Couldn’t get file lock.

Why does it now have this problem? I didn’t change anything in docker. It started when I copied a server container to a new working directory to test changes. But the identical server won’t run without this error when the original runs fine. And now I get this error in every container I try to make.

What gives?

@itzg

@Chinthor , since I have several images in this repo I just wanted to double check you’re trying the minecraft-server, right?

@itzg

…and tell me a little more about the procedure that corresponded with the problem starting.

@Chinthor

Thanks for the reply. Yes, it is the minecraft-server image. I’ve been trying to improve the main server I am running and eliminate some problems. Thought I’d duplicate the server and the world and then experiment on the copy. I copied the contents of the working directory to another folder, then used the same command as before to make a new container. This server will run, but gets the above errors. I get no errors if I make a «vanilla» forge server. But now if I try to dump mod files into a virgin container, the same errors come back.

Unrelated, I’m having issues between my server world and my own client. This despite installing a fresh instance and copying the mods and configs directly from the server itself. My fault for changing things to hastily, but I can’t find where I done goofed. My friends can play but I can’t. Frustrating. I’d create a completely fresh world and start testing from there, except for the Unix error business. This combination of errors that refuse to be analyzed is giving me a migraine.

Currently working on rebuilding A) a cloned server that works and can be tested upon, and B) my own client to match. Each done one mod at a time. I’ll repost if I find where the problem creeps in, but any thoughts you have would be great.

@Chinthor

Well, that was quick. Kinda. Found the mod with the problem. It begins with this line:
[bspkrsCore]: Initializing ModVersionChecker for mod bspkrsCore

And then tries to do this:
java.util.prefs.FileSystemPreferences$1 run

Followed by warnings that the file it wants to create cannot be created. Followed by the above errors every half minute. The problem is, this mod file is copied directly from a server directory that is working with no such errors. How can two containers made by the same user and running the same image run into different permissions problems? Especially if, as my googling suggests, it is caused when a user or user agent doesn’t have a /home directory. If I’m reading the documentation right, that user would be «minecraft» right? With the same image in both containers, both should have the same issue. Grrrr.

Sorry to vent. I’m sure you understand such frustration. I’m learning a lot, but having the same inputs give me different outputs is not conducive to learning. Only to head pain.

@itzg

I was just earlier today struggling with directory permissions with non-root container users…so, yeah, I totally understand.

I think you’re onto something with the /home directory permissions. The /data attach point is being managed by the startup script but I’ll have to see if I do anything with /home.

@Chinthor

Thanks again. I’ll also take this to the author of that mod. At the very least, there’s a chance that he doesn’t need to be writing to anyone’s /home directory. But since I’m completely new to the workings of docker, you’d be the expert on why this is happening so selectively. Cheers.

@itzg

Since my day job is Java development I happen to know that the preferences system on UNIXy systems uses the home directory structure for its backing store. (On Windows it uses the registry.)

So…if the mod developer is using Java preferences then that’s legit. I should be able to look at this more tonight.

@itzg

@Chinthor

Ooooh! Nice. So, will I have to edit the image? Rebuild one using your files? Or does this post indicate that you’ve stuck that in and I just have to delete my image and download again. Still new. Still learning.

FYI, ran into another bug. Will post as separate issue.

@itzg

The approach I use for ongoing development will probably work for you too:

  • Clone the dockerfiles repo (creating the fork first and cloning that is easier knowing that you’ll aim for a pull request)
  • Go into the minecraft-server directory and make your tweaks
  • Run docker build -t mc . to build an image with the current directory’s context and tag that image as «mc» (or whatever you want)
  • Now you can start a new container with your built image by replacing itzg/minecraft-server with mc

@Chinthor

Nice. Problem solution and a learning opportunity. Perfect.

Thanks again for all the help.

@itzg

And thank you.

BTW, if you need to debug the script execution you can add an --entrypoint=/bin/sh along with -it to drop into an interactive shell. Sometimes I’ll even tweak the script inside the container, run /start, tweak, repeat and then just bring the changes out to the checked out copy.

@itzg

Did you get a chance to look at this? I took a quick look just now and yep, the /home/minecraft directory doesn’t even exist:

# cd ~minecraft
/bin/sh: 8: cd: can't cd to /home/minecraft

itzg

added a commit
that referenced
this issue

Aug 30, 2016

@itzg

@itzg

@itzg

I went ahead and merged the fix and pushed to Hub. Its image ID is sha256:2ee91313cb28cb2037b32dad283f082b9bbff4860c521f6b884b01f84a01ddc9. Please give that a try @Chinthor and feel free to re-open the issue if you’re still seeing the problem.

Post Sun Sep 12, 2021 12:18 pm

Could not lock/flush user prefs messages

I just installed vanilla Debian Bullseye arm64 on a Raspberry Pi 4, then ffmpeg x264 dcraw openjdk 11 and Serviio 2.1. Serviio appears to be running ok — it’s presently indexing my media library, and I can play videos already added, but when i run ‘sudo systemctl status serviio.service’ at the console, I see the following:

  Code:
nick@serviio:~$ sudo systemctl status serviio.service
● serviio.service - Serviio media Server
     Loaded: loaded (/etc/systemd/system/serviio.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-09-12 21:45:32 AEST; 9min ago
   Main PID: 473 (java)
      Tasks: 145 (limit: 9242)
     Memory: 909.2M
        CPU: 11min 42.655s
     CGroup: /system.slice/serviio.service
             ├─ 473 java --add-modules jdk.unsupported -Xmx512M -Xms20M -XX:+UseG1GC -XX:GCTimeRatio=1 -XX:MinHeapFreeRatio=10 -XX:>
             └─4197 ffmpeg -i /mnt/library/Videos/Snooker/Masters2020/Extra-Day_2.mkv

Sep 12 21:52:19 serviio serviio.sh[473]: Could not lock User prefs.  Unix error code 2.
Sep 12 21:52:19 serviio serviio.sh[473]: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Sep 12 21:52:49 serviio serviio.sh[473]: Could not lock User prefs.  Unix error code 2.
Sep 12 21:52:49 serviio serviio.sh[473]: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Sep 12 21:53:19 serviio serviio.sh[473]: Could not lock User prefs.  Unix error code 2.
Sep 12 21:53:19 serviio serviio.sh[473]: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Sep 12 21:53:49 serviio serviio.sh[473]: Could not lock User prefs.  Unix error code 2.
Sep 12 21:53:49 serviio serviio.sh[473]: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
Sep 12 21:54:19 serviio serviio.sh[473]: Could not lock User prefs.  Unix error code 2.
Sep 12 21:54:19 serviio serviio.sh[473]: Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.
lines 1-21/21 (END)

The messages are happening at 90 second intervals. What causes the ‘Could not lock User prefs’ and ‘Couldn’t flush user prefs’ messages? Should I just ignore them? The serviio user is the owner of the serviio install dir and everything in it:

  Code:
nick@serviio:~$ ls -l /opt/serviio-2.1/
total 108
drwxr-xr-x 2 serviio serviio  4096 Sep 12 21:39 bin
drwxr-xr-x 2 serviio serviio  4096 May  3  2020 config
drwxr-xr-x 2 serviio serviio  4096 Sep 12 21:39 legal
drwxr-xr-x 2 serviio serviio  4096 Sep 12 21:39 lib
drwxrwxrwx 6 serviio serviio  4096 Sep 12 21:43 library
-rw-r--r-- 1 serviio serviio  3595 May  3  2020 LICENCE.txt
drwxr-xr-x 2 serviio serviio  4096 Sep 12 21:43 log
-rw-r--r-- 1 serviio serviio 10900 May  3  2020 NOTICE.txt
drwxrwxrwx 2 serviio serviio  4096 May  3  2020 plugins
-rw-r--r-- 1 serviio serviio  4636 May  3  2020 README.txt
-rw-r--r-- 1 serviio serviio 56845 May  3  2020 RELEASE_NOTES.txt
  • Top
  • Reply with quote

Понравилась статья? Поделить с друзьями:
  • Corosync parse error in config no interfaces defined
  • Could not load localization txt как исправить
  • Corona renderer error
  • Could not find or load main class java как исправить
  • Could not load library client как исправить