Epics being created with duplicate `iid`s
<!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary See https://gitlab.slack.com/archives/CETG54GQ0/p1604623964331700 Creating an epic sometimes results in the reuse of an existing `iid`. This causes unexpected behavior, such as one of the epics being visible in links and tooltips but unavailable due to a URL collision with the other. ### Steps to reproduce <!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. --> ### Example Project [This issue](https://gitlab.com/gitlab-org/gitlab/-/issues/277060) has an epic called [Supported Kubernetes Versions](https://gitlab.com/groups/gitlab-org/-/epics/4827). When clicked, it links instead to [Improve Test Efficiency](https://gitlab.com/groups/gitlab-org/-/epics/4827) because there's an `iid` collision. ### What is the current *bug* behavior? <!-- Describe what actually happens. --> ### What is the expected *correct* behavior? <!-- Describe what you should see instead. --> ### Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. --> ### Output of checks This bug happens on GitLab.com ### Possible fixes - In a transaction: - [x] Iterate over duplicates and assign a new `iid` to each - [x] Add a unique index (something like `CREATE UNIQUE INDEX index_epics_on_group_id_and_iid ON epics USING btree (group_id, iid);`
issue