dbeaver / cloudbeaver

Cloud Database Manager
https://dbeaver.com/
Apache License 2.0
3.36k stars 368 forks source link

Issue with SQL Editor Disconnecting While Editing Saved Script #2790

Closed matthieukhl closed 2 weeks ago

matthieukhl commented 1 month ago

Describe the bug In Community version 24.0.3, when working on a saved script, if the script is modified, CloudBeaver performs an automatic save. However, after the auto-save completes, the SQL editor disconnects from the database. This happens with both MySQL and ClickHouse connections. I've also reproduced this bug in Community version 24.1.2.

To Reproduce Steps to reproduce the behavior:

  1. Open a new script and write some basic SQL queries.
  2. Save the script.
  3. Edit your SQL scripts (e. g. add a new query or some random text) and wait for the auto-save to complete.
  4. The SQL Editor should be disconnected.

Desktop (please complete the following information):

Additional context 19-07-2024 07:05:48.023 [qtp878493504-1036] DEBUG i.c.m.r.l.LocalResourceController - Writing data to resource 'workspace/user-projects/<my_username>/git_hub_issue.sql in project <u_my_username>' 19-07-2024 07:05:48.103 [qtp878493504-1054] DEBUG i.c.server.graphql.GraphQLEndpoint - API > getResourceList 19-07-2024 07:05:48.188 [qtp878493504-1027] DEBUG i.c.server.graphql.GraphQLEndpoint - API > readResource 19-07-2024 07:05:48.190 [qtp878493504-1052] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 19-07-2024 07:05:48.250 [qtp878493504-1036] DEBUG i.c.server.graphql.GraphQLEndpoint - API > getResourceList 19-07-2024 07:05:48.263 [qtp878493504-1054] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 19-07-2024 07:05:48.263 [qtp878493504-1027] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 19-07-2024 07:05:48.328 [qtp878493504-1053] DEBUG i.c.server.graphql.GraphQLEndpoint - API > executionContextDestroy 19-07-2024 07:05:48.690 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - cb_scripts event handled 19-07-2024 07:05:48.690 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session xbr0hikyy3k61er3b8mr796lx101 19-07-2024 07:05:48.690 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session ju4i2ra8m5wo1dauq2a8or1fl102 19-07-2024 07:05:48.690 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session c1lwwmuee2ae1fjp7ta5qf19a58

LonwoLonwo commented 1 month ago

Hello @matthieukhl

Could you please provide more logs when the database disconnects? This is a very odd situation; we can not reproduce it for now.

matthieukhl commented 1 month ago

Hi @LonwoLonwo I've shared the logs when the database disconnects in the "Additional Context" section of the issue. Do you need more information? I can check if I can provide more details for the logs.

LonwoLonwo commented 1 month ago

You need to find something like this in the logs:

20:39:51.003 [qtp713702106-47] DEBUG o.j.d.m.i.AbstractExecutionContext - Execution context closed (postgres, 20)
20:39:51.016 [qtp713702106-47] DEBUG o.j.d.m.i.AbstractExecutionContext - Execution context closed (postgres, 21)
20:39:51.016 [qtp713702106-47] DEBUG o.j.d.registry.DataSourceDescriptor - Disconnected (postgres-jdbc-18d8db7616f-5732dbb8140e30e0)

About the disconnection moment.

matthieukhl commented 1 month ago

I haven't been able to find such logs but I have found the following:

So as I've said in my initial message these are the logs I observe when I try to edit a saved script:

24-07-2024 07:19:02.857 [qtp661440732-107] DEBUG i.c.m.r.l.LocalResourceController - Writing data to resource 'workspace/user-projects/<username>/test_script.sql in project u_<username>' 24-07-2024 07:19:02.924 [qtp661440732-105] DEBUG i.c.server.graphql.GraphQLEndpoint - API > getResourceList 24-07-2024 07:19:03.006 [qtp661440732-109] DEBUG i.c.server.graphql.GraphQLEndpoint - API > readResource 24-07-2024 07:19:03.009 [qtp661440732-102] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 24-07-2024 07:19:03.069 [qtp661440732-107] DEBUG i.c.server.graphql.GraphQLEndpoint - API > getResourceList 24-07-2024 07:19:03.095 [qtp661440732-102] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 24-07-2024 07:19:03.096 [qtp661440732-105] DEBUG i.c.server.graphql.GraphQLEndpoint - API > navNodeChildren 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - cb_scripts event handled 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session 6riy01h3itb1mzmgvwous3188 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session 15jcv68qn6pcw1q0eik1h0u9086 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session r52vz01wy2sn1bnzpzocaenzg7 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session 8htu91pwqr681ftzu98nknte75 24-07-2024 07:19:03.232 [DBeaver: CloudBeaver events job] DEBUG i.c.s.events.WSDefaultEventHandler - Cannot handle cb_scripts event 'cb_rm_resource_updated' in session 1foiasi3tfp7v1iji2tu57kt5y4

From this point nothing happens when I try running my queries, I do not get any results or errors.

When I click on "Select Connection" in the top menu to "reconnect" to my database I observed the following in the logs:

24-07-2024 07:22:35.618 [qtp661440732-117] DEBUG i.c.server.graphql.GraphQLEndpoint - API > setResourceProperty 24-07-2024 07:22:35.619 [qtp661440732-117] DEBUG i.c.m.r.l.LocalResourceController - Updating resource property 'default-catalog' in project 'u_<my_username>' 24-07-2024 07:22:35.620 [qtp661440732-117] ERROR o.j.dbeaver.registry.BaseProjectImpl - Error flushing project metadata java.nio.file.NoSuchFileException: /opt/cloudbeaver/workspace/user-projects/<my_username>/.dbeaver/project-metadata.json

As well as these logs:

24-07-2024 07:22:35.483 [qtp661440732-105] DEBUG i.c.m.r.l.LocalResourceController - Updating resource property 'default-projectId' in project 'u_<my_username>' 24-07-2024 07:22:35.483 [qtp661440732-105] ERROR o.j.dbeaver.registry.BaseProjectImpl - Error flushing project metadata java.nio.file.NoSuchFileException: /opt/cloudbeaver/workspace/user-projects/<my_username>/.dbeaver/project-metadata.json

24-07-2024 07:22:35.547 [qtp661440732-119] DEBUG i.c.m.r.l.LocalResourceController - Updating resource property 'default-datasource' in project 'u_<my_username>' 24-07-2024 07:22:35.547 [qtp661440732-119] ERROR o.j.dbeaver.registry.BaseProjectImpl - Error flushing project metadata java.nio.file.NoSuchFileException: /opt/cloudbeaver/workspace/user-projects/my_username/.dbeaver/project-metadata.json

I've checked the /opt/cloudbeaver/workspace/user-projects//.dbeaver/ path and can confirm the project-metadata.json file doesn't exist. It may seem that this isn't a disconnection issue. Could this explain the issue?

Please note that since my initial message I've upgraded cloudbeaver from 24.0.3 to 24.1.3 and am still observing the same behaviour.

alexander-skoblikov commented 1 month ago

Hi @matthieukhl, do you use custom file system permissions? Does the CloudBeaver container have write access to this folder /opt/cloudbeaver/workspace/user-projects/my_username/.dbeaver/? With correct behavior, project-metadata.json should be created automatically. Do you have any errors in your logs that it could not be created?

matthieukhl commented 1 month ago

There is this error in the logs

05-08-2024 14:11:17.196 [qtp661440732-1185] ERROR o.j.dbeaver.registry.BaseProjectImpl - Error flushing project metadata
java.nio.file.NoSuchFileException: /opt/cloudbeaver/workspace/user-projects/<my_username>/.dbeaver/project-metadata.json

I've checked in <my_username>/ folders there aren't any .dbeaver/ folders. So this explains the error.

What could cause this?

alexander-skoblikov commented 1 month ago

@matthieukhl I reproduced the problem in the following case - create a script in a private project without connections and select a connection from the shared project, in this case the .dbeaver folder is not created. we will fix this soon

matthieukhl commented 1 month ago

Thanks @alexander-skoblikov and @LonwoLonwo for taking the time to investigate this GitHub issue 👍

EvgeniaBzzz commented 2 weeks ago

Hi @matthieukhl Issue has been fixed in v.24.1.5, please, check it out. We appreciate your engagement with our project 🦫

matthieukhl commented 2 weeks ago

Thanks everyone for your time, will be updating to v24.1.5 tomorrow :)