Skip to content

Lack or foreign key use in databases could lead to orphan data #414

@Robin-Van-de-Merghel

Description

@Robin-Van-de-Merghel

Of all 6 SQL databases:

sandbox_metadata, pilot_agents aren't using foreign keys at all. This could lead to orphan data in the database for two reasons:

  1. if a pilot is deleted in the PilotAgents table, all pilot related data like in JobToPilotMapping will not be deleted
  2. we could have an unknown pilot_id in PilotOutput because we inserted a non-existent one (so we are obliged to verify that the new pilot_id exists in the database, manually, instead of letting the db verify for us and doing its magic) or because it does not exist anymore (see 1.)

I don't know if this is a choice, or a mistake. If it is a choice, task_queue and job do use foreign keys. And furthermore, even if we check manually, I think it is better to have constraints inside the DB itself, rather than constraints done before.

In the meanwhile, job_logging and auth can't use it, because the client_id is remotely defined in IAM if I recall.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions