This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
Bug 1323332 - Orphaned configuration left in database #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We knew from observation that drift-related configs were being orphaned in
the DB. Running some i-tests showed backing configs for drift definitions
being orphaned. This addresses a few different causes:
with the difference being that it is not required to go to the DB, and
instead basically wraps the given ID in a proxy for the desired class.
It should generally not be used for reasons outside of using the proxy
to set FK references in other entities, or to explicitly call setters
on the proxy in some circumstances. It should not be used for an
existence check, a way to perform subsequent gets on the proxy, or
passed to EntityManager.remove(). We were violating all of these rules
in various places. The calls to EM.remove were the cause of some
orphaned config because the getReference proxy did not provide the
proxy necessary for EM.remove to provide the cascade delete.
config, or backing drift definition for a template, when replacing
it with the new one.
DriftDefinition and DriftDefinitionTemplate, so the cascade delete
was not happening. By changing the cleanup code to use EM.remove() the
configs are now cleaned up properly.
Note that this commit does not guarantee to solve this BZ entirely or
even partially, but it is guaranteed to stop some orphan issues, as proven
in testing. Also, it includes analogous changes outside of the drift domain.