ddev-intellij-plugin icon indicating copy to clipboard operation
ddev-intellij-plugin copied to clipboard

Database connection gets reset, losing existing console and commands

Open mglaman opened this issue 1 year ago • 11 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Are you sure that this bug is related to this DDEV Integration Plugin?

  • [X] I am sure

Enter your error report ID (If available)

No response

Describe the bug

When I stop working on a project and have commands in the database console, they are lost on the next time I start DDEV. It appears the database connection gets recreated instead of updating the port.

Steps to reproduce

  1. Open PhpStorm for project
  2. Run ddev start
  3. Open a query console
  4. Perform a query with the console.
  5. Run ddev poweroff
  6. Close PhpStorm
  7. Reopen PhpStorm
  8. Open query console, see previous command
  9. Run ddev start
  10. See open query console tab close, when reopened all contents lost

Additional context

No response

mglaman avatar May 14 '23 02:05 mglaman

I haven't used the PhpStorm console much, but remember that DDEV does have history in the mysql shell, so you can review and reissue your commands there. The history persists until you delete the project.

Since the port changes for the connection on ddev restart or ddev poweroff, I'm not at all sure one could resume a new session on the new port. Remember that the server is completely new in that case (even though it has database and command-line history stored).

However, related:

  • https://github.com/ddev/ddev/issues/3566

But even with the exact same port I'm not sure you could resume a session, but I'll bet you know more about this than I do.

rfay avatar May 14 '23 02:05 rfay

Before using this plugin I would manually edit the port, and everything was fine. I think this plugin is recreating the database connection configuration which causes the issue. It's not the end of the world, but it's a minor annoyance. I was going to dig in and see if I can figure it out

mglaman avatar May 14 '23 02:05 mglaman

It's right here: https://github.com/php-perfect/ddev-intellij-plugin/blob/main/src/main/java/de/php_perfect/intellij/ddev/database/DdevDataSourceManagerImpl.java#L22-L29

                if (currentLocalDataSource.getName().equals(dataSource.getName())) {
                    localDataSourceManager.removeDataSource(currentLocalDataSource);
                }

It does remove the data source to re-add

localDataSourceManager.addDataSource(dataSource);

I don't know the details, but maybe we can just update the connection string instead of a full removal and addition.

mglaman avatar May 14 '23 02:05 mglaman

This week I'll go through https://github.com/php-perfect/ddev-intellij-plugin/blob/main/CONTRIBUTING.md#development and see if I can get a PR created.

mglaman avatar May 14 '23 02:05 mglaman

Hi @mglaman, Yes the data source is currently recreated. A PR is very welcome! If you need any assistance, please let me know.

nico-loeber avatar May 15 '23 07:05 nico-loeber

I did it myself as I wanted to publish a new release today. Please let me know if this fixed your issues, @mglaman. The release 1.1.0 is currently pending JetBrains review and should be available in the store within the next few days. You can already download the new plugin version as zip attached to the release.

nico-loeber avatar May 19 '23 10:05 nico-loeber

But the configuration won't be equal because the port changes on each start. I'll work on a fix to try and only update the connection string still.

@mglaman, you're right I missed that point. I'm reopening that issue.

nico-loeber avatar May 22 '23 07:05 nico-loeber

@mglaman are you still interested in providing a pull request? Would be great to solve this issue in a better way! :)

nico-loeber avatar Jul 26 '23 10:07 nico-loeber

This seems like a resolved issue to me.

AkibaAT avatar Aug 25 '24 14:08 AkibaAT

Not sure it's resolved, but not sure if it's worth chasing either. I would think that existing things would be lost on a new port, for example (after ddev restart)

rfay avatar Aug 25 '24 15:08 rfay

IntelliJ DB console works perfectly fine on persisting existing consoles if you update the connection details.

mglaman avatar Aug 26 '24 13:08 mglaman