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

Gracefully handle outdated .ninja_log during '-t recompact' #2390

Merged

Conversation

jheydebrand
Copy link

Fixes #2048

I ran into a similar issue when migrating existing workspaces from ninja 1.9.0 to the latest revision from Git.

This change will cause NinjaMain::OpenBuildLog() to not call build_log_.Recompact() after build_log_.Load() just deleted that file because it contained an invalid log version.

@digit-google
Copy link
Contributor

Thank you. The fix looks good to me, but can you add a regression test in misc/output_test.py to verify that this works correctly?

E.g.: perform a build, then overwrite the version bytes in the build log, then run the recompact tool and verify it does not report an error?

@jheydebrand jheydebrand force-pushed the handle-deleted-logs-during-recompact branch from f693243 to 878653f Compare March 13, 2024 16:42
@jheydebrand
Copy link
Author

I added a test as suggested, @digit-google
However, I could run it only on Windows locally - hopefully test test runs fine on Linux, too.

@jheydebrand jheydebrand force-pushed the handle-deleted-logs-during-recompact branch from 878653f to 7f72db9 Compare March 14, 2024 07:59
@jheydebrand jheydebrand force-pushed the handle-deleted-logs-during-recompact branch from 7f72db9 to db07288 Compare March 14, 2024 10:08
@digit-google
Copy link
Contributor

Thank you, this looks good to me. @jhasse what do you think?

@jheydebrand
Copy link
Author

jheydebrand commented Mar 14, 2024

Should I try to work around Python 3.6 in AppVeyor not knowing text=True?

@jhasse
Copy link
Collaborator

jhasse commented Mar 16, 2024

Dropping Ubuntu 14.04, 16.04 and 18.04 in favor of 20.04, 22.04 and 24.04 is something I would want to do soon, so you might also just wait. But I think we'd also have to run these tests on RHEL 7 (or 8 soon), I don't know what Python version they are using.

@jheydebrand
Copy link
Author

Looks like RHEL 7 supports Python 3.8 per https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/html-single/3.5_release_notes/index#sect-RHSCL-Changes-python

Depending on your timeline for dropping the older distros, I'd offer to get the test to work with the older Python version to wrap this PR up.

@digit-google
Copy link
Contributor

Aargh, I was not aware of this limitation, remove the text=True for now then, this is not a good reason to block this PR. Thanks.

@jhasse
Copy link
Collaborator

jhasse commented Mar 16, 2024

See #2399

@jhasse
Copy link
Collaborator

jhasse commented Mar 20, 2024

Can you rebase against / merge master?

@jheydebrand jheydebrand force-pushed the handle-deleted-logs-during-recompact branch from db07288 to 035526f Compare March 20, 2024 17:03
@jheydebrand
Copy link
Author

Looking good now :)

@jhasse jhasse added this to the 1.12.0 milestone Mar 20, 2024
When we explicitly unlink the file we should return LOAD_NOT_FOUND instead of LOAD_SUCCESS
@jheydebrand jheydebrand force-pushed the handle-deleted-logs-during-recompact branch from 035526f to 878aa46 Compare March 21, 2024 08:17
@digit-google
Copy link
Contributor

LGTM now, thank you.

@jhasse jhasse merged commit 903a05c into ninja-build:master Mar 22, 2024
10 checks passed
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.

Recompact fail with "failed recompaction: No such file or directory"
3 participants