Skip to content

Fix/statusengine schema primary keys - #2

Merged
nook24 merged 2 commits into
mainfrom
fix/statusengine-schema-primary-keys
Sep 8, 2026
Merged

Fix/statusengine schema primary keys#2
nook24 merged 2 commits into
mainfrom
fix/statusengine-schema-primary-keys

Conversation

@nook24

@nook24 nook24 commented Sep 8, 2026

Copy link
Copy Markdown
Member

No description provided.

nook24 and others added 2 commits September 8, 2026 20:09
.claude/specs/mysql_schema.sql is openITCOCKPIT's schema, not standard
Statusengine's, and the PRIMARY KEYs differ: openITCOCKPIT stores a UUID
in service_description, so it is unique on its own and four service
tables key on it without hostname. Standard Statusengine keeps the plain
description and leads those keys with hostname (setPrimaryKey in
lib/mysql.php of statusengine/worker).

pkColumns is what pairs a PHP row with its Go counterpart, via pkKey as a
map key. On a standard installation "PING on host A" and "PING on host B"
therefore produced the same key: one row silently replaced the other in
the map and the comparison reported mismatches between unrelated
services - noise that looks exactly like the data-parity failure this
tool exists to detect.

Naming hostname and service_description is a superset of openITCOCKPIT's
key and exactly Statusengine's, so it is unique under both and needs no
schema switch. Every one of these tables carries a hostname column in
either schema, which is what makes one binary work on both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFvRFfD1Df4LBfsNABvPPk
The ON DUPLICATE KEY UPDATE clause is a no-op because the named column is
part of the PRIMARY KEY - the row only matched because every key column
already holds the incoming value, so writing one of them back changes
nothing. The comment and the test said "first column of the PRIMARY KEY"
instead, which happens to be true of .claude/specs/mysql_schema.sql and
is not the property that matters.

That mattered once the dump turned out to be openITCOCKPIT's schema
rather than standard Statusengine's: the two order these keys
differently, so a test demanding the first column pins the fix to one
schema and passes while the worker is wrong on the other. All ten
declared columns are in the key under both, so no behaviour changes here
- but the reason they are correct was not the reason written down.

The four service tables name service_description precisely because it is
the one column inside the key under both schemas. hostname reads as the
natural choice from the standard-Statusengine keys and is not in
openITCOCKPIT's, where it would turn every redelivered row into a real
write - the mistake the test now fails on, verified by making it.

Standard Statusengine's keys are transcribed beside the map rather than
fetched: a test that reaches for GitHub fails offline for reasons that
have nothing to do with the code under test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFvRFfD1Df4LBfsNABvPPk
@nook24
nook24 merged commit aa1e696 into main Sep 8, 2026
2 checks passed
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