Hello,

Despite being one of "the mapcache devs", I have no answer to the second question. This involves MapCache connection pool which uses APR pools and which I am not familiar with:

https://github.com/MapServer/mapcache/blob/8b4d277df4f7951edd84e4fb8903dc544c3315a9/lib/connection_pool.c#L153

As for the first question, "d1" is not a magical value: this is just a placeholder in the documentation for an actual default time value or time interval.

https://mapserver.org/mapcache/dimensions.html?highlight=d1#configuring-a-time-dimension-using-an-explicit-back-end

Jerome



Le 18/01/2022 à 02:52, David Hoese a écrit :
Trygve,

Hello from outside the Pytroll community ;)

I can't answer your second question as I don't have much experience with getCapabilities, but I think I have an answer for the first question. My understanding for the `default` parameter was that that was the returned time string if no times were returned by the query (empty result). I have always expected this to be a normal time string like 2022-01-01T12:00:00Z (to match your expected format. However, the fact that you always get the oldest image when the default is "d1" is surprising to me so I hope the mapcache devs can correct me.

As for the source code for this, I found that the default from the XML goes into a dimension object as "default_value". It then gets set as the default "requested_value" like here:

https://github.com/MapServer/mapcache/blob/447c0c6848fd101c11e6d54e451037e571117ef1/lib/tileset.c#L585

Going down the rabbit hole led me to here:

https://github.com/MapServer/mapcache/blob/447c0c6848fd101c11e6d54e451037e571117ef1/lib/dimension_pg.c#L265-L271

As far as I can tell "get_values_for_entry_query" is just the "validate_query" query from your XML config. So somehow your validate query with "dp1" input may be returning the oldest time in your database. Just a guess. I'm interested in this answer, but definitely not the best person to give it to you.

Dave

On 1/17/22 11:59, Trygve Aspenes wrote:
Hi there!

Slowly I'm getting mapserver/mapcache up running and looks now how to improve things.

First: When I load a mapcache tileset with time dimension from a pg db the oldest image is displayed in my client. Is it possible to somehow get the newest image as default?
My tileset dimension look something like this:

             <dimension type="postgresql" name="time" default="d1" time="true" unit="ISO8601">
                 <connection>
                     host=mapserver-db user=$PGSQ_USERNAME password=$PGSQ_PASSWORD dbname=mapserver port=5432
                 </connection>
                 <list_query>SELECT to_char(time, 'YYYY-MM-DD"T"HH24:MI:SS"Z"') FROM products where product_name='<some product>' order by Id</list_query>
                 <validate_query>
                     SELECT to_char(time,'YYYY-MM-DD"T"HH24:MI:SS"Z"') FROM products
                     WHERE time &gt;= to_timestamp(:start_timestamp)
                     AND time &lt;= to_timestamp(:end_timestamp)
                     AND product_name='<some product>'
                     ORDER BY time DESC
                 </validate_query>
             </dimension>

I saw the `d1` default value in the documentation, but don't understand of that is a dummy or an actual selector. I have grepped around the source code, but could not see anything obvious.

Second: My client updates/fetch the getCapabilities of my mapcache server every minute. Each time this is fetched the mapcache log is filled with messages like:

mod_mapcache.c(164): [client ] tearing down pooled connection (dim_<some product>_time) to make room, referer: <my client>

I dont understand why these connections is teared down every time getCapabilites is requested.

I have looked in the documentation, but could not see how to control this. But in the mapcache.xml.sample the connection pool config is described. But adding this to my mapcache config does not remove these tear downs.

     <connection_pool>
         <max_connections>2000</max_connections>
<time_to_live_us>120000000</time_to_live_us>
     </connection_pool>

Any suggestions why this connection tear down is happening and if there is something to do about it. It slows down the getCapabilities request a bit, but if I add to many tileset I guess this will even further slow down.

Thanks

Trygve Aspenes
_______________________________________________
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users



_______________________________________________
MapServer-users mailing list
MapServer-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to