在CircleCI上进行笑话测试时,如何防止postgres死锁?

时间:2018-10-16 00:40:42

标签: integration-testing jestjs circleci

当我在CircleCI上运行测试时,它多次记录以下消息,最终测试失败,因为由于死锁,没有一个数据库方法可以检索数据:

{
  "message": "Error running raw sql query in pool.",
  "stack": "error: deadlock detected\n    at Connection.Object.<anonymous>.Connection.parseE (/home/circleci/backend/node_modules/pg/lib/connection.js:567:11)\n    at Connection.Object.<anonymous>.Connection.parseMessage (/home/circleci/-backend/node_modules/pg/lib/connection.js:391:17)\n    at Socket.<anonymous> (/home/circleci/backend/node_modules/pg/lib/connection.js:129:22)\n    at emitOne (events.js:116:13)\n    at Socket.emit (events.js:211:7)\n    at addChunk (_stream_readable.js:263:12)\n    at readableAddChunk (_stream_readable.js:250:11)\n    at Socket.Readable.push (_stream_readable.js:208:10)\n    at TCP.onread (net.js:597:20)",
  "name": "error",
  "length": 316,
  "severity": "ERROR",
  "code": "40P01",
  "detail": "Process 1000 waits for AccessExclusiveLock on relation 17925 of database 16384; blocked by process 986.\nProcess 986 waits for RowShareLock on relation 17870 of database 16384; blocked by process 1000.",
  "hint": "See server log for query details.",
  "file": "deadlock.c",
  "line": "1140",
  "routine": "DeadLockReport",
  "level": "error",
  "timestamp": "2018-10-15T20:54:29.221Z"
}

这是我运行的测试命令:jest --logHeapUsage --forceExit --runInBand

  • 我也尝试过:jest --logHeapUsage --forceExit --maxWorkers=2

几乎所有测试都运行某种数据库功能。仅当我们添加更多测试时才开始出现此问题。还有其他人遇到过同样的问题吗?

0 个答案:

没有答案