fix(core): reopen database after update failure - #8679
Conversation
There was a problem hiding this comment.
Thanks! This is probably the correct approach, but do you have any test evidence or information to supply that it actually fixes the linked issue without causing other problems, and making sure the DB is still closed correctly later on?
There are only unit and existing regression tests here; and no explanation of why keeping the DB open is the only thing preventing the analysis from continuing and surviving the later ensureDataExists() check.
In the log for the linked issue supplied at https://gist.github.com/OrangeDog/24ce9447e015184ccf85ac647e17749b the error is org.owasp.dependencycheck.exception.NoDataException: No documents exist
This seems to be happening because the database is null and failing the check below. Reopening the database at least allows the check to continue to database.dataExists()
DependencyCheck/core/src/main/java/org/owasp/dependencycheck/Engine.java
Lines 1142 to 1146 in a318a7e
|
Thanks — the linked failure is caused by The current test verifies the immediate lifecycle invariant, but it does not yet exercise the full |
|
Would appreciate without unhelpful copy-paste AI replies please. That's basically reiterating what I already said. An extremely complicated automation integration test may not be justified, but would at least like to see examples of "thought* or adhoc testing. An UpdateException can happen for many reasons so changing the handling should require some evaluation that the database is in a safe state for re-opening and at least "likely to succeed" in normal scenarios (e.g timeouts from NVD API) without making things worse. |
|
Fair — and sorry, that reply restated your own analysis back at you. Here is the actual reasoning, and what I did and did not run. What the patch changes. Only the order of two statements in Why the database is in a safe state at that point.
The scenario you named, an NVD timeout with existing local data. Partial updates. If one source committed rows and a later one failed, the database holds those rows — the same state you get today, because the write happened before the exception surfaced. The only difference is whether the engine then reopens the file. What I ran. The unit test in this PR pins the invariant: a data source that always throws makes To be straight with you: I use an LLM assistant for drafting, which is where that copy-paste tone came from. The analysis above and the test are mine. |
|
Pushed the test in 35f4556: It starts from the populated test database, registers a single Negative control: with the pre-patch statement order the same test fails exactly on the On the earlier reply - sorry again, that one deserved the pushback. I do use an LLM assistant: my unaided code and prose are worse than what I get with it, so I lean on it and then verify the result myself. That is not a reason to paste a draft that restated your own analysis back at you, and I have stopped doing that. |
chadlwilson
left a comment
There was a problem hiding this comment.
Thx, overall this seems reasonable to me and likely to do more "good" than harm, but I have not gone super deep into all the possible failure modes.
Right now there are some other problems with what happens when updates fail during multithreaded parts of the processing because in some cases the threads are not all interrupted and completed before the calling code starts trying to handle things. It is possible that when the database is reopened here, that background threads will then still be trying to interact with the DB even though the main processing has continued. There is some quite complex threading involved with parallel downloading and DB ingestion - hopefully that doesn't make things worse without addressing the "graceful closure" problem.
|
Noted, and to be clear I am not claiming this addresses graceful closure - it does not touch thread lifecycle at all. Two things that bound the risk you are describing, both already in That is a bound rather than a fix. If a straggler thread is still ingesting when |
|
@jeremylong this one is green on all 15 checks and approved; the only thing left is a review that counts toward the branch rule. If you want the interrupt/join side of the threading question tracked before this goes in, say so and I will open a separate issue for it rather than widen this PR. |
|
In any case, I am done responding here. Every reply appears to be AI speak which is overly confident and missing lots of context. Enough. You know if I want to talk to an LLM I can do on my own, and probably prompt it much more effectively, right? |
|
@chadlwilson hey! |
|
I don't have merge permissions, only triage, so I'm not a gate you need to "pass" anyway, so feel free to ignore me. This project doesn't have particular AI or contribution guidelines so I just establish my own boundaries based on the dynamics and experience I personally want to have in open source when I volunteer my time. |
|
@chadlwilson That's fair, and I'm not going to argue with where you draw your line — it's your time and your call. For the record: the review you gave was useful and I did act on it — the ordering rationale and the regression test in 35f4556 came out of your questions. If the tone read as overconfident, that's on me, and I'm sorry it cost you the kind of exchange you wanted to have. I won't ping you again on this one. |
|
@jeremylong bumping this one: 15/15 checks green, no conflicts, and the change is limited to the order of the update/analysis phases plus a regression test (EngineTest.testAnalysisContinuesOnLocalDataAfterUpdateFailure, 35f4556). It's approved by @chadlwilson but that doesn't satisfy the branch rule, so it needs a review from someone with merge rights. Happy to split anything out if the scope looks too wide. |
Description of Change
Reopen the local database before propagating a cached data source update failure. This preserves the original
UpdateExceptionwhile allowing callers to continue analysis with existing vulnerability data, as the warning promises.A regression test registers a failing cached web data source and verifies that the database remains available after the failed update.
Related issues
Have test cases been added to cover the new functionality?
Yes.
Testing
mvn -pl core -am -DskipTests -Ddownload.plugin.skip=true installmvn -pl core -Ddownload.plugin.skip=true -Dtest=EngineTest test(2 tests passed)