dawarich icon indicating copy to clipboard operation
dawarich copied to clipboard

Upgrade 0.24.1 -> 0.25.3 failed: undefined method 'y' for nil

Open solderdot72 opened this issue 9 months ago • 26 comments

OS & Hardware Raspbian, Raspberry Pi 5

Version 0.25.3

Describe the bug I upgraded from 0.24.1 (which is working fine) to 0.25.3. While doing so I compared the Docker-Compose.yml files and did not find any differences. After deploying the stack the container dawarich_app took some time to start up, but finally Portainer stated it was running. I logged in, providing my credentials, and ended up in the undefined method 'y' for nil screen observed by many others. This is persistent, reloading the page does not change anything.

I entered the commands stated in the release notes for 0.25.2, rake data_cleanup:remove_duplicate_points, rake points:migrate_to_lonlat and rake users:activate, in Portainer in into the container console of dawarich_app container. That console does not provide a bash shell but allows me to enter a command which will then be executed. Unfortunately I cannot see when the command finished executing because no prompt will be displayed in that console and I did not find a clear screen output indicating that the task had finished. So I waited for half an hour after issuing a command until I disconnected from that Portainer console, and reconnected for executing the next command.

I checked Sidekiq and see that there are only the usual batch of reverse geocoding jobs in the queue. This queue encompasses about 3.000.000 geopoints, number slowly decreasing, since I use photon.komoot.io. So on the Sidekiq page I cannot see anything unusual, but maybe I am looking into the wrong places, because I also did not see anything changing there while executing the commands.

To Reproduce see above

Expected behavior In 0.25.3. I'd expect all required migration to be performed during initial startup, so the normal map page is displayed, not the page indicating an error.

solderdot72 avatar Mar 25 '25 10:03 solderdot72

Me also, almost the same scenario. I am running Docker under Debian on Proxmox.

MrDiamond10 avatar Mar 25 '25 11:03 MrDiamond10

Same here on the synology. I would suggest splitting the conversion into 10 000 point blocks so that the server has a chance to process the data

arne182 avatar Mar 25 '25 17:03 arne182

Will running the following in the console resolve your issues?

    puts 'Updating points to use lonlat...'

    ActiveRecord::Base.connection.execute('REINDEX TABLE points;')

    ActiveRecord::Base.transaction do
      ActiveRecord::Base.connection.execute('ALTER TABLE points DISABLE TRIGGER ALL;')

      # Update the data
      result = ActiveRecord::Base.connection.execute(<<~SQL)
        UPDATE points
        SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography
        WHERE lonlat IS NULL
          AND longitude IS NOT NULL
          AND latitude IS NOT NULL;
      SQL

      ActiveRecord::Base.connection.execute('ALTER TABLE points ENABLE TRIGGER ALL;')

      puts "Successfully updated #{result.cmd_tuples} points with lonlat values"
    end

    ActiveRecord::Base.connection.execute('ANALYZE points;')

Freika avatar Mar 26 '25 19:03 Freika

Also, I don't think it's necessary to create a separate issue for the problem that was already recognized in multiple other issues, and you have clearly seen it @solderdot72 https://github.com/Freika/dawarich/issues/973

Please refrain from creating duplicated issues. Thank you

Freika avatar Mar 26 '25 19:03 Freika

@Freika : Sure. Will try to do so. Reason for me creating the ticket was that I've seen plenty of people reporting issues while upgrading to 0.25.0 or 0.25.2, but none following the upgrade path to 0.25.3. But maybe I missed some. I just did the upgrade to 0.25.3 again, and this time things look different: This time Portainer shows all containers are healthy (in contrast to the 1st attempt) and Sidekiq shows a Job DataMigrations::MigratePointsLatlonJob being processed (in contrast to the 2nd attempt). The data migration job is now executing for nearly an hour. I assume this migration will take some time with some 4M geopoints on a Raspi. I will check back tomorrow on the status of the data migration and write an update here. I have no idea what went wrong in the previous 2 attempts. But this time it looks promising.

solderdot72 avatar Mar 27 '25 18:03 solderdot72

Hi, i have the same issue as i upgraded from 0.24.1 directly to 0.25.3. (Sidekiq says "idle" with 54 failed. )

@coordinates = @points.pluck(:lonlat, :battery, :altitude, :timestamp, :velocity, :id, :country) .map { |lonlat, *rest| [lonlat.y, lonlat.x, *rest.map(&:to_s)] }

As from here https://dawarich.app/docs/updating-guides#errors-on-the-map-page I got maybe 100 errors "Caused by PG::UniqueViolation: ERROR:" and removed them - I believe. If i recall the function

User.includes(:tracked_points).find_each do |user| user.tracked_points.where(lonlat: nil).update_all('lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)') end

it now says:

`[14] pry(main)> User.includes(:tracked_points).find_each do |user| [14] pry(main)> User.includes(:tracked_points).find_each do |user|etSRID(ST_MakePoint(longitude, latitude), 4326)') user.tracked_points.where(lonlat: nil).update_all('lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)') D, [2025-03-29T19:41:09.060769 #2946] DEBUG -- : User Load (0.9ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1000]]

D, [2025-03-29T19:41:12.140301 #2946] DEBUG -- : Point Load (3073.4ms) SELECT "points".* FROM "points" WHERE "points"."user_id" = $1 [["user_id", 1]]

D, [2025-03-29T19:41:14.338538 #2946] DEBUG -- : Point Update All (5.1ms) UPDATE "points" SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326) WHERE "points"."user_id" = $1 AND "points"."lonlat" IS NULL [["user_id", 1]] => nil

`

It worked for a few minutes, but after these few minutes i get the error "nil" again and i am not able to remove the error as i did before. I cant see anything running inside sidekiq

I use Owntracks and i am connected using wireshark.

