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

vrp functions crash server #1861

Closed
cvvergara opened this issue Jan 22, 2021 · 0 comments · Fixed by #1863
Closed

vrp functions crash server #1861

cvvergara opened this issue Jan 22, 2021 · 0 comments · Fixed by #1863

Comments

@cvvergara
Copy link
Member

Problem

Server crash

To Reproduce

I was experimenting with what would happen if the code of the vrp functions were executed from a different extension name, this experiment is to look forward to move the vrp functions to a public different repository
So, I created a pgRouting extension and a vrpRouting extension with exactly the same code of pgRouting
and on the vrpRouting extension I ran:

PREPARE No_problem_query AS
SELECT * FROM vrp_pickDeliver(
    $$ SELECT * FROM orders ORDER BY id $$,
    $$ SELECT * FROM vehicles ORDER BY id$$,
    $$ SELECT * FROM pgr_dijkstraCostMatrix(
        'SELECT * FROM edge_table ',
        (SELECT array_agg(id) FROM (SELECT p_node_id AS id FROM orders
        UNION
        SELECT d_node_id FROM orders
        UNION
        SELECT start_node_id FROM vehicles) a),
        directed => false)
    $$
);

this is combines pgRouting and vrpRouting

SELECT * FROM vrp_pickDeliver(
...
$$ SELECT * FROM pgr_dijkstraCostMatrix(
...

Which generated a server crash.
The way it generated the server crash was as follows:
For simplification:
pgtap test = pgtap test with one or more queries that combines the 2 extensions
test = a pgtap test can have or can not have a query that combines the 2 extensions
Ran a pgtap test without problems, but when the next test started the server crash happened.

2021-01-17 09:05:24.776 CST [15181] HINT:  In a moment you should be able to reconnect to the database and repeat your command.
2021-01-17 09:05:24.777 CST [19237] vicky@pgr_test__db__test WARNING:  terminating connection because of crash of another server process
2021-01-17 09:05:24.777 CST [19237] vicky@pgr_test__db__test DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2021-01-17 09:05:24.777 CST [19237] vicky@pgr_test__db__test HINT:  In a moment you should be able to reconnect to the database and repeat your command.

Expectation

No server crash

Solution
I suspect it was because the code is using a singleton which creates a pointer only once, but when the process ends, it loads a different instance and the pointer do not match to the new instance.

Remove the singleton and use something different.

Sample Data
pgRouting's sampledata

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

Successfully merging a pull request may close this issue.

1 participant