ozone icon indicating copy to clipboard operation
ozone copied to clipboard

HDDS-11465. Introducing Schema Versioning for Recon to Handle Fresh Installs and Upgrades.

Open ArafatKhan2198 opened this issue 5 months ago • 7 comments

What changes were proposed in this pull request?

This PR introduces an upgrade framework in Recon that mirrors the pattern used in OMLayoutFeature with some key differences tailored for Recon's needs. The primary purpose of this PR is to manage and handle schema upgrades automatically during Recon startup, storing layout version information on disk and executing necessary upgrade actions.

Summary of Changes:

  • Replication of OMLayoutFeature Pattern: Recon now follows a similar schema upgrade pattern as used in the OM layer, but with auto-finalization. Unlike in OM, Recon will automatically finalize on restart without requiring manual intervention.
  • Storage of Metadata Value: The Metadata Layout Version (MLV) is stored in the RECON_SCHEMA_VERSION table on disk. This table tracks the schema version to identify which features have been applied.
  • Computation of SLV: The Software Layout Version (SLV) is computed dynamically based on the latest version defined in ReconLayoutFeature at runtime.
  • Code Flow During Startup :-
    • On Recon startup, the ReconLayoutVersionManager fetches the current MLV from the RECON_SCHEMA_VERSION table.
    • It then computes the SLV by identifying the highest version in ReconLayoutFeature.
    • The manager finalizes any layout features that require upgrading by executing their associated actions and updates the MLV.
  • Newly Added Classes :-
    • ReconLayoutVersionManager: Handles the determination of the current MLV and SLV and performs the finalization of pending layout features.
    • ReconSchemaVersionTableManager: Manages interactions with the RECON_SCHEMA_VERSION table, including fetching and updating the current MLV.
    • ReconLayoutFeature: Enum defining the layout features with their version, description, and direct integration of upgrade actions.
  • Differences from OMLayoutFeature:
    • No manual finalization: Recon auto-finalizes on restart.
    • No downgrade support or behavior blocking: Recon focuses solely on upgrade actions without pre-finalization constraints.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11465

How was this patch tested?

For testing this PR, three example features were introduced into ReconLayoutFeature along with their respective upgrade scripts. These scripts were designed to simply log their execution, allowing us to verify that the upgrade framework works as intended. During Recon startup, the current Metadata Layout Version (MLV) was set lower than the Software Layout Version (SLV). The logs confirmed that each feature's upgrade action executed sequentially, updating the MLV and recording the changes in the RECON_SCHEMA_VERSION table. This successful test demonstrates that the framework correctly finalizes registered features when MLV < SLV. I'll remove them once the PR is approved by everyone.

Logs showcasing upgrade :-

[main] INFO recon.ReconServer: Creating Recon Schema.
[main] INFO upgrade.ReconLayoutVersionManager: Current MLV: 0. SLV: 3. Checking features for registration...
[main] INFO upgrade.ReconLayoutVersionManager: Feature FEATURE_1 (version 1) is registered for finalization.
[main] INFO upgrade.ReconLayoutVersionManager: Feature FEATURE_2 (version 2) is registered for finalization.
[main] INFO upgrade.ReconLayoutVersionManager: Feature FEATURE_3 (version 3) is registered for finalization.
[main] INFO upgrade.Feature1UpgradeAction: Executing Feature 1 upgrade:
[main] INFO recon.ReconSchemaVersionTableManager: Inserted new schema version '1'.
[main] INFO upgrade.ReconLayoutVersionManager: MLV updated to: 1
[main] INFO upgrade.ReconLayoutVersionManager: Feature 1 finalized successfully.
[main] INFO upgrade.Feature2UpgradeAction: Executing Feature 2 upgrade
[main] INFO recon.ReconSchemaVersionTableManager: Updated schema version to '2'.
[main] INFO upgrade.ReconLayoutVersionManager: MLV updated to: 2
[main] INFO upgrade.ReconLayoutVersionManager: Feature 2 finalized successfully.
[main] INFO upgrade.Feature3UpgradeAction: Executing Feature 3 upgrade
[main] INFO recon.ReconSchemaVersionTableManager: Updated schema version to '3'.
[main] INFO upgrade.ReconLayoutVersionManager: MLV updated to: 3
[main] INFO upgrade.ReconLayoutVersionManager: Feature 3 finalized successfully.

ArafatKhan2198 avatar Sep 18 '24 07:09 ArafatKhan2198