Btw. is there a "faster" way to remove double entries instead of doing it manually for every timestamp. I run dawarich inside a Proxmox container with docker/portainer. Even if the "app" isnt reachable - does the dawarich still process new data points?

Image

maltejahn avatar Mar 29 '25 20:03 maltejahn

So... Next morning the DataMigrations::MigratePointsLatlonJob was no longer visible in Sidwkiq and the web frontend worked fine. The error was gone. The data migration took something between 1 hour and 7 hours - I did not check the logs to figure out the actual processing time. So if you've got a couple million geopoints in your database, expect the migration to take quite a while. The 1/2 hour I granted the job in my 2nd attempt when I entered the commands manually obviously was way too short. I have no ideat why it worked this time but in the two attempts beforehand the data migration task was not visible in Sidekiq. Maybe, for all the others out there, facing a similar problem, it might be worth attempting multiple times, before each new attempt restoring the backup. That's at least what I did...

solderdot72 avatar Mar 30 '25 10:03 solderdot72

For 8 million points it also took hours but newly added points already had the new format so the next day it worked

arne182 avatar Mar 30 '25 10:03 arne182

Hi,

so... it should work - and I did something wrong. I reverted the changes and i am back to 0.24.1 (thanks to Proxmox VM Backups)

How is the current update path from 24.1 to the latest version 0.25.3. When I read the release notes of 25.3 I would think that the "lonlat Update" is done when 25.3 is installed. So I "only" should handle the double entries "duplicate key value violates unique constraint "index_points"? Is there a way to do it for all duplicate keys or do I have to do it manualy for every key myself? And is Visit.suggested.destroy_all from 0.25.0 needed?

Btw. where do the double entries came from -> probably i had OwnTracks and Home assistant active the same time?

maltejahn avatar Mar 30 '25 12:03 maltejahn

@maltejahn For me the upgrade path was just installing 0.25.3. Then the migration task started automatially, and once that finished, the error message vanished and Dawarich worked fine. For me there was no need to enter any of the commands that described in the release notes or in the issues here.

solderdot72 avatar Mar 30 '25 16:03 solderdot72

Hi,

After nearly 24h the map is again reachable( N100 Proxmox with a vm for docker). Never thought it could take that long.

Thanks for your reply.

Malte

maltejahn avatar Mar 31 '25 18:03 maltejahn

Is this still a problem for anyone?

Freika avatar May 17 '25 16:05 Freika

Hi,

for me it worked in the end.

Malte

maltejahn avatar May 17 '25 17:05 maltejahn

I once got those issues a long time ago and was able to fix it but now i have it again after I was able to fire up a reverse geocoding job when i am going to places.

I did all 3 rake commands and they appear to have been successfully executed but the issue is still there.

I am talking about those 3 commands

To remove duplicate points, run rake data_cleanup:remove_duplicate_points
To migrate points coordinates to lonlat column, run rake points:migrate_to_lonlat
To activate your users, run rake users:activate

MrColumbo avatar May 18 '25 16:05 MrColumbo

@MrColumbo so you still have points without coordinates in your database?

Freika avatar May 18 '25 21:05 Freika

Yes - in visits - at least I am getting the error which indicates that.

MrColumbo avatar May 19 '25 02:05 MrColumbo

maybe the rake command did not complete ..i just noticed an abort message:

/var/app # rake points:migrate_to_lonlat [dotenv] Set DATABASE_PORT [dotenv] Loaded .env.development Updating points to use lonlat... D, [2025-05-19T10:27:25.206053 #11513] DEBUG -- : Point Load (117877.3ms) SELECT "points"."id", "points"."battery_status", "points"."ping", "points"."battery", "points"."tracker_id", "points"."topic", "points"."altitude", "points"."longitude", "points"."velocity", "points"."trigger", "points"."bssid", "points"."ssid", "points"."connection", "points"."vertical_accuracy", "points"."accuracy", "points"."timestamp", "points"."latitude", "points"."mode", "points"."inrids", "points"."in_regions", "points"."import_id", "points"."city", "points"."country", "points"."created_at", "points"."updated_at", "points"."user_id", "points"."geodata", "points"."visit_id", "points"."reverse_geocoded_at", "points"."course", "points"."course_accuracy", "points"."external_track_id", "points"."lonlat", "points"."country_id" FROM "points" WHERE "points"."longitude" IS NULL AND "points"."latitude" IS NULL ORDER BY "points"."id" ASC LIMIT $1 [["LIMIT", 1000]] D, [2025-05-19T10:27:25.209770 #11513] DEBUG -- : ↳ lib/tasks/points.rake:10:in 'block (2 levels) in

' rake aborted!
ActiveModel::MissingAttributeError: missing attribute 'raw_data' for Point (ActiveModel::MissingAttributeError) /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute.rb:251:in 'ActiveModel::Attribute::Uninitialized#value' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:55:in 'block in ActiveModel::LazyAttributeSet#fetch_value' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:46:in 'Hash#fetch' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:46:in 'ActiveModel::LazyAttributeSet#fetch_value' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/attribute_methods/read.rb:39:in 'ActiveRecord::AttributeMethods::Read#_read_attribute' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_methods.rb:273:in 'Point::GeneratedAttributeMethods#raw_data' /var/app/app/services/points/raw_data_lonlat_extractor.rb:21:in 'Points::RawDataLonlatExtractor#extract_lonlat' /var/app/app/services/points/raw_data_lonlat_extractor.rb:9:in 'Points::RawDataLonlatExtractor#call' /var/app/lib/tasks/points.rake:11:in 'block (3 levels) in
' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:88:in 'Array#each' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:88:in 'block in ActiveRecord::Batches#find_each' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:172:in 'block in ActiveRecord::Batches#find_in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:461:in 'block in ActiveRecord::Batches#batch_on_unloaded_relation' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:434:in 'ActiveRecord::Batches#batch_on_unloaded_relation' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:289:in 'ActiveRecord::Batches#in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:171:in 'ActiveRecord::Batches#find_in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:87:in 'ActiveRecord::Batches#find_each' /var/app/lib/tasks/points.rake:10:in 'block (2 levels) in
' Tasks: TOP => points:migrate_to_lonlat (See full trace by running task with --trace) /var/app #

MrColumbo avatar May 19 '25 10:05 MrColumbo

i just did ran the command with --trace ....but does not look like that it provides more valuable information

/var/app # rake points:migrate_to_lonlat --trace ** Invoke points:migrate_to_lonlat (first_time) ** Invoke environment (first_time) ** Execute environment [dotenv] Set DATABASE_PORT [dotenv] Loaded .env.development ** Execute points:migrate_to_lonlat Updating points to use lonlat... D, [2025-05-19T10:30:42.209515 #11973] DEBUG -- : Point Load (3549.7ms) SELECT "points"."id", "points"."battery_status", "points"."ping", "points"."battery", "points"."tracker_id", "points"."topic", "points"."altitude", "points"."longitude", "points"."velocity", "points"."trigger", "points"."bssid", "points"."ssid", "points"."connection", "points"."vertical_accuracy", "points"."accuracy", "points"."timestamp", "points"."latitude", "points"."mode", "points"."inrids", "points"."in_regions", "points"."import_id", "points"."city", "points"."country", "points"."created_at", "points"."updated_at", "points"."user_id", "points"."geodata", "points"."visit_id", "points"."reverse_geocoded_at", "points"."course", "points"."course_accuracy", "points"."external_track_id", "points"."lonlat", "points"."country_id" FROM "points" WHERE "points"."longitude" IS NULL AND "points"."latitude" IS NULL ORDER BY "points"."id" ASC LIMIT $1 [["LIMIT", 1000]] D, [2025-05-19T10:30:42.215677 #11973] DEBUG -- : ↳ lib/tasks/points.rake:10:in 'block (2 levels) in

' rake aborted! ActiveModel::MissingAttributeError: missing attribute 'raw_data' for Point (ActiveModel::MissingAttributeError) /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute.rb:251:in 'ActiveModel::Attribute::Uninitialized#value' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:55:in 'block in ActiveModel::LazyAttributeSet#fetch_value' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:46:in 'Hash#fetch' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_set/builder.rb:46:in 'ActiveModel::LazyAttributeSet#fetch_value' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/attribute_methods/read.rb:39:in 'ActiveRecord::AttributeMethods::Read#_read_attribute' /var/app/vendor/bundle/ruby/3.4.0/gems/activemodel-8.0.2/lib/active_model/attribute_methods.rb:273:in 'Point::GeneratedAttributeMethods#raw_data' /var/app/app/services/points/raw_data_lonlat_extractor.rb:21:in 'Points::RawDataLonlatExtractor#extract_lonlat' /var/app/app/services/points/raw_data_lonlat_extractor.rb:9:in 'Points::RawDataLonlatExtractor#call' /var/app/lib/tasks/points.rake:11:in 'block (3 levels) in
' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:88:in 'Array#each' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:88:in 'block in ActiveRecord::Batches#find_each' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:172:in 'block in ActiveRecord::Batches#find_in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:461:in 'block in ActiveRecord::Batches#batch_on_unloaded_relation' internal:kernel:168:in 'Kernel#loop' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:434:in 'ActiveRecord::Batches#batch_on_unloaded_relation' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:289:in 'ActiveRecord::Batches#in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:171:in 'ActiveRecord::Batches#find_in_batches' /var/app/vendor/bundle/ruby/3.4.0/gems/activerecord-8.0.2/lib/active_record/relation/batches.rb:87:in 'ActiveRecord::Batches#find_each' /var/app/lib/tasks/points.rake:10:in 'block (2 levels) in
' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:281:in 'block in Rake::Task#execute' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:281:in 'Array#each' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:281:in 'Rake::Task#execute' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:219:in 'block in Rake::Task#invoke_with_call_chain' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:199:in 'Monitor#synchronize' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:199:in 'Rake::Task#invoke_with_call_chain' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/task.rb:188:in 'Rake::Task#invoke' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:188:in 'Rake::Application#invoke_task' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:138:in 'block (2 levels) in Rake::Application#top_level' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:138:in 'Array#each' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:138:in 'block in Rake::Application#top_level' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:147:in 'Rake::Application#run_with_threads' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:132:in 'Rake::Application#top_level' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:83:in 'block in Rake::Application#run' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:214:in 'Rake::Application#standard_exception_handling' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/lib/rake/application.rb:80:in 'Rake::Application#run' /usr/local/lib/ruby/gems/3.4.0/gems/rake-13.2.1/exe/rake:27:in '<top (required)>' /usr/local/bin/rake:25:in 'Kernel#load' /usr/local/bin/rake:25:in '
' Tasks: TOP => points:migrate_to_lonlat

MrColumbo avatar May 19 '25 10:05 MrColumbo

i did an upgrade to the latest version and this time rake ran for a couple of hours but now it feels like I am in a loop. Below is the output from 2 runs. Maybe I am missing something but I assumed that this command will take care of all points which needs to get upgraded and there is no need to run it multiple times, right?

thanks :)

rake points:migrate_to_lonlat --trace

** Invoke points:migrate_to_lonlat (first_time) ** Invoke environment (first_time) ** Execute environment [dotenv] Set DATABASE_PORT [dotenv] Loaded .env.development ** Execute points:migrate_to_lonlat Updating points to use lonlat... D, [2025-05-21T10:07:42.173382 #75416] DEBUG -- : Point Load (8.4ms) SELECT "points".* FROM "points" WHERE "points"."longitude" IS NULL AND "points"."latitude" IS NULL ORDER BY "points"."id" ASC LIMIT $1 [["LIMIT", 1000]] D, [2025-05-21T10:07:42.174072 #75416] DEBUG -- : ↳ lib/tasks/points.rake:10:in 'block (2 levels) in

' D, [2025-05-21T10:07:42.232780 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.236027 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.549649 #75416] DEBUG -- : Point Update (234.3ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.312128"], ["id", 2092639]] D, [2025-05-21T10:07:42.550269 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.578179 #75416] DEBUG -- : TRANSACTION (12.9ms) COMMIT D, [2025-05-21T10:07:42.578488 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.582397 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.582955 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.634749 #75416] DEBUG -- : Point Update (52.6ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.580373"], ["id", 2092640]] D, [2025-05-21T10:07:42.635187 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.653355 #75416] DEBUG -- : TRANSACTION (17.8ms) COMMIT D, [2025-05-21T10:07:42.653743 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.660848 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.661620 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.674322 #75416] DEBUG -- : Point Update (13.6ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.658110"], ["id", 2092641]] D, [2025-05-21T10:07:42.674795 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.686531 #75416] DEBUG -- : TRANSACTION (11.5ms) COMMIT D, [2025-05-21T10:07:42.686837 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.688277 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.688829 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.689911 #75416] DEBUG -- : Point Update (1.8ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.687427"], ["id", 2092642]] D, [2025-05-21T10:07:42.690428 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.694912 #75416] DEBUG -- : TRANSACTION (3.3ms) COMMIT D, [2025-05-21T10:07:42.695394 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.696784 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:07:42.697315 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.707038 #75416] DEBUG -- : Point Update (10.3ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.696052"], ["id", 2092643]] D, [2025-05-21T10:07:42.707594 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.720538 #75416] DEBUG -- : TRANSACTION (12.3ms) COMMIT D, [2025-05-21T10:07:42.720906 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.724146 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.725276 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.726289 #75416] DEBUG -- : Point Update (2.4ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.722301"], ["id", 2092644]] D, [2025-05-21T10:07:42.726842 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.737022 #75416] DEBUG -- : TRANSACTION (9.5ms) COMMIT D, [2025-05-21T10:07:42.737350 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.746380 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:07:42.747235 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.748727 #75416] DEBUG -- : Point Update (5.2ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.738121"], ["id", 2092645]] D, [2025-05-21T10:07:42.749195 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.753812 #75416] DEBUG -- : TRANSACTION (4.4ms) COMMIT D, [2025-05-21T10:07:42.754072 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.767451 #75416] DEBUG -- : TRANSACTION (2.7ms) BEGIN D, [2025-05-21T10:07:42.767997 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.772003 #75416] DEBUG -- : Point Update (8.3ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.760445"], ["id", 2092646]] D, [2025-05-21T10:07:42.772475 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.787283 #75416] DEBUG -- : TRANSACTION (11.3ms) COMMIT D, [2025-05-21T10:07:42.787590 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.792448 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:07:42.793002 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.794069 #75416] DEBUG -- : Point Update (1.7ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.791920"], ["id", 2092647]] D, [2025-05-21T10:07:42.794546 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.804098 #75416] DEBUG -- : TRANSACTION (9.1ms) COMMIT D, [2025-05-21T10:07:42.804461 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.806516 #75416] DEBUG -- : TRANSACTION (0.4ms) BEGIN D, [2025-05-21T10:07:42.807219 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.808527 #75416] DEBUG -- : Point Update (2.4ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.805111"], ["id", 2092648]] D, [2025-05-21T10:07:42.809578 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.822192 #75416] DEBUG -- : TRANSACTION (11.9ms) COMMIT D, [2025-05-21T10:07:42.823225 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.836114 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.836930 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.837684 #75416] DEBUG -- : Point Update (1.7ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.825463"], ["id", 2092649]] D, [2025-05-21T10:07:42.838141 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.846378 #75416] DEBUG -- : TRANSACTION (6.9ms) COMMIT D, [2025-05-21T10:07:42.846634 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.849213 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:07:42.849752 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.880232 #75416] DEBUG -- : Point Update (31.1ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.848732"], ["id", 2092650]] D, [2025-05-21T10:07:42.881124 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.888262 #75416] DEBUG -- : TRANSACTION (6.8ms) COMMIT D, [2025-05-21T10:07:42.888567 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.889672 #75416] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:07:42.890512 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.897198 #75416] DEBUG -- : Point Update (7.6ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.889147"], ["id", 2092651]] D, [2025-05-21T10:07:42.897593 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.905034 #75416] DEBUG -- : TRANSACTION (7.3ms) COMMIT D, [2025-05-21T10:07:42.905279 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.906191 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:07:42.906875 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.907495 #75416] DEBUG -- : Point Update (1.4ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:07:42.905669"], ["id", 2092652]] D, [2025-05-21T10:07:42.907911 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:07:42.913360 #75416] DEBUG -- : TRANSACTION (5.3ms) COMMIT D, [2025-05-21T10:07:42.913794 #75416] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:09:20.868032 #75416] DEBUG -- : (97953.7ms) REINDEX TABLE points; D, [2025-05-21T10:09:20.868383 #75416] DEBUG -- : ↳ lib/tasks/points.rake:14:in 'block (2 levels) in
' D, [2025-05-21T10:09:20.870028 #75416] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:09:20.870532 #75416] DEBUG -- : ↳ lib/tasks/points.rake:17:in 'block (3 levels) in
' D, [2025-05-21T10:09:21.059752 #75416] DEBUG -- : (189.7ms) ALTER TABLE points DISABLE TRIGGER ALL; D, [2025-05-21T10:09:21.060179 #75416] DEBUG -- : ↳ lib/tasks/points.rake:17:in 'block (3 levels) in
' D, [2025-05-21T10:09:21.191920 #75416] DEBUG -- : (131.2ms) UPDATE points SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography WHERE lonlat IS NULL AND longitude IS NOT NULL AND latitude IS NOT NULL;

D, [2025-05-21T10:09:21.192594 #75416] DEBUG -- : ↳ lib/tasks/points.rake:20:in 'block (3 levels) in

' D, [2025-05-21T10:09:21.193275 #75416] DEBUG -- : (0.3ms) ALTER TABLE points ENABLE TRIGGER ALL; D, [2025-05-21T10:09:21.193523 #75416] DEBUG -- : ↳ lib/tasks/points.rake:28:in 'block (3 levels) in
' Successfully updated 0 points with lonlat values D, [2025-05-21T10:09:21.420592 #75416] DEBUG -- : TRANSACTION (226.7ms) COMMIT D, [2025-05-21T10:09:21.421022 #75416] DEBUG -- : ↳ lib/tasks/points.rake:16:in 'block (2 levels) in
' D, [2025-05-21T10:09:24.713962 #75416] DEBUG -- : (3292.6ms) ANALYZE points; D, [2025-05-21T10:09:24.714287 #75416] DEBUG -- : ↳ lib/tasks/points.rake:33:in 'block (2 levels) in
'

rake points:migrate_to_lonlat --trace

** Invoke points:migrate_to_lonlat (first_time) ** Invoke environment (first_time) ** Execute environment [dotenv] Set DATABASE_PORT [dotenv] Loaded .env.development ** Execute points:migrate_to_lonlat Updating points to use lonlat... D, [2025-05-21T10:11:23.546270 #75737] DEBUG -- : Point Load (10.2ms) SELECT "points".* FROM "points" WHERE "points"."longitude" IS NULL AND "points"."latitude" IS NULL ORDER BY "points"."id" ASC LIMIT $1 [["LIMIT", 1000]] D, [2025-05-21T10:11:23.546855 #75737] DEBUG -- : ↳ lib/tasks/points.rake:10:in 'block (2 levels) in

' D, [2025-05-21T10:11:23.572574 #75737] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:11:23.575311 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:23.729800 #75737] DEBUG -- : Point Update (97.0ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:11:23.629333"], ["id", 2092653]] D, [2025-05-21T10:11:23.730414 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:23.764652 #75737] DEBUG -- : TRANSACTION (29.1ms) COMMIT D, [2025-05-21T10:11:23.764981 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:23.769013 #75737] DEBUG -- : TRANSACTION (0.1ms) BEGIN D, [2025-05-21T10:11:23.769733 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:24.071753 #75737] DEBUG -- : Point Update (302.9ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:11:23.766962"], ["id", 2092654]] D, [2025-05-21T10:11:24.072313 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:24.123656 #75737] DEBUG -- : TRANSACTION (51.0ms) COMMIT D, [2025-05-21T10:11:24.124145 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:24.131747 #75737] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:11:24.132358 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:24.133136 #75737] DEBUG -- : Point Update (1.5ms) UPDATE "points" SET "longitude" = $1, "latitude" = $2, "updated_at" = $3 WHERE "points"."id" = $4 [["longitude", "[FILTERED]"], ["latitude", "[FILTERED]"], ["updated_at", "2025-05-21 10:11:24.128831"], ["id", 2092655]] D, [2025-05-21T10:11:24.133776 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:11:24.254045 #75737] DEBUG -- : TRANSACTION (120.0ms) COMMIT D, [2025-05-21T10:11:24.254526 #75737] DEBUG -- : ↳ app/services/points/raw_data_lonlat_extractor.rb:11:in 'Points::RawDataLonlatExtractor#call' D, [2025-05-21T10:14:56.724144 #75737] DEBUG -- : (212469.3ms) REINDEX TABLE points; D, [2025-05-21T10:14:56.724433 #75737] DEBUG -- : ↳ lib/tasks/points.rake:14:in 'block (2 levels) in
' D, [2025-05-21T10:14:56.724785 #75737] DEBUG -- : TRANSACTION (0.2ms) BEGIN D, [2025-05-21T10:14:56.725204 #75737] DEBUG -- : ↳ lib/tasks/points.rake:17:in 'block (3 levels) in
' D, [2025-05-21T10:14:59.312528 #75737] DEBUG -- : (2587.9ms) ALTER TABLE points DISABLE TRIGGER ALL; D, [2025-05-21T10:14:59.313381 #75737] DEBUG -- : ↳ lib/tasks/points.rake:17:in 'block (3 levels) in
' D, [2025-05-21T10:15:03.862120 #75737] DEBUG -- : (4548.5ms) UPDATE points SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography WHERE lonlat IS NULL AND longitude IS NOT NULL AND latitude IS NOT NULL;

D, [2025-05-21T10:15:03.862355 #75737] DEBUG -- : ↳ lib/tasks/points.rake:20:in 'block (3 levels) in

' D, [2025-05-21T10:15:03.862886 #75737] DEBUG -- : (0.4ms) ALTER TABLE points ENABLE TRIGGER ALL; D, [2025-05-21T10:15:03.863063 #75737] DEBUG -- : ↳ lib/tasks/points.rake:28:in 'block (3 levels) in
' Successfully updated 0 points with lonlat values D, [2025-05-21T10:15:05.230629 #75737] DEBUG -- : TRANSACTION (1367.3ms) COMMIT D, [2025-05-21T10:15:05.230885 #75737] DEBUG -- : ↳ lib/tasks/points.rake:16:in 'block (2 levels) in
' D, [2025-05-21T10:15:06.779564 #75737] DEBUG -- : (1548.4ms) ANALYZE points; D, [2025-05-21T10:15:06.780059 #75737] DEBUG -- : ↳ lib/tasks/points.rake:33:in 'block (2 levels) in
'

MrColumbo avatar May 21 '25 10:05 MrColumbo

the funny thing is that there are also indicators that they are no more of such points. Please have a look here:

bin/rails console [dotenv] Set DATABASE_PORT [dotenv] Loaded .env.development Loading development environment (Rails 8.0.2) [1] pry(main)> user = User.find_by(email: '[email protected]') D, [2025-05-24T06:48:50.307691 #87567] DEBUG -- : User Load (60.0ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "[email protected]"], ["LIMIT", 1]] => #<User id: 1, email: "[email protected]", created_at: "2024-07-06 17:50:47.546768000 +0200", updated_at: "2025-05-23 08:02:33.952932000 +0200", api_key: [FILTERED], theme: "light", settings: {"maps" => {"url" => "", "name" => "", "distance_unit" => "km"}, "immich_url" => "http://192.168.178.186:2283/", "immich_api_key" => "#################", "photoprism_url" => "", "photoprism_api_key" => ""}, admin: true, status: "active", active_until: "3025-04-09 11:03:34.716798000 +0100"> [2] pry(main)> user.tracked_points.where(latitude: nil, longitude: nil).size D, [2025-05-24T06:49:09.514570 #87567] DEBUG -- : Point Count (46.4ms) SELECT COUNT() FROM "points" WHERE "points"."user_id" = $1 AND "points"."latitude" IS NULL AND "points"."longitude" IS NULL [["user_id", 1]] => 0 [3] pry(main)> user.tracked_points.where.not(latitude: nil, longitude: nil).where(lonlat: nil).size D, [2025-05-24T06:54:16.804992 #87567] DEBUG -- : Point Count (285108.9ms) SELECT COUNT() FROM "points" WHERE "points"."user_id" = $1 AND NOT ("points"."latitude" IS NULL AND "points"."longitude" IS NULL) AND "points"."lonlat" IS NULL [["user_id", 1]] => 0

Do I miss something?

thanks and kind regards :)

MrColumbo avatar May 24 '25 07:05 MrColumbo

I just thought i should mention that i am only getting the error when i go to visited places. I can look at the map without any issues and I am also able to go to points without any error message.

MrColumbo avatar May 24 '25 07:05 MrColumbo

Check also user.tracked_points.where(lonlat: nil).size

Just in case, can you provide exact error you're experiencing with its surroundings and logs? Thanks

Freika avatar May 24 '25 19:05 Freika

[3] pry(main)> user.tracked_points.where(lonlat: nil).size D, [2025-05-25T14:29:53.869908 #247975] DEBUG -- : Point Count (181015.3ms) SELECT COUNT(*) FROM "points" WHERE "points"."user_id" = $1 AND "points"."lonlat" IS NULL [["user_id", 1]] => 0

MrColumbo avatar May 25 '25 14:05 MrColumbo

Image

these are the last logs from sidekiq

D, [2025-05-25T14:22:01.293308 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.294082 #23] DEBUG -- : (0.7ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.412688 49.4657379)"], [nil, "POINT (8.4126863 49.4657323)"]] D, [2025-05-25T14:22:01.294278 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.294619 #23] DEBUG -- : (0.2ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126863 49.4657323)"], [nil, "POINT (8.412701 49.4657398)"]] D, [2025-05-25T14:22:01.294795 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.295008 #23] DEBUG -- : (0.1ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.412701 49.4657398)"], [nil, "POINT (8.4126903 49.4657394)"]] D, [2025-05-25T14:22:01.295199 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.295391 #23] DEBUG -- : (0.1ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126903 49.4657394)"], [nil, "POINT (8.4126744 49.4657297)"]] D, [2025-05-25T14:22:01.295565 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.295796 #23] DEBUG -- : (0.1ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126744 49.4657297)"], [nil, "POINT (8.4126861 49.465738)"]] D, [2025-05-25T14:22:01.295970 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.296255 #23] DEBUG -- : (0.2ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126861 49.465738)"], [nil, "POINT (8.4126787 49.4657346)"]] D, [2025-05-25T14:22:01.296433 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.296630 #23] DEBUG -- : (0.1ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126787 49.4657346)"], [nil, "POINT (8.4126784 49.4657294)"]] D, [2025-05-25T14:22:01.296805 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.297060 #23] DEBUG -- : (0.2ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126784 49.4657294)"], [nil, "POINT (8.4126868 49.465732)"]] D, [2025-05-25T14:22:01.297243 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:22:01.297434 #23] DEBUG -- : (0.1ms) SELECT ST_Distance(ST_GeomFromEWKT($1)::geography, ST_GeomFromEWKT($2)::geography) [[nil, "POINT (8.4126868 49.465732)"], [nil, "POINT (8.4126736 49.4657309)"]] D, [2025-05-25T14:22:01.297608 #23] DEBUG -- : ↳ app/models/concerns/distanceable.rb:54:in 'block in Distanceable::ClassMethods#calculate_distance_for_array' D, [2025-05-25T14:24:26.431484 #23] DEBUG -- : Point Load (145006.5ms) SELECT "points"."id", "points"."battery_status", "points"."ping", "points"."battery", "points"."tracker_id", "points"."topic", "points"."altitude", "points"."longitude", "points"."velocity", "points"."trigger", "points"."bssid", "points"."ssid", "points"."connection", "points"."vertical_accuracy", "points"."accuracy", "points"."timestamp", "points"."latitude", "points"."mode", "points"."inrids", "points"."in_regions", "points"."import_id", "points"."city", "points"."country", "points"."created_at", "points"."updated_at", "points"."user_id", "points"."geodata", "points"."visit_id", "points"."reverse_geocoded_at", "points"."course", "points"."course_accuracy", "points"."external_track_id", "points"."lonlat", "points"."country_id", "points"."lonlat", "points"."timestamp", "points"."city", "points"."country" FROM "points" WHERE "points"."user_id" = $1 AND "points"."timestamp" BETWEEN $2 AND $3 ORDER BY "points"."timestamp" ASC [["user_id", 1], ["timestamp", 1746057600], ["timestamp", 1748649600]] D, [2025-05-25T14:24:26.431848 #23] DEBUG -- : ↳ app/services/countries_and_cities.rb:13:in 'Enumerable#reject' D, [2025-05-25T14:24:31.727824 #23] DEBUG -- : Stat Update (3567.0ms) UPDATE "stats" SET "distance" = $1, "toponyms" = $2, "updated_at" = $3, "daily_distance" = $4 WHERE "stats"."id" = $5 [["distance", 1877], ["toponyms", "[{"country":"Portugal","cities":[{"city":"Porto","points":6736,"timestamp":1746189896,"stayed_for":2204},{"city":"Vila Nova de Gaia","points":406,"timestamp":1746191694,"stayed_for":1672},{"city":"Matosinhos","points":57,"timestamp":1746122862,"stayed_for":115},{"city":"Aveiro","points":2221,"timestamp":1746203207,"stayed_for":168},{"city":"Alcobaça","points":1497,"timestamp":1746349515,"stayed_for":2351},{"city":"Nazaré","points":9395,"timestamp":1746349312,"stayed_for":2344},{"city":"Valado dos Frades","points":175,"timestamp":1746349022,"stayed_for":2334},{"city":"Caldas da Rainha","points":835,"timestamp":1746349819,"stayed_for":1380},{"city":"Óbidos","points":1517,"timestamp":1746350093,"stayed_for":1379},{"city":"Rebolo","points":16,"timestamp":1746349276,"stayed_for":1197},{"city":"Cela-Velha","points":15,"timestamp":1746349169,"stayed_for":1193},{"city":"Sintra","points":4012,"timestamp":1746467115,"stayed_for":1913},{"city":"Oeiras","points":2592,"timestamp":1746524805,"stayed_for":2870},{"city":"Cascais",

....

D, [2025-05-25T14:24:31.728289 #23] DEBUG -- : ↳ app/services/stats/calculate_month.rb:42:in 'block in Stats::CalculateMonth#update_month_stats' D, [2025-05-25T14:24:31.855803 #23] DEBUG -- : TRANSACTION (127.2ms) COMMIT D, [2025-05-25T14:24:31.856296 #23] DEBUG -- : ↳ app/services/stats/calculate_month.rb:33:in 'Stats::CalculateMonth#update_month_stats' I, [2025-05-25T14:24:31.856369 #23] INFO -- : Performed Stats::CalculatingJob (Job ID: e324d9f2-61c7-4036-ab59-ecfa5fbf3cf5) from Sidekiq(stats) in 1434847.43ms I, [2025-05-25T14:24:31.856878 #23] INFO -- : done D, [2025-05-25T14:24:37.653708 #23] DEBUG -- : Flushed 2 metrics

MrColumbo avatar May 25 '25 14:05 MrColumbo

I just go to the main page ...see the map ...all fine and then go to visited place and i get the error

MrColumbo avatar May 25 '25 14:05 MrColumbo

here are the last lines from the log from the app

D, [2025-05-25T14:42:32.505528 #117] DEBUG -- : User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."api_key" IS NULL LIMIT $1 [["LIMIT", 1]] D, [2025-05-25T14:42:32.505925 #117] DEBUG -- : ↳ app/controllers/api_controller.rb:22:in 'ApiController#current_api_user' I, [2025-05-25T14:42:32.506105 #117] INFO -- : {"method":"GET","path":"/api/v1/health","format":"/","controller":"Api::V1::HealthController","action":"index","status":200,"allocations":903,"duration":1.94,"view":0.04,"db":0.23} D, [2025-05-25T14:42:42.559383 #117] DEBUG -- : User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."api_key" IS NULL LIMIT $1 [["LIMIT", 1]] D, [2025-05-25T14:42:42.559672 #117] DEBUG -- : ↳ app/controllers/api_controller.rb:22:in 'ApiController#current_api_user' I, [2025-05-25T14:42:42.559805 #117] INFO -- : {"method":"GET","path":"/api/v1/health","format":"/","controller":"Api::V1::HealthController","action":"index","status":200,"allocations":903,"duration":1.15,"view":0.03,"db":0.14} D, [2025-05-25T14:42:52.632575 #117] DEBUG -- : User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."api_key" IS NULL LIMIT $1 [["LIMIT", 1]] D, [2025-05-25T14:42:52.632881 #117] DEBUG -- : ↳ app/controllers/api_controller.rb:22:in 'ApiController#current_api_user' I, [2025-05-25T14:42:52.633028 #117] INFO -- : {"method":"GET","path":"/api/v1/health","format":"/","controller":"Api::V1::HealthController","action":"index","status":200,"allocations":903,"duration":1.24,"view":0.03,"db":0.2} D, [2025-05-25T14:43:02.681298 #117] DEBUG -- : User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."api_key" IS NULL LIMIT $1 [["LIMIT", 1]] D, [2025-05-25T14:43:02.681588 #117] DEBUG -- : ↳ app/controllers/api_controller.rb:22:in 'ApiController#current_api_user' I, [2025-05-25T14:43:02.681725 #117] INFO -- : {"method":"GET","path":"/api/v1/health","format":"/","controller":"Api::V1::HealthController","action":"index","status":200,"allocations":903,"duration":1.14,"view":0.03,"db":0.17}

and here are the last log lines from the db

2025-05-25 13:20:32.291 UTC [26] LOG: checkpoint starting: time 2025-05-25 13:20:44.003 UTC [26] LOG: checkpoint complete: wrote 42 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=6.394 s, sync=1.976 s, total=11.713 s; sync files=23, longest=0.421 s, average=0.086 s; distance=229 kB, estimate=2482 kB; lsn=F/E87DAD50, redo lsn=F/E87DACC0 2025-05-25 13:25:32.099 UTC [26] LOG: checkpoint starting: time 2025-05-25 13:25:58.739 UTC [26] LOG: checkpoint complete: wrote 57 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=8.959 s, sync=10.012 s, total=26.641 s; sync files=24, longest=1.457 s, average=0.418 s; distance=344 kB, estimate=2268 kB; lsn=F/E88504D8, redo lsn=F/E8831038 2025-05-25 13:30:34.754 UTC [26] LOG: checkpoint starting: time 2025-05-25 13:31:07.690 UTC [26] LOG: checkpoint complete: wrote 40 buffers (0.2%); 0 WAL file(s) added, 0 removed, 0 recycled; write=8.706 s, sync=12.204 s, total=33.890 s; sync files=24, longest=1.665 s, average=0.509 s; distance=254 kB, estimate=2067 kB; lsn=F/E8876098, redo lsn=F/E8870878 2025-05-25 13:50:00.930 UTC [47385] ERROR: duplicate key value violates unique constraint "index_points_on_lonlat_timestamp_user_id" 2025-05-25 13:50:00.930 UTC [47385] DETAIL: Key (lonlat, "timestamp", user_id)=(0101000020E61000002BB8C4364ED3204080D591239DBB4840, 1748180590, 1) already exists. 2025-05-25 13:50:00.930 UTC [47385] STATEMENT: INSERT INTO "points" ("battery_status", "ping", "battery", "tracker_id", "topic", "altitude", "longitude", "velocity", "trigger", "bssid", "ssid", "connection", "vertical_accuracy", "accuracy", "timestamp", "latitude", "mode", "inrids", "in_regions", "raw_data", "import_id", "city", "country", "created_at", "updated_at", "user_id", "geodata", "visit_id", "reverse_geocoded_at", "course", "course_accuracy", "external_track_id", "lonlat", "country_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34) RETURNING "id" 2025-05-25 13:50:33.089 UTC [26] LOG: checkpoint starting: time 2025-05-25 13:51:53.960 UTC [26] LOG: checkpoint complete: wrote 57 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=19.874 s, sync=31.478 s, total=80.872 s; sync files=33, longest=2.933 s, average=0.954 s; distance=277 kB, estimate=1888 kB; lsn=F/E88B7C40, redo lsn=F/E88B5FF0 2025-05-25 13:55:34.060 UTC [26] LOG: checkpoint starting: time 2025-05-25 13:56:05.221 UTC [26] LOG: checkpoint complete: wrote 46 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=6.166 s, sync=13.961 s, total=31.162 s; sync files=24, longest=2.167 s, average=0.582 s; distance=262 kB, estimate=1725 kB; lsn=F/E8919060, redo lsn=F/E88F7A60 2025-05-25 14:00:34.321 UTC [26] LOG: checkpoint starting: time 2025-05-25 14:00:51.425 UTC [26] LOG: checkpoint complete: wrote 56 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=7.349 s, sync=4.763 s, total=17.105 s; sync files=25, longest=0.715 s, average=0.191 s; distance=298 kB, estimate=1583 kB; lsn=F/E896A530, redo lsn=F/E8942268 2025-05-25 14:05:34.525 UTC [26] LOG: checkpoint starting: time 2025-05-25 14:05:50.465 UTC [26] LOG: checkpoint complete: wrote 54 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=6.363 s, sync=4.026 s, total=15.940 s; sync files=24, longest=1.471 s, average=0.168 s; distance=352 kB, estimate=1460 kB; lsn=F/E899A4F8, redo lsn=F/E899A468 2025-05-25 14:10:42.372 UTC [47449] ERROR: duplicate key value violates unique constraint "index_points_on_lonlat_timestamp_user_id" 2025-05-25 14:10:42.372 UTC [47449] DETAIL: Key (lonlat, "timestamp", user_id)=(0101000020E6100000FE5F75E448D32040E5B4A7E49CBB4840, 1748182193, 1) already exists. 2025-05-25 14:10:42.372 UTC [47449] STATEMENT: INSERT INTO "points" ("battery_status", "ping", "battery", "tracker_id", "topic", "altitude", "longitude", "velocity", "trigger", "bssid", "ssid", "connection", "vertical_accuracy", "accuracy", "timestamp", "latitude", "mode", "inrids", "in_regions", "raw_data", "import_id", "city", "country", "created_at", "updated_at", "user_id", "geodata", "visit_id", "reverse_geocoded_at", "course", "course_accuracy", "external_track_id", "lonlat", "country_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $2~ # 28, $29, $30, $31, $32, $33, $34) RETURNING "id"

MrColumbo avatar May 25 '25 14:05 MrColumbo

i just noticed that if i open declined or suggested it works well. Only the confirmed section throws the error. By the way .....i am pretty confident that i have a very low number of confirmed entries there ......

MrColumbo avatar May 28 '25 11:05 MrColumbo

i added a pgadmin container to easily get some visbility .....there are 74 entries in the visited table. 60 with status 0 - i guess those are the unconfirmed ones. I am wondering what happens when i just delete those entries? I guess i can get them again when i run another job since at the end the visits are just made from the raw data which i am not touching, right?

MrColumbo avatar May 31 '25 16:05 MrColumbo

this command shows 512 rows => SELECT * FROM public.places where lonlat isnull Could this be my issue?

MrColumbo avatar May 31 '25 16:05 MrColumbo

there is only one line with lonlat=NULL when i do this: SELECT * FROM public.visits, public.places where public.visits.place_id = public.places.id order by lonlat desc

MrColumbo avatar May 31 '25 17:05 MrColumbo