"Fix: Improved Schema Version Validation and Error Handling" #158
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request addresses an issue where executing Osmosis v0.48.3 on macOS throws a schema version mismatch error:
pgsql
Copy
Edit
SEVERE: Thread for task 1-read-pbf failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: The database schema version of 5 does not match the expected version of 6.
at org.openstreetmap.osmosis.pgsnapshot.common.SchemaVersionValidator.validateDBVersion(SchemaVersionValidator.java:67)
The root cause of this issue was that the database schema version defined in pgsimple_schema_0.6.sql was set to version 5 instead of the expected version 6.
🛠️ Changes Made
Updated Schema Validation Logic:
Modified the SchemaVersionValidator class to correctly compare the schema version from the schema migrations table with the expected version.
Improved error handling to provide clearer and more actionable feedback when there’s a mismatch.
Enhanced Error Messages:
Added detailed suggestions to help users resolve version conflicts, including hints for upgrading the schema or disabling strict validation.
Resource Management Improvements:
Utilized Java’s AutoCloseable interface for better resource handling during database connections and queries.
✅ How to Test the Fix
Run Osmosis with the updated schema version.
Verify that the tool no longer throws version mismatch errors.
Ensure smooth execution of tasks like reading .pbf files without breaking existing functionality.
🔍 Related Issue
Closes #5935
📈 Impact of the Fix
Prevents schema version mismatch errors during execution.
Provides clearer guidance for users facing version-related issues.
Improves stability and maintainability of the schema validation process.
🙏 Additional Notes
I am open to feedback and ready to make any necessary adjustments based on the review.