diff --git a/.github/workflows/greengage-ci.yml b/.github/workflows/greengage-ci.yml index 5f15e6292f85..72c94510e7bf 100644 --- a/.github/workflows/greengage-ci.yml +++ b/.github/workflows/greengage-ci.yml @@ -22,11 +22,15 @@ jobs: - target_os: ubuntu - target_os: ubuntu target_os_version: "24.04" + - target_os: rockylinux + target_os_version: "8" + - target_os: rockylinux + target_os_version: "9" permissions: contents: read # Explicit for default behavior packages: write # Required for GHCR access actions: write # Required for artifact upload - uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-build.yml@v33 + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-build.yml@v42 with: version: 6 target_os: ${{ matrix.target_os }} @@ -48,7 +52,7 @@ jobs: contents: read # Explicit for default behavior packages: read # Explicit for GHCR access clarity actions: write # Required for artifact upload - uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-tests-behave.yml@v28 + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-tests-behave.yml@v46 with: version: 6 target_os: ${{ matrix.target_os }} @@ -69,7 +73,7 @@ jobs: contents: read # Explicit for default behavior packages: read # Explicit for GHCR access clarity actions: write # Required for artifact upload - uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-tests-regression.yml@v28 + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-tests-regression.yml@v46 with: version: 6 target_os: ${{ matrix.target_os }} @@ -77,6 +81,28 @@ jobs: secrets: ghcr_token: ${{ secrets.GITHUB_TOKEN }} + coverage: + needs: [behave-tests, regression-tests] + if: github.event_name == 'pull_request' && needs.behave-tests.result == 'success' && needs.regression-tests.result == 'success' + strategy: + fail-fast: false + matrix: + include: + - target_os: ubuntu + target_os_version: "24.04" + permissions: + contents: read + packages: read + actions: write + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-coverage.yml@v46 + with: + version: 6 + target_os: ${{ matrix.target_os }} + target_os_version: ${{ matrix.target_os_version }} + coverage_threshold: 75 + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} + orca-tests: needs: build if: github.event_name == 'pull_request' # Only for PR @@ -154,7 +180,7 @@ jobs: contents: read # Explicit for default behavior packages: write # Required for GHCR access actions: write # Required for artifact upload - uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-package.yml@v38 + uses: greengagedb/greengage-ci/.github/workflows/greengage-reusable-package.yml@v44 with: version: 6 target_os: ${{ matrix.target_os }} diff --git a/README.Rhel-Rocky.bash b/README.Rhel-Rocky.bash index 702f38911871..1b55d5f95bc1 100755 --- a/README.Rhel-Rocky.bash +++ b/README.Rhel-Rocky.bash @@ -1,21 +1,57 @@ #!/bin/bash +# FILE: README.Rhel-Rocky.bash +# CONTEXT: Called from ci/Dockerfile.rockylinux for Greengage build +# PURPOSE: Install build dependencies, compile zstd static library, +# Install Python based on OS version -sudo dnf -y update -sudo dnf -y install epel-release -sudo dnf -y install 'dnf-command(config-manager)' -sudo dnf config-manager --set-enabled devel -sudo dnf makecache +set -eux -sudo dnf -y install\ +dnf -y install epel-release + +# Detect OS version if not already set +export OS_VERSION="${OS_VERSION:-$(grep -oP '(?<= release )\d+' /etc/redhat-release)}" + +case "$OS_VERSION" in + 8) + dnf config-manager --set-enabled powertools + python_packages="python2 python2-devel python2-setuptools \ + python3 python3-devel python3-setuptools" + perl_packages="perl-Env perl-ExtUtils-Embed \ + perl-IPC-Run perl-JSON perl-Test-Base" + ;; + 9) + dnf config-manager --set-enabled crb + python_packages="python3.11 python3.11-devel python3.11-setuptools" + perl_packages="perl-Env perl-ExtUtils-Embed \ + perl-IPC-Run perl-JSON perl-Test-Base \ + perl-Opcode perl-Test-Simple perl-Thread-Queue perl-devel" + ;; + *) + echo "Unsupported Rocky Linux version: $OS_VERSION" + exit 1 + ;; +esac +# shellcheck disable=SC2086 # intentional: word splitting for package lists +dnf -y install \ apr-devel \ + apr-util-devel \ + autoconf \ bison \ bzip2-devel \ - cmake3 \ + cmake \ + expat-devel \ flex \ - gcc \ gcc-c++ \ + git \ + glibc-langpack-en \ + gperf \ + indent \ iproute \ + java-11-openjdk-devel \ + jq \ krb5-devel \ + krb5-server \ + krb5-workstation \ libcurl-devel \ libevent-devel \ libicu \ @@ -29,18 +65,24 @@ sudo dnf -y install\ lsof \ net-tools \ openldap-devel \ - openssl \ + openssh-server \ openssl-devel \ pam-devel \ - perl-Env \ - perl-ExtUtils-Embed \ - perl-IPC-Run \ - perl-JSON \ - perl-Test-Base \ procps-ng \ - python2-devel \ - python2-pip \ readline-devel \ + rsync \ snappy-devel \ + sudo \ + time \ + unzip \ + vim \ + wget \ xerces-c-devel \ - zlib-devel + zlib-devel \ + $python_packages $perl_packages + +# Build zstd with static library (not available as a package on Rocky) +curl -Ls https://github.com/facebook/zstd/releases/download/v1.4.4/zstd-1.4.4.tar.gz | tar -xzf - +make -j"$(nproc)" -C zstd-1.4.4 +make install PREFIX=/usr/local -C zstd-1.4.4 +rm -rf zstd-1.4.4 diff --git a/README.linux.md b/README.linux.md index c73dfd9c4d96..1e646b26166d 100644 --- a/README.linux.md +++ b/README.linux.md @@ -6,23 +6,13 @@ ``` Note: CentOS 7 is EOL — configure `yum` to use a valid repo (e.g., `vault.centos.org`) before installing dependencies. -## For RHEL/Rocky 8: +## For RHEL/Rocky (versions 8 or 9): - Install dependencies using README.Rhel-Rocky.bash script: ```bash ./README.Rhel-Rocky.bash ``` -- Build and install zstd with static library, e.g.: - ```bash - cd /tmp - curl -LO https://github.com/facebook/zstd/releases/download/v1.4.4/zstd-1.4.4.tar.gz - tar -xf zstd-1.4.4.tar.gz - cd zstd-1.4.4 - make -j$(nproc) - sudo make install PREFIX=/usr/local - ``` - - Create symbolic link to Python 2 in `/usr/bin`: ```bash diff --git a/ci/Dockerfile.rockylinux b/ci/Dockerfile.rockylinux new file mode 100644 index 000000000000..6e066c0b8b4f --- /dev/null +++ b/ci/Dockerfile.rockylinux @@ -0,0 +1,82 @@ +# FILE: ci/Dockerfile.rockylinux +# CONTEXT: Build Greengage on Rocky Linux +# PURPOSE: Multi-stage Docker build for Greengage database + +ARG OS_VERSION=8 + +FROM rockylinux:${OS_VERSION} AS base +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /home/gpadmin + +ARG OS_VERSION +ENV OS_VERSION=${OS_VERSION} + +COPY README.Rhel-Rocky.bash ./ +COPY gpMgmt/bin/gpload_test/pytest_requirement.txt ./ +RUN set -eux; \ + ./README.Rhel-Rocky.bash; \ + rm README.Rhel-Rocky.bash; \ +# Set Python as default based on OS version + case "$OS_VERSION" in \ + 8) \ + ln -sf /usr/bin/python2 /usr/bin/python; \ + PIP_PACKAGES='allure-behave==2.4.0 mock==3.0.5 psi==0.3b3 future==0.16'; \ + ;; \ + 9) \ + ln -sf /usr/bin/python3.11 /usr/bin/python; \ + python -m ensurepip --upgrade; \ + PIP_PACKAGES='allure-behave==2.4.0 future==1.0.0'; \ + ;; \ + *) \ + echo "Unsupported Rocky Linux version: $OS_VERSION"; \ + exit 1; \ + ;; \ + esac; \ +# Install pg_bsd_indent used by pgindent utility + wget --progress=dot:giga --no-hsts https://ftp.postgresql.org/pub/dev/pg_bsd_indent-1.3.tar.gz -O - | tar -xzf -; \ + make install -C pg_bsd_indent; \ + rm -r pg_bsd_indent; \ +# To run sshd directly, but not using service + mkdir -p /run/sshd; \ +# Alter precedence in favor of IPv4 during resolving + echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf; \ +# Upgrade pip to support current package versions + python -m pip install --no-cache-dir --upgrade pip; \ +# Install allure-behave for behave tests + python -m pip install --no-cache-dir $PIP_PACKAGES; \ +# Install pytest for gpload test + python -m pip install --no-cache-dir --requirement pytest_requirement.txt; \ + rm pytest_requirement.txt; \ +# Cleanup to reduce image size + dnf clean all; \ + rm -rf /tmp/* /var/tmp/* /var/cache/man/ + +ENV LANG=en_US.UTF-8 +ENV CONFIGURE_FLAGS="--enable-debug-extensions --with-gssapi --enable-cassert --enable-debug --enable-depend" + +FROM base AS build + +COPY . gpdb_src + +RUN mkdir bin_gpdb + +ENV TARGET_OS=rockylinux \ + OUTPUT_ARTIFACT_DIR=bin_gpdb + +# Use python3 to compile into GPDB's plpython3u +# Set PYTHON3 only on Rocky 8 to avoid compiling plpython3 twice +# On Rocky 9, Python 3 is the default +RUN test "$OS_VERSION" -eq 8 && export PYTHON3=python3; \ + gpdb_src/concourse/scripts/compile_gpdb.bash + +FROM base AS code +COPY . gpdb_src +RUN rm -rf gpdb_src/.git/ + +FROM base AS test + +COPY --from=code /home/gpadmin/gpdb_src gpdb_src +COPY --from=build /home/gpadmin/bin_gpdb bin_gpdb +COPY --from=build /home/gpadmin/gpdb_src/VERSION gpdb_src + +RUN make -C gpdb_src/src/tools/entab install clean diff --git a/ci/readme.md b/ci/readme.md index 788480991f0a..d7499fa81e2b 100644 --- a/ci/readme.md +++ b/ci/readme.md @@ -14,6 +14,18 @@ To build an image based on Ubuntu 24.04, specify the version in build args: docker build -t gpdb6_regress:latest --build-arg OS_VERSION=24.04 -f ci/Dockerfile.ubuntu . ``` +To build a Rocky Linux 8 image: + +```bash +docker build -t gpdb6_rockylinux8:latest -f ci/Dockerfile.rockylinux . +``` + +To build a Rocky Linux 9 image: + +```bash +docker build -t gpdb6_rockylinux9:latest --build-arg OS_VERSION=9 -f ci/Dockerfile.rockylinux . +``` + There are two additional options in [Dockerfile](./Dockerfile) to passthrough urls for [sigar](https://github.com/hyperic/sigar) packages: * `--build-arg sigar=https://path_to_sigar.rpm` for package with sigar library diff --git a/ci/scripts/run_behave_tests.bash b/ci/scripts/run_behave_tests.bash index f5930c7a9879..f9c0c3b3fb3e 100755 --- a/ci/scripts/run_behave_tests.bash +++ b/ci/scripts/run_behave_tests.bash @@ -72,6 +72,7 @@ run_feature() { -e FEATURE="$feature" -e PROJECT="$project" \ cdw bash -eux <<'EOF' set -ex + source /usr/local/greengage-db-devel/greengage_path.sh cd /tmp/coverage-data if [ "$(ls "$PROJECT"-coverage-data/ | wc -l)" -gt 0 ]; then diff --git a/concourse/scripts/common.bash b/concourse/scripts/common.bash index 01b18be4caf5..bf0a41fe5a33 100644 --- a/concourse/scripts/common.bash +++ b/concourse/scripts/common.bash @@ -10,14 +10,12 @@ function set_env() { } function os_id() { - if [[ ! -f "/etc/altlinux-release" ]] && [[ -f "/etc/redhat-release" ]]; then - echo "centos" - else - echo "$( - . /etc/os-release - echo "${ID}" - )" + if [[ -f "/etc/os-release" ]]; then + . /etc/os-release + elif [[ -f "/etc/redhat-release" ]]; then + ID="centos" fi + echo "${ID}" } function os_version() { diff --git a/concourse/scripts/ic_gpdb.bash b/concourse/scripts/ic_gpdb.bash index 7f4fc654ba6a..93b5f8c5209d 100755 --- a/concourse/scripts/ic_gpdb.bash +++ b/concourse/scripts/ic_gpdb.bash @@ -34,6 +34,18 @@ function gen_env(){ export TEST_PGFDW=1 export COVERAGE_PROCESS_START="\${1}/gpdb_src/gpMgmt/test/coveragerc_unit" make -s ${MAKE_TEST_COMMAND} + + cd /tmp/coverage-data + if [ "\$(ls coverage-data* 2>/dev/null | wc -l)" -gt 0 ]; then + coverage combine --append --keep \ + --rcfile=/home/gpadmin/gpdb_src/gpMgmt/test/coveragerc_combine_report \ + coverage-data* + coverage html \ + --rcfile=/home/gpadmin/gpdb_src/gpMgmt/test/coveragerc_combine_report \ + --show-contexts -d ./coverage-html + else + echo "No coverage-data files found, skipping coverage report" + fi EOF chmod a+x /opt/run_test.sh diff --git a/concourse/scripts/setup_gpadmin_user.bash b/concourse/scripts/setup_gpadmin_user.bash index abaadae69db7..7b051e242a59 100755 --- a/concourse/scripts/setup_gpadmin_user.bash +++ b/concourse/scripts/setup_gpadmin_user.bash @@ -92,6 +92,7 @@ setup_sshd() { # Disable password authentication so builds never hang given bad keys sed -ri 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config + echo "MaxStartups 100:30:200" >> /etc/ssh/sshd_config case "$TEST_OS" in centos6 | sles*) diff --git a/gpMgmt/bin/gpcheckcat_modules/foreign_key_check.py b/gpMgmt/bin/gpcheckcat_modules/foreign_key_check.py index a0e1702d3396..f612f706d449 100644 --- a/gpMgmt/bin/gpcheckcat_modules/foreign_key_check.py +++ b/gpMgmt/bin/gpcheckcat_modules/foreign_key_check.py @@ -67,7 +67,8 @@ def checkTableForeignKey(self, cat): # skip these master-only tables skipped_masteronly = ['gp_relation_node', 'pg_description', 'pg_shdescription', 'pg_stat_last_operation', - 'pg_stat_last_shoperation', 'pg_statistic'] + 'pg_stat_last_shoperation', 'pg_statistic', + 'pg_event_trigger'] if catname in skipped_masteronly: return diff --git a/gpMgmt/bin/gppylib/commands/gp.py b/gpMgmt/bin/gppylib/commands/gp.py index cebc46538495..a973663bc872 100644 --- a/gpMgmt/bin/gppylib/commands/gp.py +++ b/gpMgmt/bin/gppylib/commands/gp.py @@ -1380,6 +1380,8 @@ def start_standbymaster(host, datadir, port, era=None, wrapper=None, wrapper_args=None): logger.info("Starting standby master") + datadir = os.path.normpath(datadir) + logger.info("Checking if standby master is running on host: %s in directory: %s" % (host,datadir)) cmd = Command("recovery_startup", ("python -c " diff --git a/gpMgmt/bin/gppylib/gpcatalog.py b/gpMgmt/bin/gppylib/gpcatalog.py index a237b299f2e0..1429cf723961 100644 --- a/gpMgmt/bin/gppylib/gpcatalog.py +++ b/gpMgmt/bin/gppylib/gpcatalog.py @@ -40,6 +40,7 @@ class GPCatalogException(Exception): 'pg_stat_last_shoperation', 'pg_statistic', 'pg_partition_encoding', + 'pg_event_trigger' ] # Hard coded tables that have different values on every segment diff --git a/gpMgmt/test/behave/mgmt_utils/gpactivatestandby.feature b/gpMgmt/test/behave/mgmt_utils/gpactivatestandby.feature index db4f2df47bce..0041b5ee7711 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpactivatestandby.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpactivatestandby.feature @@ -76,6 +76,20 @@ Feature: gpactivatestandby And the tablespace is valid on the standby master And clean up and revert back to original master + Scenario: master can be made on dir with trailing slash + Given the database is running + And the standby is not initialized + + When the user runs gpinitstandby with options "-S /tmp/standby_data/" + Then gpinitstandby should return a return code of 0 + And verify the standby master entries in catalog + + When the master goes down + And the user runs gpactivatestandby with options "-d /tmp/standby_data/" + Then gpactivatestandby should return a return code of 0 + And verify the standby master is now acting as master + And clean up and revert back to original master + ########################### @concourse_cluster tests ########################### # The @concourse_cluster tag denotes the scenario that requires a remote cluster diff --git a/gpMgmt/test/behave/mgmt_utils/gpexpand.feature b/gpMgmt/test/behave/mgmt_utils/gpexpand.feature index 1bf817c00be4..0e89444bf9fe 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpexpand.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpexpand.feature @@ -820,3 +820,20 @@ Feature: expand the cluster by adding more segments When the user runs gpexpand with the latest gpexpand_inputfile with additional parameters "--verbose" Then gpexpand should print "[DEBUG]:-Skipping tar file (gpexpand_schema.tar) copy to cdw" escaped to stdout And verify that the cluster has 1 new segments + + @gpexpand_verify_master_only + Scenario: Verify master only tables are not copied to segment + Given the database is not running + And a working directory of the test as '/data/gpdata/gpexpand' + And a temporary directory under "/data/gpdata/gpexpand/expandedData" to expand into + And a cluster is created with no mirrors on "cdw" and "sdw1" + And database "gptest" exists + And the user creates an event trigger test_trigger + And verify that event trigger test_trigger exists + Then verify that the query "SELECT count(*) FROM gp_dist_random('pg_event_trigger');" in database "gptest" returns "0" + When the user runs gpexpand interview to add 1 new segment and 0 new host "ignored.host" + Then the number of segments have been saved + When the user runs gpexpand with the latest gpexpand_inputfile without ret code check + Then gpexpand should return a return code of 0 + And verify that the cluster has 1 new segments + Then verify that the query "SELECT count(*) FROM gp_dist_random('pg_event_trigger');" in database "gptest" returns "0" diff --git a/gpMgmt/test/behave/mgmt_utils/gpinitstandby.feature b/gpMgmt/test/behave/mgmt_utils/gpinitstandby.feature index 8e4e37cdb631..bf9c5557775c 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpinitstandby.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpinitstandby.feature @@ -101,6 +101,16 @@ Feature: Tests for gpinitstandby feature Then gpinitstandby should return a return code of 0 And verify that the file "pg_hba.conf" in the master data directory has "no" line starting with "host.*replication.*(127.0.0.1|::1).*trust" + Scenario: gpinitstandby on dir with trailing slash + Given the database is running + And the standby is not initialized + + When the user runs gpinitstandby with options "-S /tmp/standby_data/" + Then gpinitstandby should return a return code of 0 + And verify the standby master entries in catalog + When execute sql "select datadir from gp_segment_configuration where content = -1 and role = 'm'" in db "postgres" and store result in the context + Then validate that "/tmp/standby_data/" is in the stored rows + @backup_restore_bashrc Scenario: gpinitstandby should not throw error when banner exists on the hsot Given the database is running diff --git a/gpMgmt/test/behave/mgmt_utils/gpstart.feature b/gpMgmt/test/behave/mgmt_utils/gpstart.feature index 4c7c21c74a8d..37ada7c76350 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpstart.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpstart.feature @@ -172,3 +172,20 @@ Feature: gpstart behave tests When the user runs psql with "-c 'drop user foouser;'" against database "postgres" Then psql should return a return code of 0 + + Scenario: gpstart on dir with trailing slash + Given the database is running + And the catalog has a standby master entry + And the standby is not initialized + + When the user runs gpinitstandby with options "-S /tmp/standby_data/" + Then gpinitstandby should return a return code of 0 + And verify the standby master entries in catalog + + When the master goes down + And the user runs "gpstart -a" + Then gpstart should return a return code of 0 + And verify the standby master entries in catalog + + When execute sql "select datadir from gp_segment_configuration where content = -1 and role = 'm'" in db "postgres" and store result in the context + Then validate that "/tmp/standby_data/" is in the stored rows diff --git a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py index 0f4866327ada..aa2ee38bf507 100644 --- a/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py +++ b/gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py @@ -4676,3 +4676,28 @@ def impl(context): def impl(context, second): cmd = Command(name='psql', cmdStr="-c 'SELECT * from generate_series(1, %s) a where pg_sleep(1) is not null;'" % second) cmd.runNoWait() + +@given('the user creates an event trigger {trigger_name}') +def impl(context, trigger_name): + func_name = "%s_fn" % trigger_name + with dbconn.connect(dbconn.DbURL(dbname=context.dbname), unsetSearchPath=False) as conn: + sql = """CREATE OR REPLACE FUNCTION %s() +RETURNS event_trigger +LANGUAGE plpgsql AS $$ +BEGIN + RAISE NOTICE 'Event trigger %s_fn fired after DDL command'; +END; +$$; +""" % (func_name, trigger_name) + + dbconn.execSQL(conn, sql) + sql = "CREATE EVENT TRIGGER %s ON ddl_command_start EXECUTE PROCEDURE %s();" % (trigger_name, func_name) + dbconn.execSQL(conn, sql) + conn.commit() + +@given('verify that event trigger {trigger_name} exists') +def impl(context, trigger_name): + with dbconn.connect(dbconn.DbURL(dbname=context.dbname), unsetSearchPath=False) as conn: + sql = "SELECT evtname FROM pg_event_trigger WHERE evtname = '%s';" % trigger_name + cursor = dbconn.execSQL(conn, sql) + assert cursor.rowcount == 1 diff --git a/gpMgmt/test/coveragerc_behave b/gpMgmt/test/coveragerc_behave index 699be39093ea..f4863d1eb17e 100644 --- a/gpMgmt/test/coveragerc_behave +++ b/gpMgmt/test/coveragerc_behave @@ -11,6 +11,8 @@ omit = */gpload_test/* $GPHOME/lib/python/pygresql/* $GPHOME/lib/python/yaml/* + $GPHOME/lib/python/pg.py + $GPHOME/lib/python/pgdb.py $GPHOME/lib/python/sitecustomize.py $GPHOME/lib/python/subprocess32.py $GPHOME/lib/python/subprocess32.pyc @@ -36,3 +38,9 @@ source3 = /home/gpadmin/gpdb_src/gpMgmt/bin/gppylib /home/gpadmin/gpdb_src/gpMgmt/bin/gppylib $GPHOME/lib/python/gppylib + +source4 = + /home/gpadmin/gpdb_src/gpAux/gpperfmon/src/gpmon + /home/gpadmin/gpdb_src/gpAux/gpperfmon/src/gpmon + $GPHOME/bin + $GPHOME/sbin diff --git a/gpMgmt/test/coveragerc_combine_report b/gpMgmt/test/coveragerc_combine_report index 23729e3b43cc..7e1b8e185365 100644 --- a/gpMgmt/test/coveragerc_combine_report +++ b/gpMgmt/test/coveragerc_combine_report @@ -19,15 +19,23 @@ source3 = $GPHOME/lib/python/gppylib source4 = - /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check/gp_replica_check.py - /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check/gp_replica_check.py - $GPHOME/bin/gp_replica_check.py + /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check + /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check + $GPHOME/bin + +source5 = + /home/gpadmin/gpdb_src/gpAux/gpperfmon/src/gpmon + /home/gpadmin/gpdb_src/gpAux/gpperfmon/src/gpmon + $GPHOME/bin + $GPHOME/sbin [report] omit = */__init__.py* */test/* $GPHOME/lib/python/pygresql/* + $GPHOME/lib/python/pg.py + $GPHOME/lib/python/pgdb.py $GPHOME/lib/python/yaml/* $GPHOME/lib/python/sitecustomize.py $GPHOME/lib/python/subprocess32.py diff --git a/gpMgmt/test/coveragerc_unit b/gpMgmt/test/coveragerc_unit index 6fa5b11654b6..75ca49e5fbdb 100644 --- a/gpMgmt/test/coveragerc_unit +++ b/gpMgmt/test/coveragerc_unit @@ -9,13 +9,15 @@ omit = */sitecustomize.py* */test/* */gpload_test/* - /usr/local/greengage-db-devel/lib/python/pygresql/* - /usr/local/greengage-db-devel/lib/python/yaml/* - /usr/local/greengage-db-devel/lib/python/sitecustomize.py - /usr/local/greengage-db-devel/lib/python/subprocess32.py - /usr/local/greengage-db-devel/lib/python/subprocess32.pyc - /usr/local/greengage-db-devel/bin/lib/pexpect/* - /usr/local/greengage-db-devel/lib/python/psutil/* + $GPHOME/lib/python/pygresql/* + $GPHOME/lib/python/pg.py + $GPHOME/lib/python/pgdb.py + $GPHOME/lib/python/yaml/* + $GPHOME/lib/python/sitecustomize.py + $GPHOME/lib/python/subprocess32.py + $GPHOME/lib/python/subprocess32.pyc + $GPHOME/bin/lib/pexpect/* + $GPHOME/lib/python/psutil/* */dist-packages/* /usr/local/bin/behave /usr/local/bin/coverage @@ -25,19 +27,19 @@ omit = source = /home/gpadmin/gpdb_src/gpMgmt/bin /home/gpadmin/gpdb_src/gpMgmt/bin - /usr/local/greengage-db-devel/bin + $GPHOME/bin source2 = /home/gpadmin/gpdb_src/gpMgmt/sbin /home/gpadmin/gpdb_src/gpMgmt/sbin - /usr/local/greengage-db-devel/sbin + $GPHOME/sbin source3 = /home/gpadmin/gpdb_src/gpMgmt/bin/gppylib /home/gpadmin/gpdb_src/gpMgmt/bin/gppylib - /usr/local/greengage-db-devel/lib/python/gppylib + /$GPHOME/lib/python/gppylib source4 = - /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check/gp_replica_check.py - /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check/gp_replica_check.py - /usr/local/greengage-db-devel/bin/gp_replica_check.py + /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check + /home/gpadmin/gpdb_src/gpcontrib/gp_replica_check + $GPHOME/bin diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 35315b2a0514..78053eea4dfb 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5241,7 +5241,6 @@ AtEOXact_GUC(bool isCommit, int nestLevel) * record it and restore QE before next query start */ if (Gp_role == GP_ROLE_DISPATCH - && !IsTransactionBlock() && changed && ((isCommit) || (!isCommit && gp_guc_need_restore)) && (gconf->flags & GUC_GPDB_NEED_SYNC)) @@ -5921,6 +5920,14 @@ set_config_option(const char *name, const char *value, errmsg("unrecognized configuration parameter \"%s\"", name))); return 0; } + /* + * Make SET LOCAL just SET when executing on segments. It is needed for + * correct passage of local GUCs as they might be discarded. Anyway, + * master executes SET as LOCAL, so on next transaction GUC will + * resynchronize and everything will be back in place. + */ + if (Gp_role == GP_ROLE_EXECUTE && action == GUC_ACTION_LOCAL) + action = GUC_ACTION_SET; /* * Check if option can be set by the user. diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index e909d02e8a44..aadd00ab92e3 100755 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -5555,3 +5555,24 @@ NOTICE: outer_func() done drop function outer_outer_func(int); drop function outer_func(int); drop function inner_func(int); +-- Test consistency and passage of SET LOCAL GUC to writing commands +create schema s; +do $$ +begin + set local search_path to s; + create table test_table(a int) distributed by (a); + drop table test_table; +end $$; +-- check existence on master and segments +with c as ( + select gp_segment_id, relname, relkind, relnamespace from pg_class + union all + select gp_segment_id, relname, relkind, relnamespace from gp_dist_random('pg_class') +) select gp_segment_id from c +join pg_namespace n on n.oid = c.relnamespace +where c.relname = 'test_table' and c.relkind = 'r' and n.nspname = 's'; + gp_segment_id +--------------- +(0 rows) + +drop schema s cascade; diff --git a/src/test/regress/expected/plpgsql_optimizer.out b/src/test/regress/expected/plpgsql_optimizer.out index c9c9347b8f15..6af96c227cbe 100755 --- a/src/test/regress/expected/plpgsql_optimizer.out +++ b/src/test/regress/expected/plpgsql_optimizer.out @@ -5533,3 +5533,24 @@ NOTICE: outer_func() done drop function outer_outer_func(int); drop function outer_func(int); drop function inner_func(int); +-- Test consistency and passage of SET LOCAL GUC to writing commands +create schema s; +do $$ +begin + set local search_path to s; + create table test_table(a int) distributed by (a); + drop table test_table; +end $$; +-- check existence on master and segments +with c as ( + select gp_segment_id, relname, relkind, relnamespace from pg_class + union all + select gp_segment_id, relname, relkind, relnamespace from gp_dist_random('pg_class') +) select gp_segment_id from c +join pg_namespace n on n.oid = c.relnamespace +where c.relname = 'test_table' and c.relkind = 'r' and n.nspname = 's'; + gp_segment_id +--------------- +(0 rows) + +drop schema s cascade; diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index 62dc38e92e90..f3a10de5d3ba 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -4232,3 +4232,28 @@ select outer_outer_func(20); drop function outer_outer_func(int); drop function outer_func(int); drop function inner_func(int); + +-- Test consistency and passage of SET LOCAL GUC to writing commands +--start_ignore +drop schema if exists s cascade; +--end_ignore + +create schema s; + +do $$ +begin + set local search_path to s; + create table test_table(a int) distributed by (a); + drop table test_table; +end $$; + +-- check existence on master and segments +with c as ( + select gp_segment_id, relname, relkind, relnamespace from pg_class + union all + select gp_segment_id, relname, relkind, relnamespace from gp_dist_random('pg_class') +) select gp_segment_id from c +join pg_namespace n on n.oid = c.relnamespace +where c.relname = 'test_table' and c.relkind = 'r' and n.nspname = 's'; + +drop schema s cascade;