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

Multi-camera support doesn't migrate existing settings database to new format. #1046

Closed
crschardt opened this issue Dec 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@crschardt
Copy link
Contributor

Describe the bug
#1015 added a new column to the "camera" table in the settings database, but it doesn't migrate an existing database to the new format. If there is an existing database, then database access fails with the following error message (h/t quicksinger21 on discord):

Dec 17 04:31:56 photonvision java[2280]: [2023-12-17 04:31:56] [General - ConfigManager] [DEBUG] Saving to disk...
Dec 17 04:31:56 photonvision java[2280]: [2023-12-17 04:31:56] [Config - SqlConfigProvider] [DEBUG] Saving to disk
Dec 17 04:31:56 photonvision java[2280]: [2023-12-17 04:31:56] [Config - SqlConfigProvider] [ERROR] Err saving cameras: [SQLITE_ERROR] SQL error or missing database (table cameras has no column named otherpaths_json)
Dec 17 04:31:56 photonvision java[2280]: [2023-12-17 04:31:56] [Config - SqlConfigProvider] [ERROR] org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (table cameras has no column named otherpaths_json)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.DB.newSQLException(DB.java:1179)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.DB.newSQLException(DB.java:1190)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.DB.throwex(DB.java:1150)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.NativeDB.prepare(NativeDB.java:126)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.DB.prepare(DB.java:264)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.core.CorePreparedStatement.<init>(CorePreparedStatement.java:46)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.jdbc3.JDBC3PreparedStatement.<init>(JDBC3PreparedStatement.java:31)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.jdbc4.JDBC4PreparedStatement.<init>(JDBC4PreparedStatement.java:25)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.jdbc4.JDBC4Connection.prepareStatement(JDBC4Connection.java:34)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:226)
Dec 17 04:31:56 photonvision java[2280]:         at org.sqlite.jdbc3.JDBC3Connection.prepareStatement(JDBC3Connection.java:206)
Dec 17 04:31:56 photonvision java[2280]:         at org.photonvision.common.configuration.SqlConfigProvider.saveCameras(SqlConfigProvider.java:304)
Dec 17 04:31:56 photonvision java[2280]:         at org.photonvision.common.configuration.SqlConfigProvider.saveToDisk(SqlConfigProvider.java:183)
Dec 17 04:31:56 photonvision java[2280]:         at org.photonvision.common.configuration.ConfigManager.saveToDisk(ConfigManager.java:279)
Dec 17 04:31:56 photonvision java[2280]:         at org.photonvision.common.configuration.ConfigManager.saveAndWriteTask(ConfigManager.java:288)
Dec 17 04:31:56 photonvision java[2280]:         at java.base/java.lang.Thread.run(Thread.java:829)
Dec 17 04:31:56 photonvision java[2280]: 
Dec 17 04:31:56 photonvision java[2280]: [2023-12-17 04:31:56] [Config - SqlConfigProvider] [INFO] Settings saved!
Dec 17 04:33:33 photonvision java[2280]: [2023-12-17 04:33:33] [General - ShellExec] [DEBUG] Executing "journalctl -u photonvision.service > /tmp/photonvision-journalctl12219735344239381215.txt"
@crschardt crschardt added the bug Something isn't working label Dec 16, 2023
@crschardt
Copy link
Contributor Author

I figured out how to add the column to a table if it's missing. Now I'm working on figuring out how to prevent it from duplicating the camera entry when it does this. I'll try to have a PR soon.

@mcm001
Copy link
Contributor

mcm001 commented Dec 17, 2023

Also dumb question what happens if users go backwards? From a version with this new DB format to one before it was changed I mean. Not that we should be promising backwards compatibility during beta, but for future reference

@crschardt
Copy link
Contributor Author

crschardt commented Dec 17, 2023

That is a great question! I thought maybe it would work and the older version would just ignore the extra column, but testing it lead me to #1053, which makes me think that it could be a lot of work to allow for backward compatibility.

@mcm001 mcm001 closed this as completed in f37a0d0 Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants