Unify all bulk inserts to a single code path #610
Merged
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.
I set out to unify all code paths including single inserts, but ultimately realized it's a bit too messy to do that until we get rid of advisory lock unique inserts. The reason is that the current multi-insert code structure drops the
dbunique.UniqueOpts
on the floor where it generates insert args, which isn't super close to the point where the actual insert operation happens (and thus where we could branch out to the old unique inserter path). Ultimately I felt it wasn't worth trying to do that because in one more point release I think we can safely remove the advisory lock unique inserts.For now, I've unified all multi-insert paths to use the same code for generating insert options, emitting notifications, etc, with each separate top level group (regular insert many vs fast/copy) passing a function for the actual insert using a common API structure.
I think if you want to integrate #584 into this it makes sense to just focus on this unified multi insert code path, and we can ship middleware in the same release where we remove advisory lock uniqueness.