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

Sync 2.3.0 changes #26

Merged
merged 48 commits into from
Dec 4, 2023
Merged

Sync 2.3.0 changes #26

merged 48 commits into from
Dec 4, 2023

Conversation

BenderArenadata
Copy link

@BenderArenadata BenderArenadata commented Oct 26, 2023

Our commits, which were reverted because of conflicts:

commit 3b06e37

Author: Alexander Kondakov <[email protected]>
Date:   Thu Jun 29 09:50:35 2023 +0300

    ADBDEV-3685 Error handling for disqkuota worker startup stage (#20)

commit 50ed2e4

Author: Vasiliy Ivanov <[email protected]>
Date:   Thu May 4 15:32:57 2023 +1000

    temporary disable upgrade tests

commit d5b5d1e

Author: Evgeniy Ratkov <[email protected]>
Date:   Mon Apr 24 14:04:06 2023 +0700

    add fixes to run regression tests in Docker container (#14)

commit e6899aa

Author: Georgy Shelkovy <[email protected]>
Date:   Wed Nov 22 11:42:29 2023 +0500

    Invalidate diskquota.table_size entries during startup (#27)

Commits, which were cherry-picked with changes

commit e6899aa

Author: Georgy Shelkovy <[email protected]>
Date:   Wed Nov 22 11:42:29 2023 +0500

    Invalidate diskquota.table_size entries during startup (#27)

   little change at order in src/quotamodel.c after adding commit 9f2b5043c5e47842108ad827a25b1ae4cb5c03ee

commit d5b5d1e

Author: Evgeniy Ratkov <[email protected]>
Date:   Mon Apr 24 14:04:06 2023 +0700

    add fixes to run regression tests in Docker container (#14)

    at commit fba3d06790a4123c4b8828f69f1b4d3a2c7e9c7c
    the most of scripts (which are needed for runnig tests) were move to private upstream repo.
    Script entry.sh was restored from our last version and moved to concourse directory.
    I added variable OS_NAME="rhel9" at running "build.sh" and "test.sh" in entry.sh to disable upgrade tests.
    Path "/home/gpadmin/bin_diskquota" was changed to "/home/gpadmin/diskquota_artifacts"
    not to do changes at our CI

Commit which is not needed:

commit 50ed2e4

Author: Vasiliy Ivanov <[email protected]>
Date:   Thu May 4 15:32:57 2023 +1000

    temporary disable upgrade tests

Commit, which was not cherry-picked because regression test fails:

commit 3b06e37

Author: Alexander Kondakov <[email protected]>
Date:   Thu Jun 29 09:50:35 2023 +0300

    ADBDEV-3685 Error handling for disqkuota worker startup stage (#20)

test fails at test_create_extension:

-- Wait after init so that diskquota.state is clean
SELECT diskquota.wait_for_worker_new_epoch();
NOTICE:  [diskquota] timeout when waiting for worker
HINT:  please check if the bgworker is still alive.
NOTICE:  [diskquota] timeout when waiting for worker
HINT:  please check if the bgworker is still alive.

At log I found that bgworker process was stopped:

,,,p14977,th-915277696,,,,0,con13,cmd508,seg-1,,,,,"DEBUG1","00000","[diskquota] free worker 0",,,,,,,0,,"diskquota.c",1750,
,,,p14977,th-915277696,,,,0,con13,cmd508,seg-1,,,,,"DEBUG1","00000","Cleaning up Greenplum components...",,,,,,,0,,"cdbutil.c",1173,
,,,p14977,th-915277696,,,,0,con13,cmd508,seg-1,,,,,"DEBUG1","00000","session dispatched 2 plans 5 slices (2.500000), largest plan 3",,,,,,,0,,"cdbutil.c",1184,
,,,p14786,th-915277696,,,,0,,,seg-1,,,,,"DEBUG1","00000","unregistering background worker ""diskquota bgworker 16384""",,,,,,,0,,"bgworker.c",378,
,,,p14786,th-915277696,,,,0,,,seg-1,,,,,"LOG","00000","worker process: diskquota bgworker 16384 (PID 14977) exited with exit code 1",,,,,,,0,,"postmaster.c",4014,

Without this commit bgworker is stared after each CREATE EXTENSION diskquota commands:

p16914,th532994176,,,,0,con14,cmd3,seg-1,,,,,"DEBUG1","00000","[diskquota] free worker 0",,,,,,,0,,"diskquota.c",1747,
p16914,th532994176,,,,0,con14,cmd3,seg-1,,,,,"DEBUG1","00000","Cleaning up Greenplum components...",,,,,,,0,,"cdbutil.c",1173,
p16914,th532994176,,,,0,con14,cmd3,seg-1,,,,,"DEBUG1","00000","session dispatched 1 plans 3 slices (3.000000), largest plan 3",,,,,,,0,,"cdbutil.c",1184,
p16696,th532994176,,,,0,,,seg-1,,,,,"DEBUG1","00000","unregistering background worker ""diskquota bgworker 16384""",,,,,,,0,,"bgworker.c",378,
p16696,th532994176,,,,0,,,seg-1,,,,,"DEBUG1","00000","worker process: diskquota bgworker 16384 (PID 16914) exited with exit code 0",,,,,,,0,,"postmaster.c",4014,
p16724,th532994176,,,,0,con4,cmd5,seg-1,,,,,"DEBUG1","00000","[diskquota] got sigusr1",,,,,,,0,,"diskquota.c",883,
p16724,th532994176,,,,0,con4,cmd5,seg-1,,,,,"DEBUG1","00000","[diskquota] gets a worker 0",,,,,,,0,,"diskquota.c",1937,
p16696,th532994176,,,,0,,,seg-1,,,,,"DEBUG1","00000","registering background worker ""diskquota bgworker 24593""",,,,,,,0,,"bgworker.c",349,
p16696,th532994176,,,,0,,,seg-1,,,,,"DEBUG1","00000","starting background worker process ""diskquota bgworker 24593""",,,,,,,0,,"postmaster.c",6111,
p16724,th532994176,,,,0,con4,cmd5,seg-1,,,,,"DEBUG1","00000","[diskquota] next db to run:16384",,,,,,,0,,"diskquota.c",793,
p16724,th532994176,,,,0,con4,cmd5,seg-1,,,,,"DEBUG1","00000","[diskquota] got sigusr1",,,,,,,0,,"diskquota.c",883,
p16946,th532994176,,,,0,con15,,seg-1,,,,,"DEBUG1","00000","InitProcess(): gp_session_id 15, Gp_role 1",,,,,,,0,,"proc.c",486,
p16946,th532994176,,,,0,con15,,seg-1,,,,,"DEBUG1","00000","[diskquota] start disk quota worker process to monitor database:test_db1",,,,,,,0,,"diskquota.c",438,

higuoxing and others added 30 commits May 25, 2023 17:30
Note: `TextDatumGetCString()` returns a null-terminated CString.

```
[ 12%] Building C object CMakeFiles/diskquota.dir/src/diskquota.c.o
In file included from /home/v/workspace/diskquota/src/diskquota.h:16,
                 from /home/v/workspace/diskquota/src/diskquota.c:18:
/home/v/workspace/diskquota/src/diskquota.c: In function ‘diskquota_status_schema_version’:
/home/v/.local/gpdb7/include/postgresql/server/c.h:957:25: warning: ‘strncpy’ specified bound 64 equals destinatio
n size [-Wstringop-truncation]
  957 |                         strncpy(_dst, (src), _len); \
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/v/workspace/diskquota/src/diskquota.c:1548:9: note: in expansion of macro ‘StrNCpy’
 1548 |         StrNCpy(version, vv, sizeof(version));
      |         ^~~~~~~
```

Co-authored-by: Hao Zhang <[email protected]>
Fix bug produced by #339 

Co-authored-by: Xing Guo [email protected]
fix pipeline resource
# Problem
Recording active tables and permission checking on segments rely on `monitored_dbid_cache`. But after mirror switching, the data in shared memory is lost, and the above behaviors will be blocked.

# Solution
Segments update their `monitored_dbid_cache` after receiving pull_active_tables_oid requests every naptime.
To achieve upgrading directly from 2.0 to 2.2, we should do the following things:
- cherry-pick this PR in diskquota-2.0, diskquota-2.1 and diskquota-2.2.
- set the shared_preload_libraries as `diskquota-2.2`: `gpconfig -c shared_preload_libraries -v 'diskquota-2.2'`
- restart cluster: `gpstop -ar`
- execute the following SQLs:
```
ALTER extension diskquota update to '2.2';
```
Get the latest package version for release resource.
- Because of 97f1f9b, the sql file directory has been changed. The
  sql version check wouldn't work since it cannot find the sql files
  anymore. Change it to the correct ddl directory.
- 'exec_program' is deprecated, use 'execute_process' instead.
- 'git tag | sort' returns the latest version among all branches, but
  not the closest tag to the current commit. Use 'git describe --tags'
  instead. So the upgrade version check will work for the 2.1.x patch
  release.
After creating extension, the `diskquota.state` is always `unready` due to the change greenplum-db/gpdb#15239. It makes the test timeout. We disable the job of gp7 in release/pr/merge pipeline until the problem is fixed.
- By #340, diskquota should be able to upgraded directly from any previous
  version. A script is added to test this.
- Modify the cmakefile so before installing/packaing, only previous so
  files will copied. This would help us to make patch release for
  2.0/2.1.

---------

Co-authored-by: Zhang Hao <[email protected]>
- bump version to 2.2.2
- Modify the check procedure of alter extension.
git-subtree-dir: concourse/lib
git-subtree-split: d51adf5d59e4e5caefb678b29c4335881040c7d2
Change the CI pipeline to release diskquota for GP7.

TODO:
- enable regress test on CI.
- enable activatestandby test for GP7 on CI.
- fix regress test for GP7. The view in GP7 will be treated as a relation by diskquota. After `CREATE EXTENSION`, the test case should execute `SELECT diskquota.init_table_size_table()` to make the diskquota.state ready on GP7.
Fix the following issues:

diskquota cannot correctly print a warning when calling
`create extension` in a non-empty database. The diskquota.state shows
whether the current database is empty. Previously, we updated the
status to diskquota.state during `create extension` and queried the
status in UDF `diskquota.diskquota_start_worker`. When querying the
database status, the relations whose `relkind in ('v', 'c', 'f')` are
skipped, while all relations are filtered when updating the database
status. This patch merges the two SQL statements to `INSERT RETURNING`
to solve this problem.
Benefit: we won't need to upgrade the minor version of diskquota when
changing the statement.

Remove useless test `test_update_db_cache`. The behavior of the
bgworker scheduler is changed, so this test is no longer helpful.

Update the upgrade test script `2.2_set_quota`. Since the above issue,
there should be `select diskquota.init_table_size_table()` in
`2.2_set_quota`.

Add upgrade test for gp7.

Fix upgrade test for gp6.
Fix the standby test on GP7.
All tables in diskquota use primary keys. Unique index tables are created for primary keys.
Unique index tables can not be created for tables with the option appendonly=true. This 
issue only occurs in gp6 since `set gp_default_storage_options='appendonly=true';` is 
disabled in gp7. Solution: add `appendonly=false` to each table with the primary key.

Co-authored-by: Evgeniy Ratkov <[email protected]>
During the upgrade procedure, when diskquota.so is not in 
shared_preload_libraries, check whether the current version 
is the final version:
- If yes, throw an error to the user.
- Otherwise, return from _PG_init().

Co-authored-by: Sasasu <[email protected]>
This GUC shows the max number of database diskquota can monitor.
- Fix the compilation issue caused by GP7. `libpq.so` needs to be linked. 
  See greenplum-db/gpdb#16234.
- Add GP7 jobs back to the pipeline.
`diskquota.max_quotas` shows the max number of quotas on the cluster.
In the current version of diskquota, quotas means:
- role
- schema
- role_tablespace
- schema_tablespace

The number of quota =
       role + schema + (role * tablespace) + (schema * tablespace).
zhrt123 and others added 10 commits October 18, 2023 16:18
- skip add last version to the current build.
- skip upgrade test.
Co-authored-by: Chen Mulong <[email protected]>
Co-authored-by: Xing Guo <[email protected]>
Merge all types of quota info maps into one in each bgworker.
The package name is incorrect when releasing package in Rocky9/RHEL9
platforms (<package>-<version>-unknown_x86_64.tar.gz). This patch fix
it to <package>-<version>-rhel9_x86_64.tar.gz.

Cherry-pick pivotal/timestamp9#41
@red1452 red1452 changed the base branch from gpdb to 2.3.0-sync2 November 23, 2023 03:47
red1452 and others added 2 commits November 23, 2023 06:48
Diskquota calculates sizes and stores information in the diskquota.table_size
table periodically with a pause in diskquota.naptime, 2 seconds by default.
If we restart the cluster during this pause, then diskquota will lose all
changes that have occurred since the last save to the diskquota.table_size
table. We could create temporary tables, wait when it will be flushed to
diskquota.table_size table, restart the cluster, and diskquota would remember
the information about the temporary tables. Or we could delete the tables,
restart the cluster, and again diskquota will remember information about the
deleted tables. This happens because at the start of the cluster, diskquota
remembers all the information written to the diskquota.table_size table,
but does not check that some tables may have already been deleted.

As a solution, we invalidate diskquota.table_size during diskquota
worker start in addition to pg_class validation.
Removed useless commands from `concourse/scripts/entry.sh`, because our
docker images already have source of GPDB at `/home/gpadmin/gpdb_src`
and do not need to create or configure this directory.
Added file `arenadata/README.md` with information about how to run
tests at docker container.
Removed `--load-extension=diskquota_test` from `CMakeLists.txt` at regression
tests. Creating extension `diskquota_test` requires configured extension `diskquota`.
But `diskquota` is configured when `tests/regress/sql/config.sql` is executed, and
load-extension is done before this test is started. At all tests (where `diskquota_test`
is used) command `CREATE EXTENSION diskquota_test;` is executed.

This commit is cherry-picked from commit d5b5d1e.
Original commit was modified because at commit fba3d06
the most of scripts (which are needed for runnig tests) were move to private upstream repo.
Script entry.sh was restored from our last version and moved to concourse directory.
I added variable OS_NAME="rhel9" at running "build.sh" and "test.sh" in entry.sh to disable upgrade tests.
Path "/home/gpadmin/bin_diskquota" was changed to "/home/gpadmin/diskquota_artifacts"
not to do changes at our CI
@red1452 red1452 changed the base branch from 2.3.0-sync2 to gpdb November 23, 2023 06:19
@RekGRpth
Copy link
Member

May be move last big comment to PR description?

@Stolb27 Stolb27 merged commit 5e402a7 into gpdb Dec 4, 2023
3 checks passed
@Stolb27 Stolb27 deleted the 2.3.0-sync branch December 4, 2023 21:27
@Stolb27 Stolb27 mentioned this pull request Dec 5, 2023
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.

9 participants