Skip to content

Conversation

@harikrishna-patnala
Copy link
Contributor

@harikrishna-patnala harikrishna-patnala commented Mar 30, 2023

Description

This PR fixes #7370 where same foreign key names are used for multiple tables which causes issues with different MySQL versions.

I've updated the procedure to be more precise and altered the problematic foreign keys in upgrade files. This way we can log the errors and resume the upgrade.

Also removed the mysql statements related to foreign key procedure creation and usage from 4.18.0 schema files (those are moved to 4.18.1 java upgrade files) to avoid errors caused in #7370 for certain MySQL versions.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

@harikrishna-patnala harikrishna-patnala changed the title Fix foreign key Fix foreign key constraints and the mysql procedure that is being used Mar 30, 2023
@harikrishna-patnala harikrishna-patnala changed the title Fix foreign key constraints and the mysql procedure that is being used Fix foreign key constraints and the mysql procedure that is used Mar 30, 2023
@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan package

@harikrishna-patnala harikrishna-patnala added this to the 4.19.0.0 milestone Mar 30, 2023
@blueorangutan
Copy link

@harikrishna-patnala a Jenkins job has been kicked to build packages. It will be bundled with

SystemVM template(s). I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 5809

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@harikrishna-patnala
we also need to remove the codes in 41720to41800.sql
otherwise, the users who use mysql 5.6/5.7 will still fail to upgrade to 4.18.1.0 due to same error in #7358

@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Merging #7381 (58c87c2) into 4.18 (03910c2) will increase coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff            @@
##               4.18    #7381   +/-   ##
=========================================
  Coverage     12.98%   12.99%           
- Complexity     8984     8996   +12     
=========================================
  Files          2716     2716           
  Lines        256329   256390   +61     
  Branches      39974    39984   +10     
=========================================
+ Hits          33275    33307   +32     
- Misses       218892   218915   +23     
- Partials       4162     4168    +6     
Impacted Files Coverage Δ
...va/com/cloud/upgrade/dao/DatabaseAccessObject.java 81.25% <0.00%> (-16.25%) ⬇️
...ain/java/com/cloud/upgrade/dao/DbUpgradeUtils.java 80.00% <0.00%> (-12.31%) ⬇️
...ava/com/cloud/upgrade/dao/Upgrade41800to41810.java 6.66% <0.00%> (-5.34%) ⬇️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-advanced-security
Copy link

You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@harikrishna-patnala
Copy link
Contributor Author

@harikrishna-patnala we also need to remove the codes in 41720to41800.sql otherwise, the users who use mysql 5.6/5.7 will still fail to upgrade to 4.18.1.0 due to same error in #7358

Yes, I'll remove it 41720to41800.sql file

@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@harikrishna-patnala a Jenkins job has been kicked to build packages. It will be bundled with

SystemVM template(s). I'll keep you posted as I make progress.

@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@harikrishna-patnala a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@weizhouapache
Copy link
Member

@harikrishna-patnala
I think we do not necessarily need a mysql procedure.

Refer to the following code block

    public void dropKey(Connection conn, String tableName, String key, boolean isForeignKey)
    {
        String alter_sql_str;
        if (isForeignKey) {
            alter_sql_str = "ALTER TABLE " + tableName + " DROP FOREIGN KEY " + key;
        } else {
            alter_sql_str = "ALTER TABLE " + tableName + " DROP KEY " + key;
        }
        try(PreparedStatement pstmt = conn.prepareStatement(alter_sql_str);)
        {
            pstmt.executeUpdate();
            s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName);
        } catch (SQLException e) {
            s_logger.debug("Ignored SQL Exception when trying to drop " + (isForeignKey ? "foreign " : "") + "key " + key + " on table "  + tableName + " exception: " + e.getMessage());

        }
    }

@blueorangutan
Copy link

[SF] Trillian test result (tid-6717)
Environment: kvm-rocky8 (x2), Advanced Networking with Mgmt server r8
Total time taken: 49651 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7381-t6717-kvm-rocky8.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 598.91 test_kubernetes_clusters.py

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm, some malicious upgrade tests required, ... @vladimirpetrov ;)

@vladimirpetrov
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@vladimirpetrov a [LL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [LL]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6134

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

need manual testing

@DaanHoogland
Copy link
Contributor

code lgtm

need manual testing

@weizhouapache , with manual testing you mean upgrade tests, right?

@weizhouapache
Copy link
Member

code lgtm
need manual testing

@weizhouapache , with manual testing you mean upgrade tests, right?

@DaanHoogland yes, probably better with mysql 5.6/5.7 which did not work when upgrade to 4.18.0.0

@DaanHoogland
Copy link
Contributor

code lgtm
need manual testing

@weizhouapache , with manual testing you mean upgrade tests, right?

@DaanHoogland yes, probably better with mysql 5.6/5.7 which did not work when upgrade to 4.18.0.0

cc @vladimirpetrov

@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@harikrishna-patnala a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6308

@rohityadavcloud
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@rohityadavcloud a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@harikrishna-patnala a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@harikrishna-patnala a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6359

@apache apache deleted a comment from blueorangutan Jun 30, 2023
@apache apache deleted a comment from blueorangutan Jun 30, 2023
@harikrishna-patnala
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@harikrishna-patnala a [SF] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-6909)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 40485 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7381-t6909-kvm-centos7.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_migrate_VM_and_root_volume Error 79.78 test_vm_life_cycle.py
test_02_migrate_VM_with_two_data_disks Error 53.44 test_vm_life_cycle.py

Copy link
Contributor

@vladimirpetrov vladimirpetrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM based on manual testing. I tested some upgrades from 4.14, 4.15, 4.16 and 4.17 using KVM and VMware and found no issues.

@DaanHoogland DaanHoogland merged commit 0cbe770 into apache:4.18 Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing contraint foreign key in "vm_template" table

8 participants