Compare commits
No commits in common. "27e1caf1a6b687fd5742c03286c7a72321d41252" and "d2dd67c311b805f65cc88464d02ec028ddf84e5d" have entirely different histories.
27e1caf1a6
...
d2dd67c311
1 changed files with 2 additions and 4 deletions
|
|
@ -450,9 +450,7 @@ async function acceptCollectionSuggestion(name, modelIds = null) {
|
||||||
ORDER BY name = lower(name), name LIMIT 1), $1)
|
ORDER BY name = lower(name), name LIMIT 1), $1)
|
||||||
RETURNING *`, [name]));
|
RETURNING *`, [name]));
|
||||||
}
|
}
|
||||||
// Sorted, so two of these at once take the model_projects rows in the same
|
const ids = waiting.map((w) => w.model_id);
|
||||||
// order rather than deadlocking on each other.
|
|
||||||
const ids = waiting.map((w) => w.model_id).sort((a, b) => a - b);
|
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
await client.query('INSERT INTO model_projects (model_id, project_id) VALUES ($1, $2) ON CONFLICT DO NOTHING', [id, project.id]);
|
await client.query('INSERT INTO model_projects (model_id, project_id) VALUES ($1, $2) ON CONFLICT DO NOTHING', [id, project.id]);
|
||||||
}
|
}
|
||||||
|
|
@ -487,7 +485,7 @@ async function getAllTags() {
|
||||||
// ---------------------------------------------------------------- projects
|
// ---------------------------------------------------------------- projects
|
||||||
async function setProjects(client, modelId, projectIds) {
|
async function setProjects(client, modelId, projectIds) {
|
||||||
await client.query('DELETE FROM model_projects WHERE model_id = $1', [modelId]);
|
await client.query('DELETE FROM model_projects WHERE model_id = $1', [modelId]);
|
||||||
for (const pid of [...projectIds].sort((a, b) => a - b)) { // one lock order, always
|
for (const pid of projectIds) {
|
||||||
await client.query(
|
await client.query(
|
||||||
'INSERT INTO model_projects (model_id, project_id) VALUES ($1,$2) ON CONFLICT DO NOTHING',
|
'INSERT INTO model_projects (model_id, project_id) VALUES ($1,$2) ON CONFLICT DO NOTHING',
|
||||||
[modelId, pid]);
|
[modelId, pid]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue