Skip to content
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

Crate marked as yanked when both yanked and unyanked in one index-update #2295

Closed
Nemo157 opened this issue Oct 30, 2023 · 8 comments · Fixed by #2302
Closed

Crate marked as yanked when both yanked and unyanked in one index-update #2295

Nemo157 opened this issue Oct 30, 2023 · 8 comments · Fixed by #2302
Assignees
Labels
A-backend Area: Webserver backend C-bug Category: This is a bug

Comments

@Nemo157
Copy link
Member

Nemo157 commented Oct 30, 2023

It appears we process the yank and unyank events in the wrong order when they come together in one update:

2023-10-30T01:43:24.525568Z DEBUG docs_rs::build_queue: queueing changes from 0e09b092780cfd28f4d9557f7e06e9fbc1c248c7 to 3f9de8e33bc8be081b6a480a75464b908b439bfc
2023-10-30T01:43:24.531502Z DEBUG docs_rs::build_queue: dylink-0.8.0 unyanked
2023-10-30T01:43:24.536981Z DEBUG docs_rs::build_queue: dylink-0.8.0 yanked

We're explicitly reversing the changes:

docs.rs/src/build_queue.rs

Lines 293 to 294 in 4514194

// I believe this will fix ordering of queue if we get more than one crate from changes
changes.reverse();

Maybe this order was changed in a crates-index-diff update?

@Nemo157 Nemo157 added C-bug Category: This is a bug A-backend Area: Webserver backend labels Oct 30, 2023
@syphar
Copy link
Member

syphar commented Nov 4, 2023

@Byron you have more info here?

@syphar
Copy link
Member

syphar commented Nov 4, 2023

@Byron
Copy link
Member

Byron commented Nov 5, 2023

I will take a look ASAP, but vaguely remember that there is a test for this already so I doubt something regressed. But who knows, maybe it's something new that never worked and we just weren't aware. As long as I can still find the respective operations/commits in the crates-index repo I should be able to make it reproducible.

@syphar
Copy link
Member

syphar commented Nov 6, 2023

Thanks for checking!

For me it would be good enough to know in which order the updates will be emitted by crates-index-diff, then we just adapt our logic

@Byron
Copy link
Member

Byron commented Nov 6, 2023

After taking a closer look I am quite sure that this can't be adapted to, not in its current form. The documentation states that multiple changes for a single crate are emitted in any order. This was alright in the past I suppose but I also wonder how the baseline test can work as perfectly as it does if yanks and unyanks are out of order - most changes are actually ordered nonetheless as it's additions or single-line modifications though.

Tests also deal with the problem by sorting beforehand to get a deterministic order, but now this needs to change to be deterministic. Let's see if I can do that without hurting performance too much (and even if so, performance is clearly secondary here).

@Byron
Copy link
Member

Byron commented Nov 6, 2023

That's strange: peek_changes_ordered() already single-steps through the history, and in casae of dylink there is only one change per commit. It first gets yanked, then it gets unyanked, and that order will definitely be reproduced then.

The changes.reverse() will reverse the order, which explains the problem here.

However, this line seems to also have solved a problem, but it might have been coincidence.

The problem remains: should there be deterministic ordering between line-based changes? The answer here is most certainly: Yes, so I will see to it, which should allow the line 294 to be removed without side-effects.

@Byron
Copy link
Member

Byron commented Nov 6, 2023

Alright, it took me a while to realise my naiveté in trying to impose any ordering of changes within a diff and assume it's more than 'ordered by line number', but at least it's deterministic then.

I also don't know what line 294 is trying to solve, maybe figuring that out helps to solve the true underlying problem.

My adjustment right now makes the order of multiple changes to a crate deterministic, as it will order them by line number, ascending. And some determinism is certainly an improvement as to not trick anybody into imposing their own ordering for that reason alone.

Byron added a commit to Byron/crates-index-diff-rs that referenced this issue Nov 6, 2023
…fication.

This can happen if a crate is yanked and unyanked in one commit, which happens
in practice even though I am not sure how it's possible.

Related issue: rust-lang/docs.rs#2295
@Byron
Copy link
Member

Byron commented Nov 6, 2023

I have released a new version which uses the latest gix just like docs.rs and makes per-crate changes deterministic in order.

There is definitely no need to reverse the order as done in line 294 as crates-index-diff provides the order created by stepping through commits, and now additionally orders per-crate changes by line number, ascending so it is deterministic as well.

I hope that helps and that soon there will be no issues whatsoever related to the tracking of changes to crates 😅.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend Area: Webserver backend C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants