-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
[Bug Report] Stash crashes if sent graphQL after upgrade + pre migration #4197
Comments
I have a fix for this locally, as part of a larger refactor. It's based off of #4152, so I'll send a PR through once that merges. It simply returns a "database not initialized" error if any request involving the database is made before it is properly initialized, i.e. before the initial setup or if a migration is required. If a migration is required, all pages in the UI will redirect to the migration page to prompt for user confirmation. There is also a warning logged on startup ( What you could do is use the query {
systemStatus {
databaseSchema
appSchema
status
}
} and only start the automatic scan if |
Thanks for the reply and info @DingDongSoLong4! Responding to your points
Yeah, this is the exact situation that applied unfortunately!
Ah, awesome, thanks for sharing that script! I am very new to GraphQL, so appreciate it!
Yeah, it was a learning experience for sure and now that I am more explicitly aware of the dependency between Additional reflection on overall situationFirstly, thanks again for your help and multiple suggestions! Overall these should significantly reduce the chance of this happening again! As you said above, the combination of having
... which I interpretated as ...
I then spent ages looking at the wrong problem, swapping I'm not saying that stash needs to consider everything and protect against every single scenario, but in my defence, stash returning
|
This is perfectly reasonable, and I definitely agree. Having a database that needs to be migrated is an entirely normal scenario - it should be taken into account wherever possible, and should definitely not cause a crash. Actually now that I think about it, my change wouldn't solve the issue with The way I'd probably fix it is to allow for jobs to verify some kind of precondition before they can be added to the queue, in this case checking if the database has been initialized. This will let the action of adding a job to the queue potentially fail, which would then be able to return an error directly from My fix was for normal data graphql requests (something like Also sidenote: if you haven't already, I would highly recommend configuring a log file (Settings > System > Logging). The log file would have allowed you to see the |
Cool, yeah so I think there are two potential code changes that could be implemented, if the dev team agrees... Part 1 (
|
Well Part 1 is part of the fix I have already made locally - it will cause the scan to log a "database not initialized" error message instead of causing a crash. Part 2 is what I haven't implemented yet - I'll see what I can do when I have time. I don't imagine it would be amazingly complex to do, although it probably won't be trivial either.
In general @WithoutPants is the one who handles most of these things, although I'd say both changes are relatively uncontroversial. |
Ah, amazing!
Appreciate that. Like I said above, whilst I still think part 2 is valid/beneficial, it is more of a "optional" or "nice to have" so please just work on it whenever you have time, no rush!
Just to double-check -- Although in this instance it was a |
I think Edit: in fact, |
Alright that was easier than I thought it would be - I've added a commit to my local branch that ensures the database is initialized if necessary before adding jobs. |
Awesome, thanks for this!
|
Summary
Stash crashes if sent a graphQL command before the DB is upgraded to the latest schema (e.g. after updating to a new version)
To Reproduce
Context / Troubleshooting performed
I have a v. simple script that auto-runs a scan for newly downloaded content when stash starts by:
stash-win.exe
with several parameters, in a minimised windowAfter upgrading to stash v0.23.0, I found stash was crashing a few seconds after starting. I did some local troubleshooting, and discovered that the upgrade to stash v0.23.0 also required a DB schema (which is fine!) however, presumably because the stash console window was being minimised(?), this was not being prompted and so was not being done before the time-delayed graphQL instruction was sent a few seconds later, causing stash to crash (rather than ignore the command or send an error response).
Expected behaviour
If a DB upgrade is required and/or there are certain requests that stash cannot execute at a certain time due (e.g. because a DB upgrade is required first), when receiving an instruction stash should either:
Stash Version
v0.22.0 --> v0.23.0
Desktop information
The text was updated successfully, but these errors were encountered: