Skip to content

Behave: enable the gpcheckcat -x scenario - #2452

Closed
tuhaihe wants to merge 0 commit into
apache:mainfrom
tuhaihe:gpstart-m-reject-nonutility
Closed

tuhaihe wants to merge 0 commit into
apache:mainfrom
tuhaihe:gpstart-m-reject-nonutility

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Nov 30, 2026

Copy link
Copy Markdown
Member

The scenario "validate session GUC passed with -x is set" has the @not_implemented tag, so CI does not run it. Remove the tag.

The scenario starts the coordinator with gpstart -ma and expects gpcheckcat to fail without -x gp_role=utility. It fails on main, because Cloudberry does not reject non-utility connections to a utility-mode postmaster. The next commit restores that check.

Assisted-by: Claude Code

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context


@tuhaihe tuhaihe added this to the Behave tests milestone Nov 30, 2026
@tuhaihe

tuhaihe commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Error:

Scenario: validate session GUC passed with -x is set                                                                            # test/behave/mgmt_utils/gpcheckcat.feature:794
    Given the database is not running                                                                                             # test/behave/mgmt_utils/steps/mgmt_utils.py:272
    And the user runs "gpstart -ma"                                                                                               # test/behave/mgmt_utils/steps/mgmt_utils.py:564
    And "gpstart -ma" should return a return code of 0                                                                            # test/behave/mgmt_utils/steps/mgmt_utils.py:915
    Then the user runs "gpcheckcat -R foreign_key"                                                                                # test/behave/mgmt_utils/steps/mgmt_utils.py:564
    Then gpcheckcat should return a return code of 1                                                                              # test/behave/mgmt_utils/steps/mgmt_utils.py:915
      Traceback (most recent call last):
        File "/home/gpadmin/.local/lib/python3.9/site-packages/behave/model.py", line 1991, in run
          match.run(runner.context)
        File "/home/gpadmin/.local/lib/python3.9/site-packages/behave/matchers.py", line 105, in run
          self.func(context, *args, **kwargs)
        File "/__w/cloudberry/cloudberry/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py", line 919, in impl
          check_return_code(context, ret_code)
        File "/__w/cloudberry/cloudberry/gpMgmt/test/behave_utils/utils.py", line 186, in check_return_code
          raise Exception("expected return code '%s' does not equal actual return code '%s' \n%s" % (ret_code, context.ret_code, emsg))
      Exception: expected return code '1' does not equal actual return code '0' 
      STDOUT:
      Truncated batch size to number of primaries: 4
      
      Connected as user 'gpadmin' to database 'template1', port '7000', Cloudberry version '3.0'
      -------------------------------------------------------------------
      Batch size: 4
      Performing test 'foreign_key'
      Total runtime for test 'foreign_key': 0:00:00.10
      
      SUMMARY REPORT: PASSED
      ===================================================================
      Completed 1 test(s) on database 'template1' at 2026-11-30 00:39:53 with elapsed time 0:00:00
      Found no catalog issue

@tuhaihe

tuhaihe commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

New error:

make[1]: Leaving directory '/__w/cloudberry/cloudberry/src/backend'
echo "# +++ tap install-check in src/bin/pgbench +++" && rm -rf '/__w/cloudberry/cloudberry/src/bin/pgbench'/tmp_check && /usr/bin/mkdir -p '/__w/cloudberry/cloudberry/src/bin/pgbench'/tmp_check && cd . && TESTLOGDIR='/__w/cloudberry/cloudberry/src/bin/pgbench/tmp_check/log' TESTDATADIR='/__w/cloudberry/cloudberry/src/bin/pgbench/tmp_check' PATH="/usr/local/cloudberry-db/bin:/__w/cloudberry/cloudberry/src/bin/pgbench:$PATH" PGPORT='65432' top_builddir='/__w/cloudberry/cloudberry/src/bin/pgbench/../../..' PG_REGRESS='/__w/cloudberry/cloudberry/src/bin/pgbench/../../../src/test/regress/pg_regress' /usr/bin/prove -I ../../../src/test/perl/ -I .  t/*.pl
# +++ tap install-check in src/bin/pgbench +++

#   Failed test 'concurrent update with retrying status (got 1 vs expected 0)'
#   at t/001_pgbench_with_server.pl line 1374.

#   Failed test 'concurrent update with retrying stdout /(?^:processed: 2/2\b)/'
#   at t/001_pgbench_with_server.pl line 1374.
#                   ''
#     doesn't match '(?^:processed: 2/2\b)'

#   Failed test 'concurrent update with retrying stdout /(?^:number of transactions retried: 1\b)/'
#   at t/001_pgbench_with_server.pl line 1374.
#                   ''
#     doesn't match '(?^:number of transactions retried: 1\b)'

#   Failed test 'concurrent update with retrying stdout /(?^:total number of retries: 1\b)/'
#   at t/001_pgbench_with_server.pl line 1374.
#                   ''
#     doesn't match '(?^:total number of retries: 1\b)'

#   Failed test 'concurrent update with retrying stderr /(?^s:(client (0|1) sending UPDATE xy SET y = y \+ -?\d+\b).*client \2 got an error in command 3 \(SQL\) of script 0; ERROR:  could not serialize access due to concurrent update\b.*\1)/'
#   at t/001_pgbench_with_server.pl line 1374.
#                   'pgbench: error: connection to server on socket "/tmp/pN2Q2z_Bgj/.s.PGSQL.31848" failed: FATAL:  System was started in single node mode - only utility mode connections are allowed
# pgbench: error: could not create connection for setup
# '
#     doesn't match '(?^s:(client (0|1) sending UPDATE xy SET y = y \+ -?\d+\b).*client \2 got an error in command 3 \(SQL\) of script 0; ERROR:  could not serialize access due to concurrent update\b.*\1)'

#   Failed test 'deadlock with retrying status (got 1 vs expected 0)'
#   at t/001_pgbench_with_server.pl line 1458.

#   Failed test 'deadlock with retrying stdout /(?^:processed: 2/2\b)/'
#   at t/001_pgbench_with_server.pl line 1458.
#                   ''
#     doesn't match '(?^:processed: 2/2\b)'

#   Failed test 'deadlock with retrying stdout /(?^:number of transactions retried: 1\b)/'
#   at t/001_pgbench_with_server.pl line 1458.
#                   ''
#     doesn't match '(?^:number of transactions retried: 1\b)'

#   Failed test 'deadlock with retrying stdout /(?^:total number of retries: 1\b)/'
#   at t/001_pgbench_with_server.pl line 1458.
#                   ''
#     doesn't match '(?^:total number of retries: 1\b)'

#   Failed test 'deadlock with retrying stderr /(?^:client (0|1) got an error in command (3|5) \(SQL\) of script 0; ERROR:  deadlock detected\b)/'
#   at t/001_pgbench_with_server.pl line 1458.
#                   'pgbench: error: connection to server on socket "/tmp/pN2Q2z_Bgj/.s.PGSQL.31848" failed: FATAL:  System was started in single node mode - only utility mode connections are allowed
# pgbench: error: could not create connection for setup
# '
#     doesn't match '(?^:client (0|1) got an error in command (3|5) \(SQL\) of script 0; ERROR:  deadlock detected\b)'
# Looks like you failed 10 tests of 443.
t/001_pgbench_with_server.pl .. 
Dubious, test returned 10 (wstat 2560, 0xa00)
Failed 10/443 subtests 
	(3 TODO tests unexpectedly succeeded)
t/002_pgbench_no_server.pl .... ok

Test Summary Report
-------------------
t/001_pgbench_with_server.pl (Wstat: 2560 Tests: 443 Failed: 10)
  Failed tests:  434-443
  TODO passed:   4-6
  Non-zero exit status: 10
Files=2, Tests=651,  4 wallclock secs ( 0.06 usr  0.01 sys +  1.10 cusr  0.86 csys =  2.03 CPU)
Result: FAIL
make: *** [Makefile:63: installcheck] Error 1
make: Leaving directory '/__w/cloudberry/cloudberry/src/bin/pgbench'

We fixed it in 8c68e1d

@tuhaihe

tuhaihe commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Most of this PR is not new code. It aligns Cloudberry with Greenplum, which
already has the utility-mode connection check:

  • greenplum-db/gpdb c73183a9767 "Only utility connections are allowed for
    coordinator-only clusters" added the check in InitPostgres(), the
    retrieve-handler exception and the error message.
  • greenplum-db/gpdb 260710169a8 "Refactor gp_session_role check" moved the
    reset into assign_gp_role().
  • gpcheckcat -x (greenplum-db/gpdb 97cebb1cc1c) is already in Cloudberry,
    but the backend check it depends on is not, so its behave scenario was
    tagged @not_implemented. This PR enables it.

The Cloudberry-specific parts are small and come from features Greenplum
does not have:

  • Single-node deployments always run in the utility role, so the check uses
    IS_UTILITY_BUT_NOT_SINGLENODE().
  • Login monitor workers, background workers (for example, logical
    replication apply workers) and walsenders are exempt. They never send
    gp_role, and TAP test 035 fails without this.
  • The pgbench TAP test replaces PGOPTIONS, so it now keeps
    gp_role=utility.

User-visible change: after gpstart -m, a client must ask for utility mode,
for example PGOPTIONS='-c gp_role=utility' psql. gpstart and gpstop already
do this. The error message is the same as in Greenplum.

@tuhaihe
tuhaihe enabled auto-merge (squash) December 1, 2026 02:27
@tuhaihe tuhaihe closed this Dec 4, 2026
@tuhaihe
tuhaihe force-pushed the gpstart-m-reject-nonutility branch from 8c68e1d to afaa9c7 Compare December 4, 2026 10:05
auto-merge was automatically disabled December 4, 2026 10:05

Pull request was closed

@tuhaihe

tuhaihe commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

These commits has been included in #2457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant