Skip to content

Schema check fails if schema upgrade applied more than once #1068

@alamp1360

Description

@alamp1360

I tried to run the newest version of IcingaDB and got the following error:

Starting Icinga DB daemon (1.5.1-g6400506)
2026-02-02T13:49:58.175+0100    INFO    icingadb        Connecting to database at 'mysql://icingadb@mariadb-test:3306/icingadb'
2026-02-02T13:49:58.178+0100    FATAL   icingadb        unexpected database schema version: incomplete database schema upgrade: intermediate version v6 is missing, please make sure you have applied all database migrations after upgrading Icinga DB

When checking the icingadb_schema table, i see the following:

MariaDB [icingadb]> select * from icingadb_schema;
+----+---------+---------------+
| id | version | timestamp     |
+----+---------+---------------+
|  1 |       4 | 1712212035000 |
|  2 |       5 | 1731611374000 |
|  3 |       6 | 1731611374000 |
|  4 |       5 | 1731612537000 |
|  5 |       6 | 1731612537000 |
|  6 |       6 | 1746607904000 |
|  7 |       7 | 1751438713000 |
+----+---------+---------------+

Dont ask me how this happened, but the following code in file schema.go (line 73ff) in dir pkg/icingadb cannot deal with it:

	// Check if each schema update between the initial import and the latest version was applied or, in other words,
	// that no schema update was left out. The loop goes over the ascending sorted array of schema versions, verifying
	// that each element's successor is the increment of this version, ensuring no gaps in between.
	for i := 0; i < len(versions)-1; i++ {
		if versions[i] != versions[i+1]-1 {
			return fmt.Errorf(
				"%w: incomplete database schema upgrade: intermediate version v%d is missing,"+
					" please make sure you have applied all database migrations after upgrading Icinga DB",
				ErrSchemaMismatch, versions[i]+1)
		}
	}

I was able to fix the issue by removing the duplicate entries manually, but i guess the actual behaviour could be seen as a minor bug, so i wanted to bring it to your attention...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions