2012-12-27 94 views
8

我正在嘗試設置開發PostgreSQL服務器。它正在運行,我可以從命令行創建角色,表等。然而,當我嘗試使用播放應用變陣,我得到以下錯誤:PostgreSQL演變:「PSQLException:致命:對不起,客戶已經太多了」

org.postgresql.util.PSQLException: FATAL: sorry, too many clients already 

我能夠連接,如果我把故意語法錯誤,它讓我知道,玩返回語法錯誤能夠連接到數據庫。但是,在演變成功應用後,我得到上面顯示的錯誤。

我對PostgreSQl管理並不十分精通,所以我不確定問題出在Play或PostgreSQL安裝上。我只是在運行Mountain Lion的Mac上使用Heroku的Postgres.app安裝它。

這裏是被寫入到控制檯:

! @6cnb0blpp - Internal server error, for request [GET /] -> 

play.api.db.evolutions.InvalidDatabaseRevision: Database 'default' needs evolution! [An SQL script need to be run on your database.] 
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1$$anonfun$apply$1.apply$mcV$sp(Evolutions.scala:427) ~[play_2.9.1.jar:2.0.4] 
    at play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:448) ~[play_2.9.1.jar:2.0.4] 
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:414) ~[play_2.9.1.jar:2.0.4] 
    at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:412) ~[play_2.9.1.jar:2.0.4] 
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) ~[scala-library.jar:0.11.3] 
    at scala.collection.immutable.List.foreach(List.scala:45) ~[scala-library.jar:0.11.3] 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 9. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 8. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 7. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 6. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 5. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 4. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 3. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 2. Exception: null 
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 1. Exception: null 
[error] application - 

謝謝!

回答

2

您可以減少應用程序使用的連接數。在mac安裝上有相同的錯誤。如圖中official documentation

db.default.partitionCount=2 

# The number of connections to create per partition. Setting this to 
# 5 with 3 partitions means you will have 15 unique connections to the 
# database. Note that BoneCP will not create all these connections in 
# one go but rather start off with minConnectionsPerPartition and 
# gradually increase connections as required. 
db.default.maxConnectionsPerPartition=5 

# The number of initial connections, per partition. 
db.default.minConnectionsPerPartition=5 
+0

我已經在我的application.conf中設置了這些設置,但我仍然得到相同的結果。我以前用Play連接到PostgreSQL,而我從來沒有遇到過這個問題,我真的很難過。 – Ryan

5

使用GUC(「Grand Unified Configuration」)max_connectionspostgresql.conf中設置允許的連接數。默認值爲100.

但是在您修補設置之前,您必須問自己:在您的羣集達到限制之前,所有其他100個連接都來自哪裏?這通常指向您的安裝或程序中的錯誤!

您可能也有興趣connection poolingarticle about The Number of Connections在Postgres Wiki中。

+0

這是一個香草Postgres安裝和一個全新的Play 2.0.4項目。到目前爲止,我所有的都是定義的一些模型。是否有日誌可以查找其他連接來自哪裏? – Ryan

+0

@Ryan:你可以設置PostgreSQL來記錄幾乎任何東西。 [從這裏閱讀手冊開始](http://www.postgresql.org/docs/current/interactive/runtime-config-logging.html)。 –

3

Postgres.app默認爲MAX_CONNECTIONS = 10。參見~/Library/Application Support/Postgres/var/postgresql.conf

我通過將max_connections增加到50來解決這個問題。在Mountain Lion,我還必須將shared_buffers減少到500kB以便Postgres啓動。

相關問題