This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 147989 - MySQL can't be stopped.
Summary: MySQL can't be stopped.
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: MySQL (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: John Baker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-23 10:10 UTC by Roman Mostyka
Modified: 2008-10-03 16:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Mostyka 2008-09-23 10:10:19 UTC
1. Add MySQL server to the IDE and set in "Admin Properties" tab:
Start command: $MySQL\bin\mysqld.exe
Start arguments: --console
Stop command: $MySQL\bin\mysqladmin.exe
Start arguments: -u root shutdown
2. Start it. IDE will be automatically connected to the server.
3. Rightclick MySQL server's node and choose "Stop".

Result: After some time message that server can't be stopped appears. If user keeps waiting server still can't be
stopped. It was able to stop server with such admin properties before.
Comment 1 David Vancouvering 2008-09-24 21:04:46 UTC
One question: is there anything written to the output window?  I've been trying to reproduce on my Mac, but have
configuration problems; I'm trying it now in my VMWare XP virtual machine.
Comment 2 David Vancouvering 2008-09-24 22:01:34 UTC
I see the same problem, using 'net start' and 'net stop' - I can run from the command window, but it just does nothing
in NetBeans, and there is no output in the output window.
Comment 3 Roman Mostyka 2008-09-25 07:50:16 UTC
David, there is no output in the output window for me too.
Comment 4 David Vancouvering 2008-09-25 22:19:26 UTC
Now I can't reproduce it.  All I did was add some logging statements that weren't even activated during the run.  I'll
try removing them and see if that makes a difference, but I doubt it.  Sigh...
Comment 5 David Vancouvering 2008-09-25 22:50:18 UTC
Nope, works for me now, no matter what I do.  I think the other thing that change is I rebooted my Windows VM.  Perhaps
you can try rebooting and see if the problem goes away for you.

There have been bugs logged in the past where an attempt to connect to MySQL on Windows hangs, and I wonder if MySQL can
get "hung up" on Windows.

Did you try to start and stop from the command line using the same commands?
Comment 6 Roman Mostyka 2008-09-26 11:03:10 UTC
I tried after reboot, the same issue. I tried also to stop MySQL with the same arguments from command line and was
successful. Before I didn't have such problem. And I'm not sure that mysqladmin is running, at least I don't see it in
Windows Task Manager. Though it can disappear too quickly and therefore I don't see it.
Everything was fine before adding functionality with "keep waiting". And I'm constantly able to reproduce this issue.
But sometimes MySQL server is stopped, I can't say exact steps and other circumstances since I don't know them. :)
If it helps, we can setup VNC session and try to reproduce.
Anyway, I'll try with latest build and will see. But I was able to reproduce this issue on several latest builds, so I
don't think that problem has gone.
Comment 7 John Baker 2008-09-30 07:36:46 UTC
At least for my Linux installation, to shutdown MySQL, it's required to provide arguments.

Stop command: /home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin
Arguments:  -pmysql shutdown

If I enter this stop command with these arguments from the commandline, then MySQL is shut down.

However, it won't shutdown with or without these arguments.

Without arguments, the usage of the mysqladmin command is listed in the Output window:

/home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin  Ver 8.41 Distrib 5.0.67, for pc-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Administration program for the mysqld daemon.
Usage: /home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin [OPTIONS] command command....
  -c, --count=#       Number of iterations to make. This works with -i
                      (--sleep) only.
  -#, --debug[=name]  Output debug log. Often this is 'd:t:o,filename'.
Comment 8 John Baker 2008-09-30 08:00:10 UTC
Apparently, I need to provide both the username and password as arguments for the Stop command, even though
I provided both the username and password in the Basic properties section

Stop command: /home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin
Arguments:  -uroot -pmysql shutdown
(Stop works)

If the username and password are omitted from Arguments then an error is printed to the Output window:

Stop command: /home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin
Arguments:   shutdown

Result of attempting to stop:
/home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin: shutdown failed; error: 'Access denied; you need the SHUTDOWN
privilege for this operation'
Comment 9 John Baker 2008-09-30 08:17:15 UTC
Roman, 
1) from commandline, are you executing the shutdown command as root or mysql user?

2) What is the command you type from commandline to shutdown?

3) From NetBeans, when you try to shutdown, do you see this error about privileges ?

/home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin: shutdown failed; error: 'Access denied; you need the SHUTDOWN
privilege for this operation'
Comment 10 Roman Mostyka 2008-09-30 09:54:08 UTC
1) from commandline, are you executing the shutdown command as root or mysql user?
I reproduce this on Windows XP, so there is no mysql user and I'm executing the shutdown command as root.

2) What is the command you type from commandline to shutdown?
"mysqladmin.exe -u root shutdown". And this command works from commandline fine. It worked fine before in IDE too, but
not now.

3) From NetBeans, when you try to shutdown, do you see this error about privileges ?
/home/jbaker/bin/mysql-5.0.67-linux-i686/bin/mysqladmin: shutdown failed; error: 'Access denied; you need the SHUTDOWN
privilege for this operation'
No, I don't see this error. Probably because I reproduce it on Windows XP.
Comment 11 John Baker 2008-09-30 16:53:50 UTC
> 2) What is the command you type from commandline to shutdown?
"mysqladmin.exe -u root shutdown". And this command works from commandline fine. It worked fine before in IDE too, but
not now.


At least on Linux I have to provide the arguments 
-uroot -pmysql shutdown

(no space between -u and the username and same with the password)
Comment 12 John Baker 2008-09-30 18:17:38 UTC
Stop is not working 
On Windows XP, with these settings (no MySQL password configured)

Stop command: C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqladmin.exe
Arguments:    -uroot shutdown

Stop works from commandline: c:\> mysqladmin -uroot shutdown

Comment 13 John Baker 2008-09-30 18:53:24 UTC
I did a little debugging and the start command and arguments are getting passed.

I tried removing spaces from the path to the start command but that didn't seem to make any difference.

Next, I disabled the antivirus and found that now Stop works !
However, it looks like the antivirus must be disabled prior to starting NetBeans.

I don't know if there's any way to workaround the antivirus other than documenting how to disable checking Java processes
Comment 14 John Baker 2008-09-30 18:56:21 UTC
And the Stop argument for now root password should be

-uroot 
(no spaces between -u and root)


We may need to release note this as the only option ?
Comment 15 John Baker 2008-10-01 00:00:58 UTC
Antivirus is blocking the execution of mysqladmin from NetBeans.

We need to release note this.

Comment 16 David Vancouvering 2008-10-01 00:06:30 UTC
I agree that antivirus is the problem, but a release not is going to be pretty unhelpful.  

What about my suggestion that the error message when stop fails be appended to include a suggestion (if it's windows)
that perhaps antivirus is blocking the stop from succeeding?
Comment 17 John Baker 2008-10-01 01:40:58 UTC
I didn't see any other suggestion.  That's why I marked as RELNOTE and marked this as WONTFIX.

The suggestion is to add a message to the Output window?

Any new message will be added to bundle.properties, so this constitutes as a UI change and then the late UI change
process will have to be followed ?
Comment 18 John Baker 2008-10-01 01:43:03 UTC
In general, though, I think we need some note about excluding MySQL directories from being scanned, as recommended in
the MySQL docs:

http://dev.mysql.com/doc/refman/5.0/en/windows-installation.html
Comment 19 Roman Mostyka 2008-10-01 07:58:27 UTC
Actually for me MySQL can be stopped (but very rarely). But in the same time, I'm very rarely able to stop MySQL with
disabled antivirus. Can firewall be the reason also?
Comment 20 John Baker 2008-10-01 08:42:48 UTC
Actually, now on my Windows XP laptop, there is some pattern if MySQL is already running, regardless of whether the
antivirus is running.

1) Start MySQL from NetBeans
2) Exit NetBeans, restart, then choose Stop
Result - stop succeeds

3) Repeat 1 and 2
Result - stop fails

Roman, is this the same pattern you're seeing?

Also, after stopping the server successfully, when attempting to start MySQL again the MySQL node's context menu is not
opening and other nodes seem to be not responding immediately.  So, it appears a process or processes have not completed.
Comment 21 Roman Mostyka 2008-10-01 10:11:09 UTC
Yes, this pattern works for me. But I can reproduce even restart. I started NetBeans with fresh userdir and tried to
start and stop MySQL server in the same session and then I got error.
Comment 22 John Baker 2008-10-01 19:10:04 UTC
Roman,

> Yes, this pattern works for me.

OK, we agree on the steps in desc21.  

>  But I can reproduce even restart.
> I started NetBeans with fresh userdir and tried to
start and stop MySQL server in the same session and then I got error.

Maybe I didn't wait long enough for the error message to appear.
What does the error message say exactly, can you attach a screenshot or paste the text here.
Comment 23 John Baker 2008-10-02 00:03:14 UTC
If I set the path to the Administration Tool and supply the arguments -uroot shutdown then start the Administration tool
then shutdown works fine.

So the process to stop MySQL must not be executing correctly after starting MySQL from NetBeans
Comment 24 John Baker 2008-10-02 00:25:30 UTC
For testing purposes, I added a sleep of 10 seconds to MySQLDatabaseServer.stop() and now Stop works.

It appears "proc" is terminated as soon as proc.runProcess(...) terminates (almost immediately)

I don't know if adding a short sleep is the right fix or waitForStopAndDisconnect() needs to be executed
prior to  proc.runProcess(...)
Comment 25 John Baker 2008-10-02 05:24:50 UTC
4c1484fedff0
Comment 26 John Baker 2008-10-02 08:14:12 UTC
On Linux, stop works and the progress bar stops 

On Windows, stop works, but the progress bar continues

looking into this ...
Comment 27 John Baker 2008-10-02 09:22:32 UTC
b7238e4c0d48
progress bar is terminating now.
I should have used waitFor, not wait to wait for the process to complete
Comment 28 Roman Mostyka 2008-10-02 14:38:56 UTC
Verified with build 081002.
Comment 29 David Vancouvering 2008-10-02 17:26:16 UTC
Thanks for catching this and fixing it.  

DVC01
What happens if the process to stop MySQL (for whatever reason - remember it's user-configurable) never terminates? 
Then the progress bar will sit there indefinitely, and the user has no way to cancel it.

ProgressHandleFactory has a createHandle method that takes a Cancellable.  This allows the use to cancel a progress bar.
 In the cancel handler we can do proc.destroy().

Can you please add that?

DVC02
The logic of combining checkRunning() and waitFor() doesn't fully make sense.  It's more than possible, for instance,
that the stop process exits before the server stops.  Or that the server stops before the stop process exits.

Note that we call stop() and it runs asynchronously.  Then we have other logic (see
StopManager.waitForStopAndDisconnect()) that wait for the server to actually stop.  
Also, you only need to synchronize on proc when you are using Object.wait(), not Process.waitFor().

So I think you can just do

  try {
    proc = runProcess(getStopPath(), getStopArgs(), true, Utils.getMessage("LBL_MySQLOutputTab"));

    // wait for the process to stop
    proc.waitFor();
  } finally {
    if (proc != null) {
      proc.destroy();
    }
  }

Comment 30 John Baker 2008-10-02 20:31:30 UTC
ok done
f96430a5cb00

but should be re-verified
Comment 31 John Baker 2008-10-02 20:31:52 UTC
f96430a5cb00
Comment 32 David Vancouvering 2008-10-02 21:32:47 UTC
Looks good, thanks.
Comment 33 Quality Engineering 2008-10-03 14:35:00 UTC
Integrated into 'main-golden', will be available in build *200810031107* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f96430a5cb00
User: John Baker <jbaker@netbeans.org>
Log: #147989 add cancellable to the ProgressHandleFactory
Comment 34 Roman Mostyka 2008-10-03 16:31:20 UTC
Verified with build 081003. Again, John. ;)