Fix multi-round convergence for N-way collisions (bd-108)
- Add AllocateNextID() public method to SQLiteStorage for cross-package ID allocation - Enhance handleRename() to handle collision during rename with retry logic - Fix stale ID map issue by removing deleted IDs from dbByID after rename - Update edge case tests to use convergence rounds consistently - All N-way collision tests now pass (TestFiveCloneCollision, TestEdgeCases)
This commit is contained in:
@@ -636,6 +636,16 @@ func (s *SQLiteStorage) getNextIDForPrefix(ctx context.Context, prefix string) (
|
||||
return nextID, nil
|
||||
}
|
||||
|
||||
// AllocateNextID generates the next issue ID for a given prefix.
|
||||
// This is a public wrapper around getNextIDForPrefix for use by other packages.
|
||||
func (s *SQLiteStorage) AllocateNextID(ctx context.Context, prefix string) (string, error) {
|
||||
nextID, err := s.getNextIDForPrefix(ctx, prefix)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%s-%d", prefix, nextID), nil
|
||||
}
|
||||
|
||||
// SyncAllCounters synchronizes all ID counters based on existing issues in the database
|
||||
// This scans all issues and updates counters to prevent ID collisions with auto-generated IDs
|
||||
// Note: This unconditionally overwrites counter values, allowing them to decrease after deletions
|
||||
|
||||
Reference in New Issue
Block a user