mapnik / mapnik-support

Use the issues queue here to ask questions and offer help on using Mapnik (maybe if this works well we can retire the mailing list at http://mapnik.org/contact/?)
6 stars 6 forks source link

Multithreaded Mapnik PostgreSQL Config Corruption #89

Closed fchorney closed 7 years ago

fchorney commented 7 years ago

OK, so I'm not sure if this is because I'm multi threading or what, but I seem to be having this weird issue with my connection string being weird and corrupt.

My mapnik.Map and mapnik.load_map are both being called after the process is created, and only exists within that process.

# Load mapnik map config
m = mapnik.Map(size_i, size_i)
mapnik.load_map(
    m,
    join('/cti/rcrs/render/xml/', province, layer_filename),
    True,
)

My xml for this one spot it seems to be erroring out on looks as such [certain things have place holders as to not have actual username/password/etc

base.xml (srs= is the "line 23" that the error points to)

<Style name="boundary_fill_prov" filter-mode="first">
  <Rule>
    <PolygonSymbolizer fill-opacity="1" fill="#cdccca" />
  </Rule>
</Style>
<Layer name="boundary_fill_prov"
  srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName>boundary_fill_prov</StyleName>
    <Datasource>
       <Parameter name="type"><![CDATA[postgis]]></Parameter>
       <Parameter name="table"><![CDATA[(SELECT * FROM XXX) AS data]]></Parameter>
       <Parameter name="key_field"><![CDATA[gid]]></Parameter>
       <Parameter name="geometry_field"><![CDATA[geom]]></Parameter>
       <Parameter name="extent_cache"><![CDATA[auto]]></Parameter>
       <Parameter name="extent"><![CDATA[-13358492.9078094,6274295.81657785,-12245674.2969556,8399831.75147526]]></Parameter>
       <Parameter name="dbname"><![CDATA[dbname]]></Parameter>
       <Parameter name="host"><![CDATA[localhost]]></Parameter>
       <Parameter name="port"><![CDATA[0000]]</Parameter>
       <Parameter name="user"><![CDATA[user]]></Parameter>
       <Parameter name="password"><![CDATA[password]]></Parameter>
    </Datasource>
  </Layer>

So what I seem to be getting at the mapnik.load_map function is as follows

RuntimeError: Postgis Plugin: invalid port number: "51624264"

Connection string: 'host=51623752 port=51624264 dbname=51623240 user=51624776 connect_timeout=4'
  encountered during parsing of layer 'boundary_fill_prov' in Layer at line 23 of 'base.xml'

As you can see, I seem to be getting weird big numbers in the host/port/dbname/user fields for some reason. They seem to be different every time. Is the memory for that stuff being corrupted somehow? I'm not sure where to go from here. Thanks

springmeyer commented 7 years ago

This looks very odd, thanks for the report. What mapnik version are you seeing this with and what libpq client (postgres version)? /cc @artemp

fchorney commented 7 years ago
$ mapnik-config --version
3.0.12
$ psql --version
psql (PostgreSQL) 9.3.16

That's what you're looking for?

fchorney commented 7 years ago

so... I'm starting to think that maybe this is just a user error somehow. I decided to install the python mapnik bindings again, (and I ran the tests this time, I think I forgot to last time), and it seems to be working correctly now. Was using it in a virtualenv as well. Might have just been somehow half installed or something?

springmeyer commented 7 years ago

it seems to be working correctly now

That is great to hear.

Might have just been somehow half installed or something?

Possible yes. Duplicate versions or partial installs can cause bizarre behavior. A fully clean install is a good first step.

I close this now that you think it is working, please re-open if you hit the error again.