上周,我的集成测试运行良好。今天,在我的测试开始运行之前,始终会抛出该异常:
org.postgresql.util.PSQLException: FATAL: could not open file "base/12669/2601": No such file or directory
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2566)
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:131)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:210)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:452)
at org.postgresql.Driver.connect(Driver.java:254)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.onzo.analytics.dal.PostgresForTesting.openConnection(PostgresForTesting.scala:111)
PostgresForTesting.scala:111是我的代码中此函数的主体:
private def openConnection(): Unit = {
_connection = DriverManager.getConnection(_dbUrl)
}
DriverManager
是java.sql.DriverManager
。
_dbUrl
在此处设置:
private def startPostgres(): Unit = {
val port = 5431 // standard port is 5432; use a non-standard port to avoid accidentally using a real Postgres
_postgres = new EmbeddedPostgres(Version.V9_6_8, "imadatadir") // I changed this
val config = sys.env.get("HOME") match {
case None => EmbeddedPostgres.defaultRuntimeConfig()
case Some(ndHome) =>
val cache = Paths.get(ndHome, ".cache", "embedded-postgres")
Files.createDirectories(cache)
EmbeddedPostgres.cachedRuntimeConfig(cache)
}
// downloads Postgres, caches it locally (101MB)
_dbUrl = _postgres.start(config, "localhost", port, _dbName, "username", "password", new util.ArrayList[String])
val executor = AsyncExecutor(
name = "pg-for-testing",
minThreads = this.postgresConfig.numThreads,
maxThreads = this.postgresConfig.numThreads,
maxConnections = this.postgresConfig.maxConnections,
queueSize = this.postgresConfig.queueSize
)
_db = Database.forURL(_dbUrl, driver = "org.postgresql.Driver", executor = executor)
}
EmbeddedPostgres
是ru.yandex.qatools.embed.postgresql.EmbeddedPostgres
,来自postgresql-embedded。
在今天早上这个问题变得丑陋之前,我使用的是临时目录,而不是对imadatadir
目录进行硬编码。 (请参阅标记为I changed this
的行。)我对imadatadir
目录进行了硬编码,以尝试调试此问题。 (所以这不是导致问题的原因。)
有趣的事实:它抱怨无法打开的base/12669/2601
文件确实存在:
$ ls -l imadatadir/base/12669/2601*
-rw------- 1 dave.hinton staff 8192 17 Dec 12:57 imadatadir/base/12669/2601
-rw------- 1 dave.hinton staff 24576 17 Dec 12:57 imadatadir/base/12669/2601_fsm
-rw------- 1 dave.hinton staff 8192 17 Dec 12:57 imadatadir/base/12669/2601_vm
可能不相关的其他事实
版本:
关于如何使它重新工作的任何想法?或者至少进一步调查出了什么问题?