Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] - Deleting MqttViewer.db causes problems #12

@adamwoodland2

Description

@adamwoodland2

Operating System

Windows 10 22H2 VM

Description

So I was working out how to reset my settigns to blank/default and found in \AppData\Local\MqttViewer the MqttViewer.db file. So I closed the app and deleted the db file to see what happens.

When I go to run the MQTT Viewer exe file the MqttViewer.db file is recreated along with a MqttViewer.db-journal, but the exe doesn't keep running (confirmed with Task Manager). I run the exe again and the .db-journal file is deleted, but the application interface doesn't appear and nothing running in Task manager.

Usually running the exe a third time nothing happens. Rinse and repeat a few more times. If the app doesn't jump into life I delete the .db again and try again and eventually I get an app screen to appear and it looks set back to default.

Log of it never working after I deleted the db file (I cut it short to save on spam but it just repeats the same lines)

time=2025-03-25T16:11:16.319+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:11:16.320+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:11:16.320+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:11:16.320+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:11:16.320+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:11:16.332+10:00 level=ERROR msg="D:/a/mqtt-viewer/mqtt-viewer/backend/db/migrate.go:45 SQL logic error: table `publish_histories` already exists (1)\n[0.000ms] [rows:0] -- Create \"publish_histories\" table\r\nCREATE TABLE `publish_histories` (\r\n  `id` integer NULL PRIMARY KEY AUTOINCREMENT,\r\n  `connection_id` integer NULL,\r\n  `topic` text NULL,\r\n  `qo_s` integer NULL,\r\n  `retain` numeric NULL,\r\n  `payload` text NULL,\r\n  `encoding` text NULL,\r\n  `format` text NULL,\r\n  `user_properties` text NULL,\r\n  `header_content_type` text NULL,\r\n  `header_response_topic` text NULL,\r\n  `header_correlation_data` text NULL,\r\n  `header_payload_format_indicator` numeric NULL,\r\n  `header_message_expiry_interval` integer NULL,\r\n  `header_topic_alias` integer NULL,\r\n  `header_subscription_identifier` integer NULL,\r\n  `published_at` datetime NULL,\r\n  CONSTRAINT `fk_connections_publish_histories` FOREIGN KEY (`connection_id`) REFERENCES `connections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION\r\n);\r\n-- Create index \"publish_history_connid\" to table: \"publish_histories\"\r\nCREATE INDEX `publish_history_connid` ON `publish_histories` (`connection_id`);\r\n" module=db-internal
time=2025-03-25T16:11:16.333+10:00 level=ERROR msg="SQL logic error: table `publish_histories` already exists (1)"
time=2025-03-25T16:12:46.612+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:12:46.614+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:12:46.614+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:12:46.614+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:12:46.614+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:12:46.616+10:00 level=ERROR msg="D:/a/mqtt-viewer/mqtt-viewer/backend/db/migrate.go:45 SQL logic error: table `publish_histories` already exists (1)\n[0.000ms] [rows:0] -- Create \"publish_histories\" table\r\nCREATE TABLE `publish_histories` (\r\n  `id` integer NULL PRIMARY KEY AUTOINCREMENT,\r\n  `connection_id` integer NULL,\r\n  `topic` text NULL,\r\n  `qo_s` integer NULL,\r\n  `retain` numeric NULL,\r\n  `payload` text NULL,\r\n  `encoding` text NULL,\r\n  `format` text NULL,\r\n  `user_properties` text NULL,\r\n  `header_content_type` text NULL,\r\n  `header_response_topic` text NULL,\r\n  `header_correlation_data` text NULL,\r\n  `header_payload_format_indicator` numeric NULL,\r\n  `header_message_expiry_interval` integer NULL,\r\n  `header_topic_alias` integer NULL,\r\n  `header_subscription_identifier` integer NULL,\r\n  `published_at` datetime NULL,\r\n  CONSTRAINT `fk_connections_publish_histories` FOREIGN KEY (`connection_id`) REFERENCES `connections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION\r\n);\r\n-- Create index \"publish_history_connid\" to table: \"publish_histories\"\r\nCREATE INDEX `publish_history_connid` ON `publish_histories` (`connection_id`);\r\n" module=db-internal
time=2025-03-25T16:12:46.616+10:00 level=ERROR msg="SQL logic error: table `publish_histories` already exists (1)"
time=2025-03-25T16:13:05.981+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:13:05.982+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:13:05.982+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:13:05.982+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:13:05.982+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:13:05.984+10:00 level=ERROR msg="D:/a/mqtt-viewer/mqtt-viewer/backend/db/migrate.go:45 SQL logic error: table `publish_histories` already exists (1)\n[0.000ms] [rows:0] -- Create \"publish_histories\" table\r\nCREATE TABLE `publish_histories` (\r\n  `id` integer NULL PRIMARY KEY AUTOINCREMENT,\r\n  `connection_id` integer NULL,\r\n  `topic` text NULL,\r\n  `qo_s` integer NULL,\r\n  `retain` numeric NULL,\r\n  `payload` text NULL,\r\n  `encoding` text NULL,\r\n  `format` text NULL,\r\n  `user_properties` text NULL,\r\n  `header_content_type` text NULL,\r\n  `header_response_topic` text NULL,\r\n  `header_correlation_data` text NULL,\r\n  `header_payload_format_indicator` numeric NULL,\r\n  `header_message_expiry_interval` integer NULL,\r\n  `header_topic_alias` integer NULL,\r\n  `header_subscription_identifier` integer NULL,\r\n  `published_at` datetime NULL,\r\n  CONSTRAINT `fk_connections_publish_histories` FOREIGN KEY (`connection_id`) REFERENCES `connections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION\r\n);\r\n-- Create index \"publish_history_connid\" to table: \"publish_histories\"\r\nCREATE INDEX `publish_history_connid` ON `publish_histories` (`connection_id`);\r\n" module=db-internal
time=2025-03-25T16:13:05.984+10:00 level=ERROR msg="SQL logic error: table `publish_histories` already exists (1)"

Log of it working after I deleted the db file the second time I run the exe:

time=2025-03-25T16:16:52.214+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:16:52.216+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:16:52.216+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:16:52.216+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:16:52.216+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:16:52.220+10:00 level=ERROR msg="D:/a/mqtt-viewer/mqtt-viewer/backend/db/migrate.go:45 SQL logic error: table `publish_histories` already exists (1)\n[0.000ms] [rows:0] -- Create \"publish_histories\" table\r\nCREATE TABLE `publish_histories` (\r\n  `id` integer NULL PRIMARY KEY AUTOINCREMENT,\r\n  `connection_id` integer NULL,\r\n  `topic` text NULL,\r\n  `qo_s` integer NULL,\r\n  `retain` numeric NULL,\r\n  `payload` text NULL,\r\n  `encoding` text NULL,\r\n  `format` text NULL,\r\n  `user_properties` text NULL,\r\n  `header_content_type` text NULL,\r\n  `header_response_topic` text NULL,\r\n  `header_correlation_data` text NULL,\r\n  `header_payload_format_indicator` numeric NULL,\r\n  `header_message_expiry_interval` integer NULL,\r\n  `header_topic_alias` integer NULL,\r\n  `header_subscription_identifier` integer NULL,\r\n  `published_at` datetime NULL,\r\n  CONSTRAINT `fk_connections_publish_histories` FOREIGN KEY (`connection_id`) REFERENCES `connections` (`id`) ON UPDATE NO ACTION ON DELETE NO ACTION\r\n);\r\n-- Create index \"publish_history_connid\" to table: \"publish_histories\"\r\nCREATE INDEX `publish_history_connid` ON `publish_histories` (`connection_id`);\r\n" module=db-internal
time=2025-03-25T16:16:52.220+10:00 level=ERROR msg="SQL logic error: table `publish_histories` already exists (1)"
time=2025-03-25T16:16:57.480+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:16:57.480+10:00 level=INFO msg="creating db file at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:16:57.485+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:16:57.485+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:16:57.485+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:16:57.485+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:16:57.553+10:00 level=INFO msg="applied migration 20240615025345_init"
time=2025-03-25T16:16:57.562+10:00 level=INFO msg="applied migration 20240616060546_add-websocket-path"
time=2025-03-25T16:16:57.579+10:00 level=INFO msg="applied migration 20240731092726_persist-sort-and-panel-open-state"
time=2025-03-25T16:16:57.615+10:00 level=INFO msg="applied migration 20241003123229_remove_clear_data_on_connect_field"
time=2025-03-25T16:16:57.656+10:00 level=INFO msg="applied migration 20241124062407_skip-cert-verification-option"
time=2025-03-25T16:16:57.709+10:00 level=INFO msg="applied migration 20250104043611_add-filter-history"
time=2025-03-25T16:17:02.174+10:00 level=INFO msg="logging initalized with debug logging: false, file logging: true, console logging: false"
time=2025-03-25T16:17:02.176+10:00 level=INFO msg="connected to database at C:\\Users\\[user]\\AppData\\Local\\MqttViewer/MqttViewer.db"
time=2025-03-25T16:17:02.176+10:00 level=INFO msg="running MQTT Viewer v0.5.1"
time=2025-03-25T16:17:02.176+10:00 level=INFO msg="resource path located at C:\\Users\\[user]\\AppData\\Local\\MqttViewer"
time=2025-03-25T16:17:02.176+10:00 level=INFO msg="running migrations"
time=2025-03-25T16:17:02.237+10:00 level=INFO msg="applied migration 20250105103712_add-publish-history"
time=2025-03-25T16:17:02.248+10:00 level=INFO msg="applied migration 20250320051532_add-global-and-encrypt-passwords"
time=2025-03-25T16:17:02.248+10:00 level=INFO msg="encrypting existing passwords"
time=2025-03-25T16:17:02.248+10:00 level=INFO msg="applied 2 migrations"
time=2025-03-25T16:17:05.183+10:00 level=INFO msg="current version is the latest" module=updater

Obviously this is not a normal user action but it probably needs to better handle the deletion of the db file

Reproduction steps

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    low-priorityThis can be addressed later.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions