It seems like something was corrupted in the device_keys table, but nothing obvious was wrong. Records could be queried directly from the DB and a full table dump did not reveal any obvious issues.
When an export of the DB to a new installation was performed, the problem persisted.
And update was made to v4.11 of Chirpstack and the problem has gone away.
I’m still unsure why this update fixed the problem - still looking into it.