Bug 59780 - [IDE] Better handling of lock file issue
Summary: [IDE] Better handling of lock file issue
Status: RESOLVED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 141588 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-23 09:53 EDT by Brent Nicolle CLA
Modified: 2020-05-15 23:38 EDT (History)
18 users (show)

See Also:


Attachments
patch for better user experience (8.97 KB, patch)
2006-04-12 09:07 EDT, Helmut J. Haigermoser CLA
no flags Details | Diff
patch against the latest from HEAD, but still a bad solution and I do not endorse it (9.50 KB, text/plain)
2006-12-05 19:27 EST, Wassim Melhem CLA
no flags Details
Rebased to 3.0.0 and changed according to Wassims feedback (9.61 KB, patch)
2006-12-06 09:23 EST, Helmut J. Haigermoser CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Nicolle CLA 2004-04-23 09:53:41 EDT
This is an enhancement to improve the handling of a problem described
in bug 44735 and duplicated many times.

There are other ways to reproduce this problem, but here's mine:
1. Install Suse SLES 9 beta 3 out-of-the-box.
2. Set up as NFS client so that you can access your NFS-mounted home dir.
Unfortunately, statd process isn't running on your Linux NFS client,
but you didn't know to check.  Other apps seem to work OK.
3. Install Eclipse in your home dir.
4. Run Eclipse.
You get some kind of error message preventing Eclipse from starting up.
5. Throw Eclipse away; use Emacs instead.

From bug 44735 comment 39:

>Marking as wontfix since there isn't anything that we can do.
>
>Some file-systems and VMs just won't let us do locking properly. (for instance
>the HP-UX case)
>
>People who are having problems with a "non-standard" file-system and locking
>should ensure that no other users are currently running that workspace and then
>run with the System property to bypass the locking mechanism.
>
>Will add to README.

Judging from the number of times people are running into this (and judging
from the number of ways in particular a Linux-for-the-masses box may be 
configured) I wonder if the README and the command-line switch is the right
approach.  Furthermore, we can remind the user to read the README before
calling the support hotline.

Does something like the following work?
1. Catch the condition where lock is failing
(Ideally separate that from the condition where the lock mechanism works 
but the workspace is actually locked.  I have merged the two conditions
below.)
2. Pop up a dialog:
The specified workspace is in use or cannot be locked.
[Choose another workspace (default)] [Unlock] [Disable Lock]
3. If the user clicks on "Unlock",  try to manually remove
the lockfile, then retry locking it.  If this fails, return to #2.
4. If the user clicks on "Disable Lock", they get a
confirmation dialog:
"Are you sure?  Locking the workspace is recommended in
environments that support it, and you may be able to reconfigure
your environment.  Click Exit and review the README for advice
on enabling locks in your environment."
[OK] [Exit (the default)]
5. If the user clicks on "OK", Eclipse behaves as if the
"ignoreLockFile" arg was specified.
Comment 1 DJ Houghton CLA 2004-04-23 12:54:40 EDT
This will require coordination between the Core and UI teams. Adding NE to CC
for comment since the UI does the "startup dialogs and error dialogs work".
Adding JM to CC because I know he likes to get lots of email.
Comment 2 Nick Edgar CLA 2004-04-23 14:29:23 EDT
Adding Andrew since he's doing the real work here.
Comment 3 Jeff McAffer CLA 2004-04-23 15:33:37 EDT
We could consider using the osgi.locking system property in the config.ini.  In 
environments where java.nio locking does not work, set it to java.io.  If you 
actually don't want any locking set it "none" and no locking will be done.

I'm not sure you will actually be able unlock something that is locked by 
someone else in general.  If it is just a tag file, sure you might be able to 
delete it but if the originator is using nio, it is unlikely to work.
Comment 4 Hubert Baumeister CLA 2004-11-04 10:40:54 EST
The file locking issue has bitten quite a few people at my institute. These
people do not use eclipse because of the problem during startup. The problem has
increased as not only the workspace is being locked but also the configuration
(which, for a shared installation, resides in the .eclipse directory in the NFS
mounted home-directories; thus moving the workspace to a local filesystem, like
tmp, does not work anymore and osgi.locking has to be set to java.io). Of
course, when I get to know their problems I tell them how to use eclipse with
the osgi.locking=java.io setting.

I wonder if it would not be possible to write some code detecting the locking
behaviour of the file system and then choosing the appropriate locking strategy
automatically. For example, first create a new file in the workspace location
and then try to lock it. If acquiring the lock fails then locking using java.nio
is broken and should be set automatically (or maybe after notifying the user) to
java.io or none.

Judging on how often a duplicate of bug 4475 is filed, a lot of people seem to
have this problem. And I would guess that the number of people not filing a bug
report but just being annoyed by seeing "workspace in use, choose a different
one" for no apparent reason is larger.
Comment 5 Rafael Chaves CLA 2004-11-04 10:57:57 EST
"And I would guess that the number of people not filing a bug
report but just being annoyed by seeing "workspace in use, choose a different
one" for no apparent reason is larger."

The error message produced by UI is misleading (see bug 67053), and causes a lot
of confusion. When an IOException happens during Location.lock, the original
message should be presented instead. The error message produced by the framework
when Location.lock() fails because nio is not working is:

"An error occurred while locking file <file>: <original IOException message>. A
probably reason is that the file system or Runtime Environment does not support
file locking. You may want to choose a different location, or disable file
locking (using the osgi.locking property), but this can cause data corruption."

Another problem is that we didn't document the osgi.locking property for 3.0,
and this is handled by bug 77112.
Comment 6 Michael Van Meekeren CLA 2005-05-05 17:22:11 EDT
Rafael, what do you suggest we do here?  I'm not exactly sure what you're saying.
Comment 7 Rafael Chaves CLA 2005-05-05 18:26:37 EDT
My comments were in response to the last paragraph in comment 4, what has
already been addressed by bug 67053. 

The original issue is basically about: if locking fails with IOException, and
the current locking mechanism is java.nio, show a dialog to the user saying: "a
locking failure happened, do you want to continue without locking?"

This would also require Core to allow changing the locking method on-the-fly.
Comment 8 Helmut J. Haigermoser CLA 2006-04-12 09:07:28 EDT
Created attachment 38396 [details]
patch for better user experience

This patch adds a check to the IDEApplication.
The output of this "lock-check" is used to prompt
the user if no locking is possible asking
him whether locking shall be disabled and the 
workspace be fired up anyway...
Comment 9 Andrew Overholt CLA 2006-11-08 14:08:57 EST
We sometimes see Fedora users with this problem.  Can the better UI experience patch be applied?
Comment 10 Wassim Melhem CLA 2006-11-08 14:13:48 EST
but of course, Andrew.

Will take a look at the patch and if it plays well, we will have one of the Platform/UI committers release it.
Comment 11 Andrew Overholt CLA 2006-11-08 14:16:12 EST
(In reply to comment #10)
> Will take a look at the patch and if it plays well, we will have one of the
> Platform/UI committers release it.

Thanks, Wassim.  You, as usual, rock :)
Comment 12 Wassim Melhem CLA 2006-12-05 19:27:33 EST
Created attachment 55087 [details]
patch against the latest from HEAD, but still a bad solution and I do not endorse it

In our ongoing effort to keep our RedHat friends happy, I took the 'better user experience' patch in comment 8 on a test drive.  Unfortunately, it fails on a very basic scenario:

1. Launch a runtime workbench.  Keep the runtime instance (#1) up. 
2. Try to launch a second runtime instance on the same workspace as instance #1

Expected result and the result that you see without the patch: 
you get a message telling you the workspace is currently in use by another Eclipse application.  Great and accurate assessment.

Observed result with the patch: 
You get a message telling you that "the workspace is on a file system which does not support file locking.  Do you want to open the workspace without locking?  Please note that opening the same workspace a second time might cause data corruption and data loss.  Open Workspace?"

The assessment of the problem is way off.
I also found the message to be a bit scary, but maybe it's just me.  I have been a little skittish all day today :)

The patch did not apply cleanly to the latest ui.ide plug-in from head.  That's expected after a few months, so I am attaching an updated version of the same patch that would be a better point for the next revision.
Comment 13 Helmut J. Haigermoser CLA 2006-12-06 09:23:59 EST
Created attachment 55130 [details]
Rebased to 3.0.0 and changed according to Wassims feedback

This version will fix the problem with the misleading message. The check for a lockable workspace is now performed via a temporary file that is deleted right after the test, not via the .lock file itself.
Comment 14 Helmut J. Haigermoser CLA 2006-12-06 09:25:30 EST
(In reply to comment #13)
> Created an attachment (id=55130) [details]
> Rebased to 3.0.0 and changed according to Wassims feedback
> 
> This version will fix the problem with the misleading message. The check for a
> lockable workspace is now performed via a temporary file that is deleted right
> after the test, not via the .lock file itself.
> 
Sorry, should read: "Rebased to 3.3.0 M3,5 (as of 20061206)".
Thanks for the feedback, hope this patch passes the tests :)
Comment 15 Wassim Melhem CLA 2006-12-21 23:14:01 EST
Boris, can you please take it from here?
Comment 16 Boris Bokowski CLA 2007-06-19 16:56:12 EDT
Sorry, this bug must have fallen off my radar. Marking for 3.4.
Comment 17 Grant Gayed CLA 2007-10-29 11:12:18 EDT
*** Bug 141588 has been marked as a duplicate of this bug. ***
Comment 18 Boris Bokowski CLA 2008-05-02 14:56:55 EDT
Mass update - removing 3.4 target. This was one of the bugs I marked for investigation (and potential fixing) in 3.4 but I ran out of time. Please ping on the bug if fixing it would be really important for 3.4, and does not require API changes or feature work.
Comment 19 Martin Oberhuber CLA 2010-01-29 09:56:48 EST
While attached patch addresses the problems found when Java nio locking is not available for the Workspace, this is only part of the story - the Summary should perhaps be changed to "[IDE] Improve handling of workspace locking"

Our patch on bug 301226 should also be considered for addressing the case where the configuration area cannot be created on a read-only folder or cannot be locked with Java nio locking.

Addressing these two bugs could potentially allow removing the sections about osgi.locking on linux-gtk-ppc from the Eclipse README.
Comment 20 Anton Leherbauer CLA 2010-02-17 08:36:53 EST
Note that the actual locking method of Locker_JavaNio has changed since the patch was created.  Instead of

  lock = stream.getChannel().tryLock();

it should be

  lock = stream.getChannel().tryLock(0, 1, false);

See also http://bugs.sun.com/view_bug.do?bug_id=6628575 and bug 44735
Comment 21 Lars Vogel CLA 2020-05-15 23:38:36 EDT
AFAIK we use this NIO file system access to release the log. Please reopen if you plan to improve this handling.