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

ERROR: relation "search_name" does not exist at character 1161 when importing with --reverse-only #3583

Closed
leonardehrenfried opened this issue Nov 12, 2024 · 5 comments · Fixed by #3588

Comments

@leonardehrenfried
Copy link

leonardehrenfried commented Nov 12, 2024

Describe the bug

We are in the process of updating nominatim-docker and during our automated tests, I noticed that the test case that imports with --reverse-only and then queries breaks because it cannot find a table.

Endpoint returned status code 500: b'{"title": "500 Internal Server Error"}'
2024-11-12 13:51:27.727 UTC [293] nominatim@nominatim ERROR:  relation "search_name" does not exist at character 1161
2024-11-12 13:51:27.727 UTC [293] nominatim@nominatim STATEMENT:  WITH searches AS 
	(SELECT anon_1.place_id AS place_id, anon_1.search_rank AS search_rank, anon_1.address_rank AS address_rank, anon_1.country_code AS country_code, anon_1.centroid AS centroid, anon_1.importance AS importance, anon_1.penalty AS penalty 
	FROM (SELECT anon_2.place_id AS place_id, anon_2.search_rank AS search_rank, anon_2.address_rank AS address_rank, anon_2.country_code AS country_code, anon_2.centroid AS centroid, anon_2.importance AS importance, anon_2.penalty AS penalty, first_value(anon_2.penalty - anon_2.importance) OVER (ORDER BY anon_2.penalty - anon_2.importance) AS min_penalty 
	FROM (SELECT search_name.place_id AS place_id, search_name.search_rank AS search_rank, search_name.address_rank AS address_rank, search_name.country_code AS country_code, search_name.centroid AS centroid, search_name.name_vector AS name_vector, search_name.nameaddress_vector AS nameaddress_vector, CASE WHEN (search_name.importance > $1::INTEGER) THEN search_name.importance ELSE $2 - CAST(search_name.search_rank AS FLOAT) / CAST($3::INTEGER AS NUMERIC) END AS importance, $4 + weigh_search(search_name.name_vector, $5::VARCHAR, $6) AS penalty 
	FROM search_name 
	WHERE (search_name.name_vector @> $7::INTEGER[]) ORDER BY importance DESC 
	 LIMIT $8::INTEGER) AS anon_2) AS anon_1 
	WHERE anon_1.penalty - anon_1.importance < anon_1.min_penalty + $9)
	 SELECT placex.place_id, placex.osm_type, placex.osm_id, placex.name, placex.class, placex.type, placex.address, placex.extratags, placex.housenumber, placex.postcode, placex.country_code, placex.wikipedia, placex.parent_place_id, placex.rank_address, placex.rank_search, placex.linked_place_id, placex.admin_level, ST_AsEWKB(placex.centroid) AS centroid, ST_AsEWKB(ST_Expand(placex.geometry, $10::INTEGER)) AS bbox, searches.importance, searches.penalty AS accuracy 
	FROM placex JOIN searches ON placex.place_id = searches.place_id 
	WHERE placex.linked_place_id IS NULL AND placex.indexed_status = $11::SMALLINT ORDER BY searches.penalty - searches.importance, accuracy 
	 LIMIT $12

Log: https://github.com/mediagis/nominatim-docker/actions/runs/11798513937/job/32865181892

To Reproduce

Import data, for example Monaco, with --reverse-only and then query for a result.

Software Environment (please complete the following information):

  • Nominatim version: 4.5.0
  • Postgresql version: 16
  • Postgis version: 3
  • OS: Ubuntu 24.04 (inside container)

Hardware Configuration (please complete the following information):

  • RAM: Github Actions, so I think 8GB
  • number of CPUs: 2, i think
  • type and size of disks: Github Actions, so no idea

Postgresql Configuration:

https://github.com/mediagis/nominatim-docker/blob/86f1d3494b29b98d7486ae70b3c79c9448cf44e0/4.5/conf.d/env#L1-L6

Nominatim Configuration:

https://github.com/mediagis/nominatim-docker/blob/86f1d3494b29b98d7486ae70b3c79c9448cf44e0/4.5/conf.d/env#L1-L6

Additional context

@leonardehrenfried
Copy link
Author

This is similar to when we discovered that warming was broken with reverse-only in 4.3.0: #3213

@mtmail
Copy link
Collaborator

mtmail commented Nov 12, 2024

Your tests on Github Actions run

          - name: REVERSE_ONLY
            commands: |-
              docker run -i --rm \
                -e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
                -e REVERSE_ONLY="true" \
                -p 8011:8080 \
                nominatim &

              ./assert-reverse-only "http://localhost:8011/search.php?q=avenue%20pasteur"
              ./assert-non-empty-json "http://localhost:8011/reverse.php?lat=43.734&lon=7.42&format=jsonv2"

In the past (Nominatim 4.4) you expected a HTTP 404 response with an error message
https://github.com/mediagis/nominatim-docker/blob/master/.github/workflows/assert-reverse-only

and now you receive a failure

 WARNING:urllib3.connectionpool:Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /search.php?q=avenue%20pasteur

@leonardehrenfried
Copy link
Author

I would say that a 503 is undesirable and a 4xx correct but maybe this doesn't need to be part of the API contract. So, I could simply not assert that there is a 404 returned.

@lonvia
Copy link
Member

lonvia commented Nov 12, 2024

That's clearly a regression that needs to be fixed. I shall do that shortly but I'm not convinced that it is important enough to warrant a patch release. Can you cope with it for the current release?

@leonardehrenfried
Copy link
Author

leonardehrenfried commented Nov 12, 2024

Now that I realised that the test just asserts that a specific error happens, I can definitely live with it for much longer. It's firmly in the nice-to-have territory.

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 a pull request may close this issue.

3 participants