0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed deadlock when adding multiple authors in tests

refs 275107d423

- Because there might be multiple authors being added at the same time with different values to the posts_authors table these operations should not be done in parallel! Making post insertion sequential fixed the deadlock
This commit is contained in:
Naz 2022-05-03 16:28:07 +08:00
parent 275107d423
commit 734ef66e6c

View file

@ -6,6 +6,7 @@ const fs = require('fs-extra');
const uuid = require('uuid');
const ObjectId = require('bson-objectid');
const KnexMigrator = require('knex-migrator');
const {sequence} = require('@tryghost/promise');
const knexMigrator = new KnexMigrator();
// Ghost Internals
@ -26,9 +27,11 @@ let postsInserted = 0;
/** TEST FIXTURES **/
const fixtures = {
insertPosts: function insertPosts(posts) {
return Promise.map(posts, function (post) {
const tasks = posts.map(post => () => {
return models.Post.add(post, context.internal);
});
return sequence(tasks);
},
insertPostsAndTags: function insertPostsAndTags() {