Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cluster Layer GetMetadata fix with test #6278

Merged
merged 1 commit into from
Mar 27, 2021

Conversation

geographika
Copy link
Member

Fix for GetMetadata calls on a database layer with no EXTENT. See #6277.
Adds in a test used to recreate the error (with an additional cluster image test) for a MSSQL layer.

The fix simply removes any clustering in msMetadataGetLayerMetadata. As clustering won't have an effect on the source metadata, and the function is only called by a GetMetadata this should have no side-effects.

Attempting to modify msClusterLayerOpen to try and copy across connection objects etc. would be an alternative, and more complicated solution, but I'm unaware of any similar issues with other service calls and cluster layers.

@jmckenna jmckenna added this to the 8.0 Release milestone Mar 27, 2021
@sdlime sdlime requested a review from szekerest March 27, 2021 17:26
@jmckenna
Copy link
Member

thanks @geographika !

@jmckenna jmckenna merged commit 6ebf2ac into MapServer:main Mar 27, 2021
@@ -687,6 +687,11 @@ xmlNodePtr msMetadataGetLayerMetadata(mapObj *map, metadataParamsObj *paramsObj,
if(strcasecmp(GET_LAYER(map, i)->name, paramsObj->pszLayer) == 0) {
layer_found = MS_TRUE;
layer = GET_LAYER(map, i);
// when checking a layer with clustering msLayerGetExtent does not have access
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling this isn't the right fix. That wouldn't fix the crash for someone calling msLayerGetExtent() through the C API or Mapscript, would it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only called using the GetMetadata request (see https://mapserver.org/ogc/layer_metadata.html) - there is no mapscript access currently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only called using the GetMetadata request

yes, but isn't the issue fundamentally with msLayerGetExtent() called on a clustered layer ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True.. Cluster layers are a special case in msLayerOpen. Then a copy is made of the original layer in msClusterLayerOpen, but it is the source layer vtable which is opened, but then the copied layer doesn't have the original connection - I had a hard time trying to follow exactly what is happening here.
I've not had any cases of msLayerGetExtent calls crashing the server apart from through GetMetadata, but this may be luck/missing logs. The fix in this pull request prevents a server crash, but I agree it would be better to fix the underlying issue.

@@ -0,0 +1,51 @@
#
# Test a clustered layer with the MSSQL driver plugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the issue specific to using mssql ? Can't the be reproduced with shapefiles ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is around a NULL layerinfo->conn in the database driver when trying to get the extent from the database. Shapefiles would be unaffected, but I'd image the PostGIS and Oracle drivers would have the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants