Recap
-----
I have a layer group.
Sometimes, when it is rendered via WMS, some (openlayers) tiles are missing
some of the styles.
See image attached to this thread.
Explanation
-----------
summary: don't let geoserver ask for too many database connections - set
"max connections" parameter to a relatively low number.
disclaimer: I am not a real DBA or sys admin - but I have to wear those
hats.
Details:
I had a layer group specified in geoserver - 16 layers....
<BaseMapGroup baseMapTitle = "layer-group_map" >
<baseMapLayers>postgis:bayarea_general,postgis:parks,postgis:waterbodies,postgis:v_citylots,postgis:v_roads_0,postgis:v_roads_1,postgis:v_roads_2,postgis:v_roads_0,postgis:v_roads_1,postgis:v_roads_2,postgis:v_roads_2,postgis:v_roads_1,postgis:v_roads_0,postgis:v_roads_3,postgis:v_roads_3,postgis:v_roads_3</baseMapLayers>
<baseMapStyles>900913_map_bayarea_general,900913_map_parks,900913_map_waterbodies,900913_map_citylots,900913_map_roads_0_outer,900913_map_roads_1_outer,900913_map_roads_2_outer,900913_map_roads_0_inner,900913_map_roads_1_inner,900913_map_roads_2_inner,900913_map_roads_2_label,900913_map_roads_1_label,900913_map_roads_0_label,900913_map_roads_3_outer,900913_map_roads_3_inner,900913_map_roads_3_label</baseMapStyles>
<baseMapEnvelope srsName = "EPSG:900913" >
<pos>-1.3892984E7 4350270.99999996</pos>
<pos>-1.3410216E7 4804494.999999971</pos>
</baseMapEnvelope>
</BaseMapGroup>
A little crazy - yes - but I did it this way to help reduce the complexity
of the SLDs.
(looking forward to using the SLD tools that OpenGeo.org)
When I set up the postgis layers I accepted the defaults (relevant elements
only):
<datastore id = "roads_2" enabled = "true" namespace = "postgis" >
<connectionParams >
<parameter name = "validate connections" value = "false" />
<parameter name = "max connections" value = "10" />
<parameter name = "min connections" value = "4" />
</connectionParams>
</datastore>
And when I installed postgresQL I took the deafults provided in
postgresql.conf for max connections
- max_connections = 100 # (change requires restart)
So the particluar combination of
- layer-group specification
- layer connection pool specification
- postgresQL max connections specification
results in geoserver asking for more postgresql connections than my little
dev box could support.
The messages I was getting in the postgresQL log files did not make this
clear - due to my lack of expertise as a DBA I am sure.
Version 8.2 log output for example said something like:
2008-05-28 14:00:50 LOG: server process (PID 5592) exited with exit
code -1073741502
and then postgres restarts itself.
Version 8.3 provides an exit code that maps to something like "could not
load dll".
Then the 8.3 dataserver would actually stop (crash).
How to Fix It
-------------
Obviously, it is unacceptable to the dataserver to go down - so first I
lowered the postgresql.conf max connections
- max_connections = 50
What number you use depends on a number of factors - plenty of material
about this on the web.
This alone prevents postgresql from crashing - a very good thing.
However, if this is all you do, geoserver will still drops styles in the
layer-group rendering.
From the geoserver log:
13 Jun 10:40:07 ERROR [geotools.rendering] - Could not aquire
feature:org.geotools.data.DataSourceException: Connection
failed:org.postgresql.util.PSQLException: FATAL: sorry, too many clients
already
Validating connections does not help here.
Bottom line is that I needed to reduce the number of connections per layer:
e.g.
<datastore id = "roads_2" enabled = "true" namespace = "postgis" >
<connectionParams >
<parameter name = "validate connections" value = "false" />
<parameter name = "max connections" value = "2" />
<parameter name = "min connections" value = "1" />
</connectionParams>
</datastore>
RE:
http://geoserver.org/display/GEOSDOC/Connection+pooling+options+(for+DBMS+based+datastores)
So I'll conjecture that if I have a layer group with 16 layers (as defined
above) with the pool specs (just above),
calls to that layer group may results in as many as 32 database connections.
Perhaps a geoserver developer could confirm this?
In any case, the configuration resolves all of my problems and does not
appear to impact performance in my dev env.
My QA and PROD configs will be slightly more generous because I have more
resources there.
It also worth noting that for my use case, we use WMS to seed our tilecache.
Therefore, I care more about the integrity of the rendered map tiles than I
care about performance.
Database versions had no bearing on this problem - although I did see
different db log messages between 8.2 and 8.3.
Key words / phrases
-------------------
postgresql
postgis
database connection
connection pool
geoserver
styles
rendering
Regards,
Paul
--
View this message in context: http://www.nabble.com/Styles-dropping-out-tp17471813p17831310.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.