go/cmd/dolt: Make movable temp file configuration lazy.#10327
Merged
Conversation
Previously, early in the process life-cycle after dolt was run, dolt would immediately check if a file created in `os.TempDir()` was able to be `os.Rename`d into a subdirectory of the dolt process's data directory, by default `$PWD/.dolt`. If the rename failed, it would configure Dolt to use `.dolt/temptf` as the movable temp file directory instead. This meant that for many `dolt` invocations, Dolt would do some local filesystem writes, including potentially `Mkdir(.dolt)` before it it was fully loaded. With the advent of things like dolt accessing the running server through sql-server.info and `dolt --host ... sql` this behavior was not ideal. It creates races with concurrently run `dolt` processes that try to use the `.dolt` directory, and it creates odd behavior when running something like `dolt sql` in a non-Dolt directory but on a filesystem mount where this rename from `os.TempDir()` does not work. This PR changes the check and the configuration of a potential `.dolt/temptf` directory to be delayed until the first temporary movable file is actually requested by Dolt. At that point we know that we have a need for a renamable temp file and it is OK to go ahead and create `.dolt/temptf` if we need it. This PR changes the error handling around some edge cases like permissions errors on the calling process creating `temptf` within `.dolt`. In particular, some errors which were previously early and fatal are now delayed until use site and may end up being persistent but non-fatal to the process, depending on the operation.
| } | ||
| } | ||
|
|
||
| type LazyTempFileProvider struct { |
Contributor
There was a problem hiding this comment.
add a comment re: what this is for
Co-authored-by: angelamayxie <angela@dolthub.com>
angelamayxie
approved these changes
Jan 16, 2026
Contributor
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, early in the process life-cycle after dolt was run, dolt would immediately check if a file created in
os.TempDir()was able to beos.Renamed into a subdirectory of the dolt process's data directory, by default$PWD/.dolt. If the rename failed, it would configure Dolt to use.dolt/temptfas the movable temp file directory instead.This meant that for many
doltinvocations, Dolt would do some local filesystem writes, including potentiallyMkdir(.dolt)before it it was fully loaded. With the advent of things like dolt accessing the running server through sql-server.info anddolt --host ... sqlthis behavior was not ideal. It creates races with concurrently rundoltprocesses that try to use the.doltdirectory, and it creates odd behavior when running something likedolt sqlin a non-Dolt directory but on a filesystem mount where this rename fromos.TempDir()does not work.This PR changes the check and the configuration of a potential
.dolt/temptfdirectory to be delayed until the first temporary movable file is actually requested by Dolt. At that point we know that we have a need for a renamable temp file and it is OK to go ahead and create.dolt/temptfif we need it.This PR changes the error handling around some edge cases like permissions errors on the calling process creating
temptfwithin.dolt. In particular, some errors which were previously early and fatal are now delayed until use site and may end up being persistent but non-fatal to the process, depending on the operation.