Idea: Stop syncing data to legacy epic tables
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
WorkItem RelatedLink Implementation Strategy
Background
Issue #515885 (closed) revealed a bug where WorkItem RelatedLinks were created without corresponding Legacy Epic RelatedLinks. This prompted a discussion about how to handle such synchronization issues going forward, especially as work items become the source of truth.
Current State
After completing Workstream 5 for related epic links, the WorkItem system is now the source of truth. We're working on making it the source of truth for Epic-Issue and Epic-Epic hierarchies as well. Epic creation and updates will soon go through WorkItems first.
For RelatedLinks:
- When creating an
issue_linkbetween epic work items, we create a correspondingrelated_epic_linksentry and copy the data. Therelated_epic_linkstable will soon have a NOT NULL constraint onissue_link_id. - Legacy REST and GraphQL APIs query only the
related_epic_linkstable. - While we ensure every
related_epic_linkhas anissue_link, the reverse isn't guaranteed, potentially causing API inconsistencies.
Proposed Solution
Instead of continuing to sync data between tables, we propose using the issue_links IDs directly. We've evaluated several approaches:
Option 1: Negative IDs on API ❌
- Use negative IDs to indicate work item table queries
- Rejected due to existing clients assuming positive integers
Option 2: Store Offset ⚠️
- Store highest ID of
related_epic_linksin separate table - Stop backfilling to
related_epic_links - Use new table for IDs higher than stored maximum
- Problem: Database rollbacks could cause inconsistent IDs
Option 3: Store Offset + Adapt Sequence ✅
Recommended approach:
- Update
RelatedWorkItemLink.idsequence to match maximum ID between both tables - Stop adding records to
RelatedEpicLink - Add rollback trigger to maintain ID synchronization
- Include backdated migration for trigger cleanup
- Maintain ID consistency even during rollbacks
Benefits
- Reduced database writes
- Lower risk of synchronization errors
- No expensive backfills needed
- Consistent treatment of new work item epic data
Drawbacks
- Initial implementation complexity for offset and sequence adaptation
- Risk in handling edge cases during implementation
Alternative
The only alternative is to:
- Continue syncing IDs to legacy tables
- Eventually break and remove existing REST APIs and provide a work-item alternative
