Skip to content

ci: merge staging to master #71

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
Jul 28, 2022
Merged

ci: merge staging to master #71

merged 5 commits into from
Jul 28, 2022

Conversation

maxwell-aiden
Copy link
Member

This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful.

@maxwell-aiden maxwell-aiden self-assigned this Jul 28, 2022
@maxwell-aiden
Copy link
Member Author

@ghost
Copy link

ghost commented Jul 28, 2022

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@maxwell-aiden
Copy link
Member Author

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Jul 28, 2022

Ok there's another concurrency non-determinism. This time caused by a slower write while there is a write stream. It's quite confusing. But this is my theory.

We have a write stream that writes 10 chunks of AAAAA. Therefore if it was writing by itself, we would see something like:

AAAAA AAAAA AAAAA AAAAA ... etc

Now we also have an atomic call to a duplicated FD but that which starts at position 0. It writes 25 characters of B.

The test currently expects the 25 characters to be written atomically. Therefore the test thinks the end result is either one of these:

AAAAA AAAAA ... etc
OR
B*25 A*25

But the problem with this expectation is that, the former is true if the B write occurred first, and then A writes started. The latter can occur when A writes complete, then B write starts.

But if B write starts in the middle of A writes. Then we would get a mixed output.

This is because:

  1. Let's suppose that after the first A chunk, the B writes were written. We would have B*25
  2. On the second A chunk, it is still writing from the first chunks ending position.
  3. This results in BBBBB as the first 5 bytes, but subsequent bytes will all be A.

Hence is why we have:

    Expected: "BBBBBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAA"
    Received: "BBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"

Now this could also change if the B writes occurs after the 2nd chunk. In that case we should use B*10 and then all As.

The reason why this is quite non-deterministic is because there are 2 levels of asynchronicity here. The ones involving await, but also lazy drainage events, where just because we do writeStream.write(dataA), there's no guarantee that the writes have written to the disk. Of course in our in-memory FS, we could sequence it properly with a callback to wait for when the chunk is in fact written.

But the end result is that the B writes can occur at any point in time between the atomic A writes. This is the same problem as the previous problem, but it wasn't as clear, because B writes starting from position 0, whereas A writes are in sequence.

@CMCDragonkai
Copy link
Member

@tegefaulkes

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Jul 28, 2022

So the solution could be to strictly control the concurrency, but that doesn't allow our test to be robust. A robust test here should instead have a predicate that allows any of the possible permutations of the output. That being of all As, or any number of chunks of B based on the chunk size of A, up to 5 chunks (the length of B divided by the chunk size of A).

@CMCDragonkai
Copy link
Member

This has been resolved with a more robust regex check. I suspect more of these bugs are lurking in the tests.

@CMCDragonkai CMCDragonkai requested a review from tegefaulkes July 28, 2022 10:48
@maxwell-aiden
Copy link
Member Author

@maxwell-aiden
Copy link
Member Author

@maxwell-aiden
Copy link
Member Author

@maxwell-aiden maxwell-aiden merged commit 92efef0 into master Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants