Skip to content

Commit

Permalink
Ensure accurate metadata inconsistency checks (#2609) (#2626)
Browse files Browse the repository at this point in the history
This commit addresses metadata inconsistency checks, ensuring they occur in the appropriate places. Additionally, steps have been added to verify the existence of the inconsistency checker function before performing the metadata checks.

This is a cherry-pick commit of 858698.

Issues Resolved: BABEL-4139

Signed-off-by: Roshan Kanwar <[email protected]>
  • Loading branch information
roshan0708 authored May 31, 2024
1 parent 1022131 commit d4f57e3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
34 changes: 32 additions & 2 deletions .github/composite-actions/check-babelfish-inconsistency/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,36 @@ runs:
- name: Check Babelfish metadata inconsistency
id: check-babelfish-inconsistency
run: |
output=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT sys.check_for_inconsistent_metadata() GO" | tail -n +2)
echo "check_result=$output" >> "$GITHUB_OUTPUT"
# Check if the function exists
function_exists=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "
SELECT CASE WHEN COUNT(*) > 0 THEN 'exists' ELSE 'not_exists' END
FROM pg_proc
WHERE proname = 'check_for_inconsistent_metadata';" | grep -o 'exists\|not_exists')
echo "::set-output name=function_exists::$function_exists"
echo "Check Babelfish metadata inconsistency function exists: $function_exists"
# If the function exists, run the metadata inconsistency check
if [[ "$function_exists" == "exists" ]]; then
output=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT 'check_result=', sys.check_for_inconsistent_metadata() GO" | grep 'check_result' | sed 's/[[:blank:]]//g')
check_result=$(echo "$output" | grep -oP 'check_result=\K.+')
echo "Check Babelfish metadata inconsistency result: $check_result"
if [[ "$check_result" == "1" ]]; then
echo "Check Babelfish metadata inconsistency failed"
# Fetch and print the detailed inconsistent rules
inconsistent_rules=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "
SELECT DISTINCT object_type, schema_name, object_name, detail::text
FROM sys.babelfish_inconsistent_metadata();")
echo "Babelfish Inconsistent Metadata failing rules:"
echo "$inconsistent_rules"
exit 1
else
echo "Check Babelfish metadata inconsistency succeeded"
fi
else
echo "The function check_for_inconsistent_metadata does not exist, skipping metadata check."
fi
shell: bash
9 changes: 8 additions & 1 deletion .github/composite-actions/setup-base-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,15 @@ runs:
python3 upgrade_validation.py
shell: bash

- name: Run Babelfish metadata inconsistency check
id: check-babelfish-inconsistency
if: always() && steps.run-dependency-check.outcome == 'success'
uses: ./.github/composite-actions/check-babelfish-inconsistency

- name: Upload artifacts
if: always() && steps.run-dependency-check.outcome == 'failure'
if: |
always() && (steps.run-dependency-check.outcome == 'failure'
|| steps.check-babelfish-inconsistency.outcome == 'failure')
run: |
mkdir -p ~/upgrade
cp test/python/output/upgrade_validation/* ~/upgrade
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/major-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ jobs:
- name: Run pg_upgrade
id: run-pg_upgrade
if: |
always() && steps.setup-new-datadir.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
&& steps.check-babelfish-inconsistency.outputs.check_result == 0
always() && steps.setup-new-datadir.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
uses: ./.github/composite-actions/run-pg-upgrade

- name: Disable TDS fault injection tests in release mode
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/singledb-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
id: upgrade-and-verify
if: |
always() && steps.setup-base-version.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
&& steps.check-babelfish-inconsistency.outputs.check_result == 0
&& steps.check-babelfish-inconsistency.outcome == 'success'
uses: ./.github/composite-actions/major-version-upgrade-util
with:
engine_branch: latest
Expand Down

0 comments on commit d4f57e3

Please sign in to comment.