apache / cloudberry

One advanced and mature open-source MPP (Massively Parallel Processing) database. Open source alternative to Greenplum Database.
https://cloudberry.apache.org
Apache License 2.0
417 stars 104 forks source link

cherry-pick signle commit 43a5e58dfa: Clean up logic in CdbTryOpenTable. #689

Closed reshke closed 3 weeks ago

reshke commented 3 weeks ago

This commit removes the function UpgradeRelLockAndReuseRelIfNecessary and clean up the implementation of CdbTryOpenTable. Now the logic is:

  1. open the relation using some lockmode
  2. if need correct lockmode (AO|AOCO with GDD enabled), then close and reopen it using upgraded lockmode
  3. if need lockUpgraded information, deduce this using actually mode with request mode.

Also we remove the post-check for AO table not upgrade, because under the new implementation that's impossible to happen and NOTE Greenplum does not support change table's storage kind yet (Even support some day, there will not be any problem).

The other place that uses UpgradeRelLockAndReuseRelIfNecessary is gpdbwrappers.cpp:GPDBLockRelationOid. Before this commit, it passes nullptr to UpgradeRelLockAndReuseRelIfNecessary, thus will open, lock, close the relation, and then lock the relation oid again. This commit implement this by just calling LockRelationOid since there is no need to test lock-upgrade here:

  1. Greenplum only need to upgrade lock level for target relation of DELETE | UPDATE statement
  2. Parse-Analyze stage will always handle root partition correctly and store the lockmode in RTE
  3. ORCA does not support DML on partiton table yet, and in future when implementing this, ORCA should use the lockmode in RTE of root so no need to deduce lock-upgrade
  4. Index does not have lock-upgrade issue.

fix #ISSUE_Number


Change logs

Describe your change clearly, including what problem is being solved or what feature is being added.

If it has some breaking backward or forward compatibility, please clary.

Why are the changes needed?

Describe why the changes are necessary.

Does this PR introduce any user-facing change?

If yes, please clarify the previous behavior and the change this PR proposes.

How was this patch tested?

Please detail how the changes were tested, including manual tests and any relevant unit or integration tests.

Contributor's Checklist

Here are some reminders and checklists before/when submitting your pull request, please check them:

CLAassistant commented 3 weeks ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

reshke commented 3 weeks ago

close as dup of https://github.com/cloudberrydb/cloudberrydb/pull/688/