2012-12-27 15 views
8

Sto provando a configurare un server PostgreSQL dev. È in esecuzione e sono in grado di creare ruoli, tabelle, ecc. Dalla riga di comando. Tuttavia quando provo ad applicare evoluzioni utilizzando Play, ottengo il seguente errore:Evoluzioni PostgreSQL: "PSQLException: FATAL: mi dispiace, troppi clienti già"

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

sono in grado di connettersi e se ho messo in un errore di sintassi di proposito, restituisce l'errore di sintassi quindi so che il gioco è in grado di connettersi al database. Tuttavia, dopo che l'evoluzione è stata applicata correttamente, ottengo l'errore mostrato sopra.

Non sono molto esperto nell'amministrazione di PostgreSQl, quindi non sono sicuro che il problema sia relativo all'installazione di Play o PostgreSQL. L'ho appena installato usando Heroku's Postgres.app su un Mac che esegue Mountain Lion.

Ecco ciò che viene scritto nella console:

! @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 - 

Grazie!

risposta

2

È possibile ridurre il numero di connessioni utilizzate dall'applicazione. Ho avuto gli stessi errori su un'installazione mac. Come mostrato nella 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

Ho impostato queste impostazioni nel mio application.conf ma ho ancora lo stesso risultato. Mi sono collegato a PostgreSQL in passato con Play e non ho mai avuto questo problema, sono davvero perplesso. – Ryan

5

Il numero di connessioni consentite è impostato su postgresql.conf con GUC ("Grand Unified Configuration") max_connections. Il valore predefinito è 100.

Ma prima di armeggiare con l'impostazione, è necessario chiedersi: da dove provengono tutte le altre 100 connessioni, prima che il cluster raggiunga il limite? Questo di solito indica un bug nell'installazione o nel programma!

Potreste anche essere interessati a connection pooling e questo article about The Number of Connections nel Wiki Postgres.

+0

È un'installazione vaniglia Postgres e un nuovissimo progetto Play 2.0.4. Tutto quello che ho finora sono definiti alcuni modelli. C'è un registro che posso cercare per capire da dove vengono le altre connessioni? – Ryan

+0

@Ryan: puoi impostare PostgreSQL per registrare praticamente tutto. [Inizia leggendo il manuale qui] (http://www.postgresql.org/docs/current/interactive/runtime-config-logging.html). –

3

default Postgres.app a max_connections = 10. Vedere ~/Library/Application Support/Postgres/var/postgresql.conf.

Ho risolto questo problema aumentando max_connections a 50. Su Mountain Lion ho dovuto ridurre anche shared_buffers a 500kB per l'avvio di Postgres.

Problemi correlati