Unrecognized database schema version is treated as a pre-2.0 database
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #497 của @tonygermano — đã merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc ServerMigrator.getCurrentVersion() và migrate(); issue xác định các phương thức này và truy vấn phiên bản SCHEMA_INFO là luồng gây lỗi. Kiểm tra cách xử lý bảng trống để bảng vẫn bắt đầu ở V0, và cách một phiên bản đã lưu không được nhận diện phải phát sinh MigrationException trước khi chạy các migration. Công việc được xem là hoàn tất khi lỗi nêu phiên bản đã lưu và không có script migration nào được thực thi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
If SCHEMA_INFO holds a version string the server doesn't know, such as one written by a newer or different release, ServerMigrator treats the database as schema version 0 and starts running the legacy pre-2.0 migrations against it. Startup then fails with an error about a 2.x-era delta script, which says nothing about the real problem.
Steps to reproduce
With the default Derby database, from the server's install directory:
- Start a fresh install once so the database is created, then stop it (Ctrl+C once startup has finished):
./oieserver - With the server stopped, set a version this release doesn't know:
java -cp 'server-lib/database/*' org.apache.derby.tools.ij <<'EOF' connect 'jdbc:derby:appdata/mirthdb'; UPDATE SCHEMA_INFO SET VERSION = '99.0.0'; SELECT * FROM SCHEMA_INFO; exit; EOF - Start the server again:
./oieserver
On other databases, run the same UPDATE with that database's client.
After the failed start, the process keeps running instead of exiting, which is a separate bug. Stop it with Ctrl+C. On Derby that also hangs, so you'll need kill -9.
Expected
Startup stops with an error naming the unrecognized version, and no migrations run.
Actual
ServerMigrator.migrate() starts the migration chain at V0 and runs LegacyMigrator(1), which executes the first legacy delta script (derby-0-1.sql, postgres-0-1.sql and so on). Startup fails with Failed to execute script for that file.
On a stock schema the script fails at its first statement, DROP TABLE TRANSPORT, because that table no longer exists, so nothing is changed. Nothing guards the path, though: the scripts run with auto-commit on, so if a TRANSPORT table did exist, it would be dropped and the next statements would alter existing tables (CHANNEL, or EVENT on MySQL) before anything failed.
Cause
ServerMigrator.getCurrentVersion() returns Version.fromString() of the stored value, which is null for any string not in the Version enum. migrate() uses null to mean an empty SCHEMA_INFO table and starts from Version.values()[0]. updateVersion() uses the same null to choose INSERT over UPDATE, so a migration step that did succeed would add a second row to SCHEMA_INFO instead of updating the first.
Fix
getCurrentVersion() throws a MigrationException when SCHEMA_INFO has a row whose version isn't recognized, naming the version found. An empty table still starts at V0, as before. Startup already stops on that exception before any other migration runs.
Related
- Server process keeps running after a startup failure
- Stopping the server after a failed startup hangs on Derby
🤖 Drafted with Claude Code
- Ngôn ngữ chính
- Java
- Star
- 227
- Fork
- 81
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenIntegrationEngine/engine
-
Outdated GitHub workflow action versionsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenIntegrationEngine/engine#485 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
OpenIntegrationEngine/engine#478 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenIntegrationEngine/engine#355 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenIntegrationEngine/engine#347 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Fix call-home in test runĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenIntegrationEngine/engine#313 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenIntegrationEngine/engine
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QuiltMC/update-quilt-meta#28 ·
-
awaiting triage Documentation P3
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/build area/maintainability component/camunda-process-test kind/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Kafka: Filter empty strings and whitespace in IcebergSinkConfig stringToListCó thể đã có người làm @mohamed-elbrik đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/kotlin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày