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

Fix project settings file getting corrupted #652

Closed

Conversation

AliAlbarrak
Copy link

Why this change?

This resolve the settings file corruption as described in #524

Even though reading and writing of the settings file is protected by a lock, it is possible (due to domain reload) that 2 separate running processes are trying to access the file at the same time so the lock in one process is not aware of the other process.

A scenario like this could happen.

  1. Code in domain A will start writing to ProjectsSettings file
  2. Code in domain B will start reading the file
  3. If domain A didn't finish writing yet, domain B will encounter unexpected EOF
  4. Domain B will assume the file is broken and reset settings
  5. Domain B will write default settings to ProjectsSettings file

What did I do?

I made the writing happen to a temporary file. When the writing is complete, copy the temp file to the target path. This avoids the file being in an "invalid state" for a short time during the writing.

Review

Feedback is greatly appreciated and please let me know which steps I need to take to make my change release-ready.

@AliAlbarrak AliAlbarrak marked this pull request as draft November 14, 2023 07:29
@AliAlbarrak
Copy link
Author

As reported here, this fix fails sometimes so I'll draft the pull request until I find a better solution

@AliAlbarrak AliAlbarrak marked this pull request as ready for review December 17, 2023 04:37
@AliAlbarrak
Copy link
Author

The settings file gets written multiple times with every domain reload/compile, even when settings didn't change. I added an extra check to skip file write if settings didn't change since last read.

@AliAlbarrak
Copy link
Author

Hello @a-maurice @chkuang-g and team
I'd appreciate it if you can guide me through what I need to do to get this reviewed and merged. This PR is associated with the top voted 👍 issue #524. I believe it will be great UX improvement for most users to get it fixed.

@Nezz
Copy link
Contributor

Nezz commented Jan 5, 2024

We'd love to have this incorporated - this is a very annoying issue.

@cmcpasserby
Copy link

really can non one review this and get it merged in? This issue has been going on for years and makes working with this very annoying and tedious

@Tommigun1980
Copy link

I tested this pull request and my findings are at #524 (comment)

Copy link

@TyelorD TyelorD left a comment

Choose a reason for hiding this comment

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

I think this pull looks good to me, aside from the one change I requested.

That said, I'm not affiliated with Google in any way.

@berniegp
Copy link
Contributor

berniegp commented Mar 9, 2024

Hi! I still got settings corruption with your version. However I think I found the source of the problem and a fix here #678.

@AliAlbarrak
Copy link
Author

I guess this is no longer needed since #678 was merged 🎉

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.

None yet

6 participants