Skip to content

Commit

Permalink
[#23250] YSQL: UT org.yb.pgsql.TestPgMemoryGC#testPgMemoryGcOrderBy i…
Browse files Browse the repository at this point in the history
…s failing with connection manager

Summary:
During the connection setup with postgres, there is a startup message shared with the client, the message contains the details of the backend pid, cipher key.  This info is persisted in the client side and can be used to cancel query if needed in the future.

With connection manager, the above BackendKeyData packet is intercepted by connection manager and the info is persisted as part of server details. And, the client id info is shared with the client app. Propagating backend pid would not help as the client can be attached to a different backend across queries. So, in the case of connection manager, the connection manager client id is shared with the client app and this same id can be used to cancel the query if needed.

As, the pid being shared with connection manager is not the true backend postgres id, I made the change to use `SELECT pg_backend_pid()` instead of `getPgBackendPid(connection)` which fetches the pid persisted in the client side.

Follow up tickets for this change are:
  - Write a UT to test cancel query functionality with connection manager - https://yugabyte.atlassian.net/browse/DB-12241
  - Document that the id persisted in JDBC is not the backend pid when connection manager is enabled - https://yugabyte.atlassian.net/browse/DB-12242

Jira: DB-12181

Test Plan:
Run the test and check that the test `./yb_build.sh --java-test 'org.yb.pgsql.TestPgMemoryGC#testPgMemoryGcOrderBy'` is working as expected.

Run the test and check that the test `./yb_build.sh --enable-ysql-conn-mgr-test --java-test 'org.yb.pgsql.TestPgMemoryGC#testPgMemoryGcOrderBy'` is working as expected.

Verify that the cancel query is working with connection manager.

Jenkins: test regex: .*TestPgMemoryGC.*, enable connection manager

Reviewers: mkumar, rbarigidad, asrinivasan, nkumar, skumar

Reviewed By: asrinivasan

Differential Revision: https://phorge.dev.yugabyte.com/D36774
  • Loading branch information
vpatibandla-yb committed Jul 30, 2024
1 parent 17828e2 commit 34e6e7a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMemoryGC.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -90,7 +91,9 @@ public void testPgMemoryGcOrderBy() throws Exception {
try (Statement stmt = connection.createStatement()) {
stmt.execute("SET work_mem='1GB'");

final int pgPid = getPgBackendPid(connection);
ResultSet rs = stmt.executeQuery("SELECT pg_backend_pid()");
rs.next();
final int pgPid = rs.getInt("pg_backend_pid");
final long rssBefore = getRssForPid(pgPid);

/*
Expand Down

0 comments on commit 34e6e7a

Please sign in to comment.