Skip to content

fix: write compilation database atomically - #37

Merged
fcying merged 1 commit into
mainfrom
dev
Sep 3, 2026
Merged

fcying merged 1 commit into
mainfrom
dev

Conversation

@fcying

@fcying fcying commented Sep 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3c33e5654

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/init.go
}
// Rename is atomic on Unix when both paths share a filesystem. Go does not
// guarantee atomicity on Windows, but staging still avoids in-place writes.
return os.Rename(temporaryFilename, filename)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain a fallback for sharing-blocked Windows replacements

On Windows, replacing an existing database with os.Rename fails with a sharing violation whenever another process has the file open without FILE_SHARE_DELETE; a normal Go os.Open reader is one example. The previous in-place os.Create path could still update the file when that reader allowed FILE_SHARE_WRITE, so an IDE, indexer, or other database consumer holding the file open can now make the supported Windows CLI terminate without updating it. Retry the replacement or fall back to an in-place write for this Windows error.

AGENTS.md reference: AGENTS.md:L48-L48

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@codex review
▏ The Windows sharing-violation scenario is valid, but falling back to an in-place truncate/write would reintroduce the partial-JSON race this change is intended to eliminate. When replacement is blocked, the current implementation
▏ preserves the complete old database, removes the staged file, and returns an error. Windows replacement is intentionally best-effort because a handle opened without FILE_SHARE_DELETE makes atomic replacement impossible. A retry
▏ would only help transient readers and cannot guarantee progress for long-lived handles

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3c33e5654

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/init.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e24fc238d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/init.go
@fcying

fcying commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: e24fc238d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcying
fcying merged commit 1277af6 into main Sep 3, 2026
12 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.

1 participant