Skip to content

Fix return in a finally block in buildMirrorSegments.py - #2110

Open
tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-python314-return-in-finally
Open

tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-python314-return-in-finally

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Oct 10, 2026

Copy link
Copy Markdown
Member

Python 3.14 (PEP 765) warns at compile time about a return in a finally block. Every gp* utility that imports gppylib.operations.buildMirrorSegments prints it on stderr:

buildMirrorSegments.py:293: SyntaxWarning: 'return' in a 'finally' block

This breaks tests that compare the output of those utilities, such as contrib/sslinfo, where "gpstop -arf" is run from the test and the two extra lines make the result differ from the expected file.

In _update_config(), "return backout_map" was in the finally block that restores the SIGINT handler. A return there discards any exception from the try block, so a failure of updateSystemConfig() was silently ignored and None was returned. The caller then went on with the recovery, and _revert_config_update() failed later with a TypeError from len(None).

Return after the finally block. The SIGINT handler is restored in the same way, and an exception from updateSystemConfig() is now raised to the caller with its own message, as every other step of the recovery does.

This is the only return, break or continue in a finally block in the repository.

Assisted-by: Claude Code
Backpatch-through: REL_2_STABLE

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


Python 3.14 (PEP 765) warns at compile time about a return in a finally
block. Every gp* utility that imports gppylib.operations.buildMirrorSegments
prints it on stderr:

  buildMirrorSegments.py:293: SyntaxWarning: 'return' in a 'finally' block

This breaks tests that compare the output of those utilities, such as
contrib/sslinfo, where "gpstop -arf" is run from the test and the two
extra lines make the result differ from the expected file.

In _update_config(), "return backout_map" was in the finally block that
restores the SIGINT handler. A return there discards any exception from
the try block, so a failure of updateSystemConfig() was silently ignored
and None was returned. The caller then went on with the recovery, and
_revert_config_update() failed later with a TypeError from len(None).

Return after the finally block. The SIGINT handler is restored in the
same way, and an exception from updateSystemConfig() is now raised to
the caller with its own message, as every other step of the recovery does.

This is the only return, break or continue in a finally block in the
repository.

Assisted-by: Claude Code
Backpatch-through: REL_2_STABLE
@tuhaihe tuhaihe added this to the Ubuntu 26.04 Support milestone Oct 10, 2026
@tuhaihe

tuhaihe commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

This change has been verified in Ubuntu 26.04 on #2096

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.

1 participant