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

Unknown Exception - Matrix calculation with local ORS instance for large amounts of data #180

Open
lautre7 opened this issue Apr 26, 2023 · 4 comments

Comments

@lautre7
Copy link

lautre7 commented Apr 26, 2023

Context:

Our local ORS instance has worked without problems so far. Recently, we increased the capacity for matrix calculation to 20,000 connections per request in order to evaluate larger amounts of points.

A large number of individual requests with less than 20,000 connections are sent to the local instance by a PyQGIS script in a loop via the QGIS plugin.

Excerpt from the script:


l = []
err = [] #Liste mit Punkten bei denen ORS eine Fehlermeldung auswirft

for point in region_points.getFeatures():
    point_id = int(point['id'])
    processing.run("qgis:selectbyattribute", {'INPUT':region_points,'FIELD':'id','OPERATOR':0,'VALUE':point_id,'METHOD':0})
    origin = processing.run("native:saveselectedfeatures", {'INPUT':region_points,'OUTPUT':'TEMPORARY_OUTPUT'}) 

    matrix_out = matrix_folder +'matrix_' +region_name +'_'+str(grid_space)+'mgrid_'+ str(point_id) + ".csv"
    l.append(matrix_out)

    try:
        processing.run("ORS Tools:matrix_from_layers", {'INPUT_PROVIDER':1,'INPUT_PROFILE':0,'INPUT_START_LAYER':origin['OUTPUT'],'INPUT_START_FIELD':'id','INPUT_END_LAYER':destinations_all['OUTPUT'],'INPUT_END_FIELD':'id','OUTPUT':matrix_out})
          
         
    except Exception:
        traceback.print_exc()
        err.append(point_id)

Problem:

For all tested records, an exception occurs after a certain number of requests, which we cannot explain and which also causes all subsequent requests from the same QGIS window to fail for several hours. Subsequently, further requests suddenly work again. Their quantity may be greater than that of the matrices created before the problem.

grafik
Line 50 is the line where the matrix tool is called.

I have attached a record of start and destination points where the problem occurred:
destinationpoints.zip
originpoints.zip

With this data set 739 matrices were calculated, then the error occurred for several hours with each query, before another 10,600 matrices were calculated without problems or further pauses.

Manual calculation:

I tried to compute the connections of the missing points manually with the tool "Matrix from Layers", but also after 739 elements the same problem occurred. There were also no new requests from this QGIS window, the error occurred immediately. I have also added the log files:

QGIS_Matrix_from_layers_Protocol.txt

The issue occurred in QGIS versions 3. 24. 2 and 3. 28. 4. For different output data (different number of points), the error occurred after a different number of requests.
There is no noticeable downtime of the service and there does not seem to be any capacity problems.
The search, whether the error could be with QGIS, has yielded nothing. We have not found any similar problems in your forum.

Our theory would be that there may be some restriction on requests (per time) in the backend of the ORS, but here it is questionable why a larger number of requests will work after the error occurs than before.

Can you help us with that?

Thank you very much.

@TheGreatRefrigerator TheGreatRefrigerator changed the title Unknown Exception - ORS-Tools Matrixberechnung mit lokaler ORS Instanz bei großen Datenmengen [German] Unknown Exception - Matrix calculation with local ORS instance for large amounts of data Apr 26, 2023
@TheGreatRefrigerator
Copy link
Collaborator

Hi @lautre7,
(please stick to english in github issues, so a broader audience can read it. You can just use e.g. pons or google translator)

Did you already increase the timeout in the provider settings to the maximum value?
Apart from that that might also be an issue with some of the data points that get the request stuck in the backend.

Both using the plugin with a local ors instance and using the algorithms in separate pyqgis scripts is not really tested.

You could do a selective Matrix for the features that produce the error, and take a look at them if the error persists.
(so setting e.g. the features around 739 as sources and in another run as destinations)
That way you might be able to better identify the error.

Best regards

@lautre7
Copy link
Author

lautre7 commented Apr 27, 2023

Hi @TheGreatRefrigerator,
thanks for the fast answer. (Sorry, I was told by one of your co-workers I could ask in German, but I see why English is better.)

Yes, the timeout is on maximum value. The error occurs immediately when the concerning request is sent, so that should not be the problem.
I am sure the data points are not the problem, since they are all generated automatically by the same algorithm and the error does not occur on subsets of the error points. Also, it occurs on different sets of points in different regions.

It seems to depend mainly on the count of points and the number of requests, so I guess somewhere there is a limitation of the number of individual routes or of the amount of data, but it is funny that after a few hours of error requests, it continues to work for more requests and routes than before the error occured.

I don't know if it comes from the plug-in, QGIS itself or the ORS instance, but if you happen to find the reason, I am very curious. In the meantime I am using a workaround.

Best regards

@MichaelsJP
Copy link
Member

@lautre7 Thanks for posting your issue. Could you paste your ors config file in here (without the sensitive parts, of course)?
That would definitely help.

@lautre7
Copy link
Author

lautre7 commented May 11, 2023

@MichaelsJP Here's the config file, sorry it took so long.
ors-config.zip

@MichaelsJP MichaelsJP added the easy fix Issues that are rather quick to be resolved label Oct 2, 2023
@koebi koebi removed the easy fix Issues that are rather quick to be resolved label Nov 6, 2023
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

No branches or pull requests

4 participants