Geo: Implement support for composite primary keys
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
1. Update the Model Definition
# ee/app/models/geo/job_artifact_state.rb
class JobArtifactState < Ci::ApplicationRecord
# Change from single to composite primary key
self.primary_key = [:job_artifact_id, :partition_id] # ✅ Proper fix
# Instead of:
# self.primary_key = :job_artifact_id # ❌ Current broken state
end
2. Update Geo's Core Abstractions
Geo's verification and replication system assumes single primary keys throughout. For example you'd need to update:
Verification State Methods:
# Current code assumes single primary key
def verification_state_model_key
primary_key # Returns :job_artifact_id
end
# Would need to become:
def verification_state_model_key
primary_key.is_a?(Array) ? primary_key : [primary_key]
end
Replication Logic:
# Current replication code likely does things like:
record_id = model.id # Assumes single value
# Would need to handle:
record_id = model.id # Could be [123, 1] for composite keys
3. Database Query Updates
Many Geo queries would need updates:
# Current queries:
where(job_artifact_id: ids)
# Would need to become:
where(job_artifact_id: ids.map(&:first), partition_id: ids.map(&:second))
4. Update "Add a new Geo data type" issue templates
Edited by 🤖 GitLab Bot 🤖