astarte-platform / astarte

Core Astarte Repository
https://docs.astarte-platform.org/
Apache License 2.0
236 stars 45 forks source link

DUP: do not crash on device process initialization #930

Closed Annopaolo closed 2 months ago

Annopaolo commented 2 months ago

After the decoupling of Astarte realms and Scylla keyspaces, when the ASTARTE_INSTANCE_ID is set and a data updater process is created, it crashes because the keyspace is not found. Here is an example (test was the name of a realm, but not of a keyspace):

Apr 30 10:26:35 |WARN| Crash detected. Reason: {{:case_clause, {:error, %Xandra.Error{reason: :invalid, message: "Keyspace test does not exist"}}}, [{Astarte.DataUpdaterPlant.DataUpdater.Impl, :maybe_cache_trigger_policy, 2, [file: ~c"lib/astarte_data_updater_plant/data_updater/impl.ex", line: 2549]}, {Enum, :"-reduce/3-anonymous-1-", 3, [file: ~c"lib/enum.ex", line: 4387]}, {Enumerable.CQEx.Result, :reduce, 3, [file: ~c"lib/cqex/result.ex", line: 242]}, {Enum, :reduce, 3, [file: ~c"lib/enum.ex", line: 4387]}, {Astarte.DataUpdaterPlant.DataUpdater.Impl, :populate_triggers_for_object!, 4, [file: ~c"lib/astarte_data_updater_plant/data_updater/impl.ex", line: 2396]}, {Astarte.DataUpdaterPlant.DataUpdater.Impl, :maybe_handle_cache_miss, 4, [file: ~c"lib/astarte_data_updater_plant/data_updater/impl.ex", line: 2104]}, {Astarte.DataUpdaterPlant.DataUpdater.Impl, :"-send_control_consumer_properties/2-fun-1-", 3, [file: ~c"lib/astarte_data_updater_plant/data_updater/impl.ex", line: 2699]}, {Enum, :"-flat_map/2-fun-0-", 3, [file: ~c"lib/enum.ex", line: 1260]}]}, state: {:accepting, {[], ["test-RSOphDYQT5Ge-55o-3CE90991FBD39C-EEF8E3DE"]}, %{"test-RSOphDYQT5Ge-55o-3CE90991FBD39C-EEF8E3DE" => 43}, #PID<0.2066.0>}. |= function=handle_info/2 tag=data_upd_crash_detected astarte-astarte-data-updater-plant-1= module=Astarte.DataUpdaterPlant.MessageTracker.Server