Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrip Debugger plugin does not load the latest function version #107

Open
chernia opened this issue Jul 17, 2023 · 8 comments · Fixed by #108
Open

DataGrip Debugger plugin does not load the latest function version #107

chernia opened this issue Jul 17, 2023 · 8 comments · Fixed by #108
Assignees
Labels
bug Something isn't working

Comments

@chernia
Copy link

chernia commented Jul 17, 2023

Describe the bug
When a function code is updated, the debugger does not load the new version unless one quits DataGrip and starts it agian.

To Reproduce
Steps to reproduce the behavior:

  1. Debug a function
  2. Change its code, verify the function is updated.
  3. Debug again in the same or new console
    The old code is loaded, unless DataGrip is restarted.

Expected behavior
When a function code changes, the debugger should load the new version on every debug run.

Desktop (please complete the following information):

  • OS: macOS Ventura 13.4.1
  • DataGrip 2023.1.2
  • DataGrip PostgreSQL Debugger plugin 231.0.1
@ng-galien
Copy link
Owner

Hi,

The plugin shares the Datagrip session. While the stored procedure code is loaded on every debugger step, that's possible the old function definition remains on the active session.

Please test update your code with ensuring the debugger session is closed ( in the task bar on bottom right) AND after deleting or closing your active session in the service panel.

When the stored procedure is updated it should have a different OID displayed on the code editor (in brackets after the procedure name).

Anyway code update workflow remains a big caveat of the debugger, hope this helps until we find a better solution.

@chernia
Copy link
Author

chernia commented Jul 18, 2023 via email

@ng-galien ng-galien self-assigned this Jul 18, 2023
@ng-galien ng-galien added the bug Something isn't working label Jul 18, 2023
@ng-galien
Copy link
Owner

Seems clearly a bug, thanks for your investigation. What's your PG version?

@chernia
Copy link
Author

chernia commented Jul 19, 2023 via email

@ng-galien
Copy link
Owner

@chernia the fix will be available next week.

@chernia
Copy link
Author

chernia commented Sep 1, 2023

Seems fine, but something else pops up:
[ERROR] Query failed LIST_BREAKPOINT ERROR: select() failed waiting for target (com.intellij.database.remote.jdbc.SQLExceptionWithProperties: ERROR: select() failed waiting for target)
The debugger hangs with lot of [01000] cache reference leak: cache pg_type (80), tuple 0/10 has count 577
and the breakpoint is left.

@ng-galien
Copy link
Owner

ng-galien commented Sep 2, 2023

@chernia here is my setup and test scenario:

  • lastest Intellij
  • Postgres image galien0xffffff/postgres-debugger:14 linux/arm64
CREATE OR REPLACE FUNCTION inner_debug(IN p_text text)
    RETURNS text
    LANGUAGE plpgsql
AS
$function$
    DECLARE
        v_test text;
BEGIN
    --Test
    v_test = p_text;
    v_test = v_test || ' -INNER -' || current_timestamp;
    return v_test;
end
$function$;

CREATE TABLE debug
(
    id   serial,
    name text
);

INSERT INTO debug (name) VALUES ('Debug 1');
INSERT INTO debug (name) VALUES ('Debug 2');

CREATE TYPE custom_type AS
(
    id   integer,
    name text
);


CREATE OR REPLACE FUNCTION public.test_debug(p_text text, p_int integer DEFAULT 0)
    RETURNS text
    LANGUAGE plpgsql
AS
$function$
DECLARE
    v_int_array   INT[]       = ARRAY [6, 7, 8];
    v_custom      custom_type = (434, 'Custom')::custom_type;
    v_debug_array debug[];
    v_debug       debug;
    v_text        TEXT        = 'hchc';
    v_int         INT         = 45;
    v_date        date        = NULL;
BEGIN
    --Test
    v_text = p_text;
    v_text = v_text || ' -' || current_timestamp;
    v_text = v_text || ' -' || current_timestamp;
    v_int_array = array_append(v_int_array, p_int);
    SELECT * FROM debug limit 1 into v_debug;
    v_int_array = array_append(v_int_array, 3);
    SELECT array_agg(d) FROM debug d into v_debug_array;
    v_int_array = array_append(v_int_array, 5);
    v_int_array = array_append(v_int_array, 7);
    v_text = inner_debug(p_text);
    v_int = v_int + 1;
    v_date = current_date;
    SELECT array_agg(id) FROM debug into v_int_array;
    return 'DEBUG END';
end
$function$;

In ran this

CREATE EXTENSION IF NOT EXISTS pldbgapi;
SELECT * FROM test_debug('ZZEZ', 1);
  1. Debug the select with the button (SELECT * FROM test_debug('ZZEZ', 1);
  2. At the first time the top breakpoint does not shows up 👎
  3. Stop the debug session
  4. Put a breakpoint
  5. Restart debug with the button
  6. Stops a the breakpoint
  7. Variables are quite ok
  8. Stop the debug session
  9. Modify public.test_debug
  10. Restart debug with the button
  11. Check the source code have changed
  12. Repeat from 6

Could you please provide more information that I can reproduce the problem? Thanks!
(If you use the same docker images on my docker hub repo, please update it because I've made some changes to it)

@chernia
Copy link
Author

chernia commented Nov 13, 2023

Thanks the test is fine. Reloads code. Once I got an error:
[ERROR] Query failed LIST_BREAKPOINT ERROR: select() failed waiting for target (com.intellij.database.remote.jdbc.SQLExceptionWithProperties: ERROR: select() failed waiting for target)
but could not reproduce.

Unfortunately on some functions, the Debug window closes immediately and when I open it, it says Nothing to show. How to find the problem? Do I need to set search_path in functions or session is enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants