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

Upgrade to PostgreSQL 15 #9797

Open
ymahajan opened this issue Aug 23, 2021 · 16 comments
Open

Upgrade to PostgreSQL 15 #9797

ymahajan opened this issue Aug 23, 2021 · 16 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) current-roadmap kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue roadmap-tracking-issue This issue tracks a major roadmap item, and usually appears in the roadmap list.

Comments

@ymahajan
Copy link
Contributor

ymahajan commented Aug 23, 2021

Jira Link: DB-1591

Motivation -

  1. Feature / Need: This is one of the key motivating factors for application developers and database administrators. Each new version introduces many small and big features which open new ways of solving a problem and introducing new improvements.
  2. Support for new Postgres Extensions: An added advantage for some can be added features which you get with the use of Postgres Extensions. With each new version of PostgreSQL the extensions take advantage of the new features and add functionality which can be boon for application development. Tools like Pgpool, Bgbouncer, extensions get better with each version.
  3. Community Support and Fixes: The best part of using an open source community database is not being bound by proprietary licensing hence low cost of operations as well as a large group of developers contributing to it. That doesn't translate to being able to keep using a version indefinitely or getting fixes indefinitely. Every version of Postgres is supported by the community for a defined period of time in which the community releases security patches and bug fixes on a regular cycle. Once the version is deemed unsupported, the fixes stop.
  4. Compliance: Organizations have strict compliances to ensure and enforce that critical application databases are up to date with the latest supported versions. These policies can also extend to applications with embedded databases. This makes it imperative to keep your deployments up to date.
  5. Performance: Throughput of your database can be your key driving factor for upgrades. With each new version Postgres keeps delivering better performances.

Phase 1 - Set up Postgres 15 branch for YSQL

Feature Status Comments
Create pg15 YSQL branch https://github.com/yugabyte/yugabyte-db/tree/pg15
Rebase Postgres 15 changes onto pg15 branch From PG version 15.2 (commit)
Fix post-rebase compilation issues Support compiling with ./yb_build.sh --clang15 --sjb --rebuild-postgres --no-initdb
Set up regular rebase of Yugabyte latest on pg15 branch weekly rebase from yugabyte-db/master branch

Phase 2 - Support YSQL database initialization (initdb)

Feature Status Comments
Initdb bootstrap stage Initialize core template1 system tables
Initialize rest of pinned objects setup_auth and setup_depend
Initialize rest of template1 objects collations, dictionary, privileges, schemas, plpgsql
Initialize other primitive databases template0, postgres, yugabyte, and system_platform

Phase 3 - Feature parity with current YSQL

Many features are already used internally as part of initdb (phase above)

Feature Status Comments
Set up CI tests for pg15 branch Run all the same tests as for the latest branch
Review new PG 15 tests Add any new tests for pre-existing (PG11) features
Clean up CI test results Fix any broken tests to get regular clean runs on pg15 branch
Review and merge PG extensions e.g. pg_stat_statements, pg_hint_plan, orafce, etc.
Support rolling upgrade to YSQL.PG15 ⬜️ Functional Spec and Design Doc
Merge pg15 branch into master PG v15 as default YSQL baseline

Phase 4 - Enable select PostgreSQL v12 to v15 features

Feature Status Comments
Allow foreign keys to reference partitioned tables 🕐 Added in PG 12 (release notes)
Stored generated columns Added in PG 12 (release notes)
Better query planning when using extended statistics ⬜️ Added in PG 13 (release notes)
Improvements to PostgreSQL's query parallelism support ⬜️ Added in PG 14 (release notes)
Improved Sort Performance and Compression ⬜️ Added in PG 15 (release notes)
Support for the SQL MERGE command. ⬜️ Added in PG 15 (release notes)

Phase 5 (future) - Enable all PostgreSQL v12 to v15 features

@adil246
Copy link
Contributor

adil246 commented Jul 19, 2022

@ymahajan This will also enable creating foreign keys referencing partitioned tables with other improvements for copy, partition join, etc available from PG12 onwards. A few customers have been requesting this feature.

@kisg
Copy link

kisg commented Nov 15, 2022

Do you have a strategy for keeping up with upstream PostgreSQL? I admit that I have not looked into your forked version in detail, so I don't know how feasible it would be. But wouldn't it make sense to refactor the main PostgreSQL codebase in a way so it has APIs / extension points where your code has to diverge from core PostgreSQL? If these changes could be accepted by the upstream PostgreSQL project, then the amount of maintenance work you have to do would drop significantly.

If you start working on upgrading to PostgreSQL 16 (the current development version) now and also do these refactorings and submissions to the upstream project, you could have it done and accepted by the time PostgreSQL 16 is released.

Another option would be to keep up with upstream PostgreSQL on a commit-by-commit basis. This is not a very fun project (I was involved in such a project to port Google V8 commit-by-commit from ARM to MIPS - did it for 6 years), but the result is that you can follow the PostgreSQL feature set very closely.

What do you think?

@ymahajan ymahajan changed the title [Master] Upgrade to PostgreSQL 13 [Master] Upgrade to PostgreSQL 15 Jan 30, 2023
@bmjhversteeg
Copy link

I see upgrade to Postgres 13/15 is still on the github frontpage as being in progress, but is there any news regarding this? The lack of foreign key support on partitioned tables is currently holding our project back from migrating to yugabyte

@mrajcevic01
Copy link
Contributor

Hi @bmjhversteeg,

This effort is actively underway. I will let the engineering team comment on the timeline if one is available at this time. We currently have two main workarounds for this issue - #15424

If you can reach out to me (@MarkoR (YB)) in our Community Slack I can share the function mentioned in #15422 if you would like to test with it. I have also created some documentation that can be shared that further clarifies your options for FKs on non-partitioned and partitioned tables.

@bmjhversteeg
Copy link

@mrajcevic01 Thanks a lot for your reply! I'll meet you on Slack.

@FranckPachot
Copy link
Contributor

@bmjhversteeg I'm interested to know more about your use case needing foreign keys to partitioned tables. I think that in the context of YugabyteDB the need to reference a partitioned table from a non-partitioned one should be rare. I've detailed that in: https://dev.to/yugabyte/foreign-keys-referencing-partitioned-tables-in-yugabytedb-26pn but I'll be happy to see if I missed something. I'll ping you on slack

@m-iancu m-iancu added the roadmap-tracking-issue This issue tracks a major roadmap item, and usually appears in the roadmap list. label May 15, 2023
@m-iancu m-iancu changed the title [Master] Upgrade to PostgreSQL 15 Upgrade to PostgreSQL 15 May 15, 2023
@NOBLES5E
Copy link

This issue seems to have been open for a while now, and it's clear from the discussion thread that it's of substantial importance to many users. Could someone from the engineering team kindly provide an estimated timeline for the completion of the PostgreSQL 15 upgrade? I understand that it's a complex endeavor, and these things can be difficult to predict accurately, but a rough estimation would be helpful to understand when we might expect this upgrade. Thanks for all the hard work on this!

@alexted
Copy link

alexted commented Jan 12, 2024

Now, it seems to make sense to upgrade to version 17, not 15

@FranckPachot
Copy link
Contributor

@alexted which PG16 feature are you using? It is important to think in term of features to also remain compatible with previous versions of PostgreSQL

@thinkwelltwd
Copy link

thinkwelltwd commented Jan 12, 2024

which PG16 feature are you using? It is important to think in term of features to also remain compatible with previous versions of PostgreSQL

As a longtime lurker on this 3.5 year old thread, with well-nigh zero (0) meaningful input from YB, that response seems rather tactless and impertinent.

Shouldn't YB support a modern version of Postgres and let application writers and sysadmins worry about compatibility with older versions?

@alexted
Copy link

alexted commented Jan 12, 2024

@alexted which PG16 feature are you using? It is important to think in term of features to also remain compatible with previous versions of PostgreSQL

  1. JSON path expressions
  2. generated columns
  3. nondeterministic collations
  4. "REINDEX CONCURRENTLY" command
  5. pg_checksums command
  6. extended statistics based on "CREATE STATISTICS" command
  7. gen_random_uuid() function
  8. JSON data access using expressions, reminiscent of working with arrays
  9. multirange-types
  10. "SEARCH" and "CYCLE" commands
  11. "MERGE" command
  12. regexp_count(), regexp_instr(), regexp_like() and regexp_substr() functions
  13. security_invoker regime
  14. ability to set "ICU Collation" as default collation instead of libc
  15. paralleling the operations of joining tables "FULL JOIN" and "RIGHT JOIN"
  16. "IS JSON", "JSON_ARRAY()" и "JSON_ARRAYAGG()" functions
  17. ability to using the underscore character in numbers
  18. ability to specify hexadecimal, binary and octal literals

I can go on and on with this list...

@FranckPachot
Copy link
Contributor

@alexted YugabyteDB uses PostgreSQL only for the SQL layer so the features that are storage specific do not depend on the PostgreSQL compatibility. For example:

  • "REINDEX CONCURRENTLY" command: there's no blot in indexes so re-indexing is not useful. And you can drop+create indexes and they are by default created concurrently
  • pg_checksums command: YugabyteDB has checksums to detect corruption and automatically repairs from the other replicas
  • gen_random_uuid(): we have this in pgcrypto extension
  • ability to set "ICU Collation" as default collation instead of libc: we do not depend on OS GLIBC
  • paralleling the operations of joining tables "FULL JOIN" and "RIGHT JOIN": parallel query is being implemented in YugabyteDB
  • generated columns: the PG12 identity columns were added to YugabyteDB on top of PG11 compatibility

Just wanted to note that features on layers below the SQL API don't apply to YugabyteDB as-is. I agree that there are also great SQL features that we will benefit from.

@alexted
Copy link

alexted commented Jan 13, 2024

Thanks for your comment. besides the few things I mentioned that you mentioned, there is a lot more functionality from the current SQL layer of Postgres missing. Well, in this case, could you tell me if we should wait for the necessary functionality of the latest versions of PostgreSQL in YugabyteDB?
Is work on this task being done at all?

@sushantrmishra
Copy link

@alexted
Currently we are aggressively working on upgrading YugabyteDB to PostgreSQL15.

Current state:
Code from PostgreSQL15 has been merged with YugabyteDB code and is available in a separate pg15 branch in Yugabyte repository.
Refer to https://github.com/yugabyte/yugabyte-db/tree/pg15 .

Currently we are working on

  • Stabilizing the tests and making sure that all the test suites are passing with the PostgreSQL15 compatible YugbayteDB clusters.
  • Seamless upgrade from existing YugabyteDB Clusters to PostgreSQL15 compatible YugabyteDB clusters.

Considering this is a very large effort, so currently do not have any fixed timeline yet. Though as we are getting closer to the completion of ongoing task, we will update the firm timeline for it.
Tentatively we expect to have the ability to create the PostgreSQL15 compatible cluster this year (2024) .

Please ping us for any additional question you may have.

@alexted
Copy link

alexted commented Feb 7, 2024

@sushantrmishra Look, April 8 is going to be a feature freeze in PostgreSQL. Perhaps, in that case, it makes sense for you to work with PostgreSQL version 17 at once?

@ddorian
Copy link
Contributor

ddorian commented Feb 26, 2024

@alexted one of the reasons that this project is hard is because we're looking to support online-upgrade of the version, which isn't supported in normal PostgreSQL. Once we upgrade to PG15, and support online upgrade, it will be much easier to upgrade to newer versions of PostgreSQL.

foucher added a commit that referenced this issue Jul 31, 2024
Summary:
The pg15-upgrade branch has implementations of 3 RPCs needed for the YSQL major version upgrade:
 * StartYsqlMajorVersionUpgradeInitdb
 * IsYsqlMajorVersionUpgradeInitdbDone
 * RollbackYsqlMajorVersionUpgrade

In order to facilitate integration with tools such as YBA, add stubs for these methods to the master branch.

Upgrade/Downgrade safety:
No issues. New, unimplemented interface.

Jira: DB-1591

Test Plan:
Jenkins

Using a recent pg15-upgrade build, manually run:
  yb-admin ysql_major_version_upgrade_initdb
  yb-admin rollback_ysql_major_version_upgrade

Verify it shows something like the following errors:
  Error running ysql_major_version_upgrade_initdb: Not implemented (yb/master/catalog_manager.cc:3281): Unable to run initdb for ysql major version upgrade: Ysql major version upgrade is not supported
  Error running rollback_ysql_major_version_upgrade: Not implemented (yb/master/catalog_manager.cc:3294): Unable to roll back ysql major version upgrade: Ysql major version upgrade is not supported

Note yb-admin doesn't have a command for IsYsqlMajorVersionUpgradeInitdbDone because it implements its own blocking on the pg15-upgrade branch, but the code is similar for the 3 RPCs.

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: vbansal, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D36940
jasonyb pushed a commit that referenced this issue Aug 2, 2024
Summary:
 66890cb [PLAT-14781] Add runtime config for download metrics as pdf
 b2f24f2 [#9797] YSQL: Stubs for ysql major version upgrade RPCs
 5891faa [#23332] Docdb: Fix yb-admin to handle snapshot_retention correctly
 0614c52 [PLAT-14756] Releases API RBAC cleanup
 2cfb999 [docs] Release notes for 2024.1.1.0-b137 (#23185)
 d868a03 [PLAT-13495] Do not run dual nic steps on systemd upgrade
 10bc447 [PLAT-14798] Adding internal load balancer to devspace
 7296df8 [docs] [2.23] Add pg_cron extension docs (#22546)
 79902ae [PLAT-14678] - feat : Export All Metrics to pdf
 8a0b95c [#23322] YSQL: pg_partman: fix logic of checking existing table
 Excluded: 63f471a [#18822] YSQL: Framework to skip redundant sec index updates and fkey checks when relevant columns not modified
 3040472 [PLAT-14783] [PGParity] After Edit RR cores scale up on PG Parity enabled cluster, the RR node does not have PGP gflags
 e052089 [PLAT-14774] Per process tserver metrics is not working if YSQL is disabled
 0c664a1 [#22370] docdb: Cost Based Optimizer changes to take into account backward scans improvement
 a060877 [PLAT-13712]fix plan info for Azure VMs
 291dd40 Remove 6sense domains from CSP headers (#23354)
 75cb273 [#23330] docdb: fixed static columns handling for CQL operations

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D36984
foucher added a commit that referenced this issue Oct 4, 2024
Switch YugabyteDB YSQL layer from PostgreSQL 11 to PostgreSQL 15.
foucher added a commit to foucher/yugabyte-db that referenced this issue Oct 11, 2024
…line upgrade

Summary:
Before and during a major YSQL version upgrade, through the heartbeat mechanism, the master provides current catalog versions to tservers from the PG11 catalog versions table. Note that DDLs are not allowed during a YSQL major version upgrade, and the PG15 catalogs are being updated by being set to semantic equivalents of PG11. To the PG11-only clients (tservers), there is only one valid catalog version state and that is the state when the upgrade began.

While going through the upgrade flow, the C++ upgrade tests keep the cluster running while the YB master is switched out of upgrade mode. When the master is switched out of upgrade mode in this way, it switches to providing the current catalog versions from the PG15 catalog versions table, which is fresh and sets everything as version 1. Thus tservers see the version number going down and probabilistically crash themselves with the following error message:

  Ignoring ysql db 13245 catalog version update: new version too old. New: 1, Old: 2, ignored count: 31

Fix this incorrect state by copying the contents of the PG11 catalog versions table to PG15, right after the PG15 catalog is established, and before returning success of the catalog upgrade.

Test Plan:
Jenkins

On MacOS arm64:
  ./yb_build.sh release --cxx-test pg15_upgrade-test --gtest_filter=Pg15UpgradeTest.Schemas

Reviewers: hsunder

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D38961
foucher added a commit that referenced this issue Oct 11, 2024
…rade

Summary:
Before and during a major YSQL version upgrade, through the heartbeat mechanism, the master provides current catalog versions to tservers from the PG11 catalog versions table. Note that DDLs are not allowed during a YSQL major version upgrade, and the PG15 catalogs are being updated by being set to semantic equivalents of PG11. To the PG11-only clients (tservers), there is only one valid catalog version state and that is the state when the upgrade began.

While going through the upgrade flow, the C++ upgrade tests keep the cluster running while the YB master is switched out of upgrade mode. When the master is switched out of upgrade mode in this way, it switches to providing the current catalog versions from the PG15 catalog versions table, which is fresh and sets everything as version 1. Thus tservers see the version number going down and probabilistically crash themselves with the following error message:

  Ignoring ysql db 13245 catalog version update: new version too old. New: 1, Old: 2, ignored count: 31

Fix this incorrect state by copying the contents of the PG11 catalog versions table to PG15, right after the PG15 catalog is established, and before returning success of the catalog upgrade.
Jira: DB-1591

Test Plan:
Jenkins

On MacOS arm64:
  ./yb_build.sh release --cxx-test pg15_upgrade-test

On AlmaLinux 8:
  ./yb_build fastdebug --gcc11 --sj
  pg15_tests/get_shell_test_specs.sh | grep upgrade | pg15_tests/run_tests.sh

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D38961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) current-roadmap kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue roadmap-tracking-issue This issue tracks a major roadmap item, and usually appears in the roadmap list.
Projects
Status: No status
Development

No branches or pull requests