manifold-systems / manifold-ij

IntelliJ plugin for Manifold
Other
17 stars 5 forks source link

Using manifold-sql and the manifold plugin causes IntelliJ to constantly open database connections. #40

Open oldshensheep opened 3 months ago

oldshensheep commented 3 months ago

My program startup failed.

Caused by: org.postgresql.util.PSQLException: FATAL: sorry, too many clients already

IntelliJ opened 90 connections, and my program opened 10 connections. The maximum allowed connection limit is 100.

image

Lots of connections are waiting for connect, green means new connection image

If I disable the plugin, it will be normal.

rsmckinney commented 3 months ago

Thanks for reporting this issue.

Can you provide more context? For instance, what type of activity leads to all the connections? Are you using IntelliJ Ultimate SQL features? Are you running tests, or just using the editors? Which version of IJ are you using? Etc. Thanks.

oldshensheep commented 3 months ago

I did some testing. I restarted IJ. This time, [.sql/] some sql doesn't have syntax highlighting but has code completion.

When I open the project for the first time, it opens 10 connections. If I open a code file containing [.sql/] some SQL, it opens another 10 connections. When I run my project, it opens another 20 connections.

Oh, I ran gradlew clean and ran my project again. It opened another 10 connections (total: 50). Oh, I ran gradlew clean, which opened another 20 connections. When I ran my project again, it opened another 10 connections (total: 80). Oh, while writing this comment, it opened another 20 connections (total: 100). It can't open any more connections.

for your questions:

  1. what type of activity leads to all the connections? don't know.
  2. Are you using IntelliJ Ultimate SQL features? Yes
  3. Are you running tests, or just using the editors? just using the editors, yes and run project (no test).
  4. Which version of IJ are you using? 2024.1.2 (241.17011.79)
oldshensheep commented 3 months ago

I found a way to reproduce this issue.

  1. gradlew clean
  2. Run project
  3. Stop
  4. Go to step 1
rsmckinney commented 3 months ago

Can you disable your IJ SQL postgresql connection to ensure that is not the issue? Thanks

oldshensheep commented 3 months ago

I removed IJ postgresql configuration and tried again, still the same issue.

rsmckinney commented 3 months ago

Ok thanks, just needed to eliminate that from the deck.

rsmckinney commented 3 months ago

You can try manifold release 2024.1.17, there was a statement leak in DDL execution.

oldshensheep commented 3 months ago

I have tried, and yesterday I had this issue once. Now it's hard to reproduce. I will close it if I can't reproduce it anymore.

I found another issue. When your code contains a SQL statement that uses a table that doesn't exist in the database, and you keep opening the file, you will find that IJ's CPU usage is extremely high. I looked at the database log and found it executes a lot of SQL every second. The SQL is the same as I provided below.

"[.sql/] insert into table_doesnt_exists(data) values(?) ".execute(ctx, data);
oldshensheep commented 3 months ago

This issue still exists, so I created a reproducer. For another issue, it's harder to reproduce and may be related to this issue, so let's fix this issue first.

https://github.com/oldshensheep/manifold-bug