Race condition when connecting a relation (transaction rollback)
### Node Version

20.18.0

### NPM/Yarn/PNPM Version

10.8.2

### Strapi Version

5.9.0

### Operating System

Linux (Debian/Ubuntu)

### Database

PostgreSQL

### Javascript or Typescript

Typescript

### Reproduction URL

_No response_

### Bug Description

I have two Collections, one called "MythicHistory" and one called "RaidRewardFeature".
They are related in this way: RaidRewardFeature belongs to many MythicHistories

Now the problem is, I'm running two API calls simultaneously, 
`POST <url>/api/mythic-histories`
```
{
    "data": {
        "raid_reward_feature": {
            "connect": [
                "kuauttomp8x61jt12ye96nm7"
            ]
        },
    }
}
```

and:

`PUT <url>/api/raid-reward-features/kuauttomp8x61jt12ye96nm7`
```
{
    "data": {
        .....
    }
}
```
What should happen is, the mythic history is created and linked (a strapi inner transaction is called, created the mythic history and THEN linking it to the RaidRewardFeature), and the RaidRewardFeature is updated.
But sometimes, this happens:

Strapi logs:
```
[2025-02-03 16:36:42.141] http: PUT /api/raid-reward-features/fyh3iw73iia4k3pqly7bvyos (134 ms) 200
[2025-02-03 16:36:42.148] error: delete from "public"."mythic_histories" where ("id" = $1) - current transaction is aborted, commands ignored until end of transaction block
error: delete from "public"."mythic_histories" where ("id" = $1) - current transaction is aborted, commands ignored until end of transaction block
    at Parser.parseErrorMessage (/opt/node_modules/pg-protocol/dist/parser.js:283:98)
    at Parser.handlePacket (/opt/node_modules/pg-protocol/dist/parser.js:122:29)
    at Parser.parse (/opt/node_modules/pg-protocol/dist/parser.js:35:38)
    at Socket.<anonymous> (/opt/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:518:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
[2025-02-03 16:36:42.152] http: POST /api/mythic-histories (157 ms) 500

```
Postgres 16 logs:
```
2025-02-03 16:36:42.139 UTC [191792] ERROR:  insert or update on table "mythic_histories_raid_reward_feature_lnk" violates foreign key constraint "mythic_histories_raid_reward_feature_lnk_ifk"
2025-02-03 16:36:42.139 UTC [191792] DETAIL:  Key (raid_reward_feature_id)=(79077) is not present in table "raid_reward_features".
2025-02-03 16:36:42.139 UTC [191792] STATEMENT:  insert into "public"."mythic_histories_raid_reward_feature_lnk" ("mythic_history_id", "mythic_history_ord", "raid_reward_feature_id") values ($1, $2, $3) returning "id"
2025-02-03 16:36:42.144 UTC [191792] ERROR:  current transaction is aborted, commands ignored until end of transaction block
2025-02-03 16:36:42.144 UTC [191792] STATEMENT:  delete from "public"."mythic_histories" where ("id" = $1)
```


Basically, what I think happened is, there was a race condition, when the RaidRewardFeature was updated, in strapi v5, you update the id (increment it) and at the same time, in the mythic history transaction, the mythic history was created but couldn't link to the RaidRewardFeature because it was using the old unUpdated ID, so the transaction fails and the mythic history is deleted because it couldn't "connect" to the RaidRewardFeature.
Why is it even using the id instead of documentId, since the ID changes/isn't static.

### Steps to Reproduce

1 - Create two collections A and B.
2 - Add a relation between them: A belongs to many B
3 - Make an instance of A and B that are linked.
4 - Update A and Create B at the same time.

### Expected Behavior

The RaidRewardFeature is updated and the mythic history is created.

### Logs

```shell
Strapi logs:

[2025-02-03 16:36:42.141] http: PUT /api/raid-reward-features/fyh3iw73iia4k3pqly7bvyos (134 ms) 200
[2025-02-03 16:36:42.148] error: delete from "public"."mythic_histories" where ("id" = $1) - current transaction is aborted, commands ignored until end of transaction block
error: delete from "public"."mythic_histories" where ("id" = $1) - current transaction is aborted, commands ignored until end of transaction block
    at Parser.parseErrorMessage (/opt/node_modules/pg-protocol/dist/parser.js:283:98)
    at Parser.handlePacket (/opt/node_modules/pg-protocol/dist/parser.js:122:29)
    at Parser.parse (/opt/node_modules/pg-protocol/dist/parser.js:35:38)
    at Socket.<anonymous> (/opt/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:518:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
[2025-02-03 16:36:42.152] http: POST /api/mythic-histories (157 ms) 500


Postgres 16 logs:

2025-02-03 16:36:42.139 UTC [191792] ERROR:  insert or update on table "mythic_histories_raid_reward_feature_lnk" violates foreign key constraint "mythic_histories_raid_reward_feature_lnk_ifk"
2025-02-03 16:36:42.139 UTC [191792] DETAIL:  Key (raid_reward_feature_id)=(79077) is not present in table "raid_reward_features".
2025-02-03 16:36:42.139 UTC [191792] STATEMENT:  insert into "public"."mythic_histories_raid_reward_feature_lnk" ("mythic_history_id", "mythic_history_ord", "raid_reward_feature_id") values ($1, $2, $3) returning "id"
2025-02-03 16:36:42.144 UTC [191792] ERROR:  current transaction is aborted, commands ignored until end of transaction block
2025-02-03 16:36:42.144 UTC [191792] STATEMENT:  delete from "public"."mythic_histories" where ("id" = $1)
```
Here are some images:

![Image](https://github.com/user-attachments/assets/7e00a7cd-c1a4-46f9-881a-4fb036bd3cbc)
![Image](https://github.com/user-attachments/assets/0812d6ce-f194-4c10-901c-7d5b72615ab8)


### Code Snippets

_No response_

### Media

_No response_

### Additional information

_No response_

### Confirmation Checklist

- [x] I have checked the existing [issues](https://github.com/strapi/strapi/issues) for duplicates.
- [x] I agree to follow this project's [Code of Conduct](https://github.com/strapi/strapi/blob/develop/CODE_OF_CONDUCT.md).