Skip to content

Follow-up from review on PR #554 #572

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

Merged
merged 5 commits into from
Feb 13, 2025
Merged

Follow-up from review on PR #554 #572

merged 5 commits into from
Feb 13, 2025

Conversation

dcoutts
Copy link
Collaborator

@dcoutts dcoutts commented Feb 13, 2025

Additional post-merge PR review.

Typos and stale / inaccurate comments.
by making it a newtype for UnspentCredits rather than Credits, so when
unwrapping one layer its still compatible with other credit values and
we can perform operations.
We do now check that we do not do too much merging work. But we could
still supply excess credits leading to unexpected leftover credits. Add
TODOs in the right places about asserting there are no leftover credits.

We can't assert this yet because there are in fact leftovers because we
do not spread out merging work fully, in the case that runs are less
than worst case in size.
These are not concurrency safe. The merging runs could complete during
snapshot persistence leading to use after free. Add TODOs to explain
this and to suggest a solution.
And remove a stale comment about non-zero cases and replace it by an
assertion.
@dcoutts dcoutts added this pull request to the merge queue Feb 13, 2025
Merged via the queue into main with commit bd366da Feb 13, 2025
27 checks passed
@dcoutts dcoutts deleted the dcoutts/pr-554-review branch February 13, 2025 16:13
Comment on lines +882 to +884
--TODO: assert leftoverCredits == 0
-- to assert that we did not finished the merge too early,
-- and thus have spread the work out evenly.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise that you are changing the credit scaling in #571, so maybe this comment does not apply anymore, but I'll post it anyway:

I don't think this assertion will hold in the presence of exceptions, even if we fix credit scaling (a priori) to precisely add up to the a priori merging debt.

Say a table needs n updates until the next flush. We do some updates but an exception happens, so we roll back the database internal state to a consistent state. This means undoing changes to the write buffer for example, but not undoing the credits we supplied to merging runs already. Afterwards, the table still needs n updates until the next flush, but some or all of its merging runs already have an elevated count of supplied credits. This means that supplyCredits during normal operation can also return leftover credits.

Moreover, if multiple tables concurrently supply credits, we'll in general try to supply even more credits, leading to more leftovers.

If we really want to assert this, maybe we have to:
(i) ensure that scaleCreditsForMerge accounts for the elevated counts of supplied credits
(ii) undo supplied credits

Both options sound like they would be rather complex to do in a concurrent setting

Comment on lines +755 to +757
--TODO: Run.fromMutable (used in Merge.complete) claims not to be
-- exception safe so we should probably be using the resource registry
-- and test for exception safety.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. We could use modifyWithActionRegistry or something similar to guarantee that the result of Run.fromMutable is put in the mergeVar.

I'm hoping we can make Run.fromMutable and Merge.complete exception safe without passing a registry into it, so that we don't have to have a registry argument in too many places, but I haven't tried that yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants