Skip to content

Conversation

@Akirathan
Copy link
Member

@Akirathan Akirathan commented Oct 8, 2025

Partially fixes #14122

Pull Request Description

Refactors EnsoFile to use java.nio.files.Path instead of TruffleFile.

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@Akirathan Akirathan self-assigned this Oct 8, 2025
@Akirathan Akirathan added the CI: No changelog needed Do not require a changelog entry for this PR. label Oct 8, 2025
@Akirathan Akirathan changed the title EnsoFile uses java.nio.files.Path instead of TruffleFile EnsoFile uses java.nio.files.Path instead of TruffleFile Oct 8, 2025
@Akirathan Akirathan changed the title EnsoFile uses java.nio.files.Path instead of TruffleFile EnsoFile uses java.nio.files.Path instead of TruffleFile Oct 8, 2025
@JaroslavTulach
Copy link
Member

JaroslavTulach commented Oct 9, 2025

Few more truffle boundaries needed... Done in 564907e

@Akirathan Akirathan marked this pull request as ready for review October 9, 2025 10:05
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

OK, in general. We do want to move away of using TruffleFile, because it makes little sense when one can polyglot java import java.io.File... The primary use of TruffleFile is security and Enso as deliberately given upon any security by opening whole JDK API up.

The Windows failures may be relevant and may deserve to be addressed.

Read XLSX / XLS Files
❌ during read_many, should not mix metadata columns with data columns with same name or when matching by position
An unexpected dataflow error ((Access_Denied (File_Like.Value (File C:\runner_work\enso\enso\test\Table_Tests\data\transient\read_many_test)))) has been matched (at C:\runner_work\enso\enso\test\Table_Tests\src\IO\Read_Many_Spec.enso:452:5-46).
❌ during read_many, should correctly handle empty sheets
An unexpected dataflow error ((Access_Denied (File_Like.Value (File C:\runner_work\enso\enso\test\Table_Tests\data\transient\read_many_test)))) has been matched (at C:\runner_work\enso\enso\test\Table_Tests\src\IO\Read_Many_Spec.enso:452:5-46).

@Akirathan
Copy link
Member Author

Akirathan commented Oct 13, 2025

The stack trace of java.io.AccessDeniedException on Windows is at https://github.com/enso-org/enso/actions/runs/18405614769/job/52448768751?pr=14126#step:14:6652 when trying to create a directory after it has been recursively deleted. This exception is thrown from

base_dir.create_directory . should_succeed

This exception is happening both in JVM mode and in native mode. On Windows only.

GitHub
Enso Analytics is a self-service data prep and analysis platform designed for data teams. - EnsoFile uses java.nio.files.Path instead of TruffleFile · 78d78b2

@Akirathan
Copy link
Member Author

Akirathan commented Nov 7, 2025

Executing just a single test on Windows that was previously failing (along with some additional log messages) is (surprisingly) OK - https://github.com/enso-org/enso/actions/runs/19165386957/job/54789759488?pr=14126#step:14:914. Let's try to run two consecutive tests - 2adea49

GitHub
Enso Analytics is a self-service data prep and analysis platform designed for data teams. - EnsoFile uses java.nio.files.Path instead of TruffleFile · 7609480

@Akirathan
Copy link
Member Author

Akirathan commented Nov 10, 2025

After adding more verbose logs in da7a7a6, running two consecutive tests now mysteriously pass. The AccessViolationException was expected to be thrown in https://github.com/enso-org/enso/actions/runs/19178063595/job/54832637621?pr=14126#step:14:1279 that is, when creating the directory after it has been recursively deleted. The previous AccessViolationException is in https://github.com/enso-org/enso/actions/runs/19167793456/job/54796541791?pr=14126#step:14:933

More verbose logs revealed, that all the EnsoInputStream and EnsoOutputStream are properly closed.

@Akirathan
Copy link
Member Author

Akirathan commented Nov 11, 2025

Since the AccessDeniedException occurs transiently, my latest theory is that there is some kind of race condition, similar to the one mentioned in https://stackoverflow.com/questions/15892295/access-denied-when-repeatedly-create-and-remove-the-same-directory. I have tested this theory on Akirathan/windows-nio#1 but without success. In that PR, there is a recursively deleted directory, and then created, in a loop.

Stack Overflow
I just had a little test, and this is how I did it: I repeatedly create and remove one directory, d:\test, for example. I did that for like 1000 times, and it always will get an error for acccessing

@Akirathan
Copy link
Member Author

After an investigation, that has taken longer than I expected, I have simply decided that the AccessDeniedException is most likely caused by some race condition on Windows. As such, I am providing a simple retry mechanism directly in the test in 1826dc7.

I think this is OK because end users are unlikely to delete and create the same directory in a tight loop. And if so, and the AccessDeniedException is raised, we can argue that is an "expected weird behavior of Windows". At this time, I don't think there is any reasonable systematic solution for this problem.

private with_temp_dir callback =
base_dir = enso_project.data / "transient" / "read_many_test"
private with_temp_dir test_name:Text callback =
base_dir = enso_project.data / "transient" / test_name
Copy link
Member

Choose a reason for hiding this comment

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

  • won't the problems go away if 524405f stops using the same directory again and again?
  • if not, feel free to remove 524405f with git reset HEAD~1; git push -f

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I think this is a much more elegant solution. And yes, the problem should go away. Let's merge.

@Akirathan Akirathan merged commit 57a9c89 into develop Nov 13, 2025
82 of 84 checks passed
@Akirathan Akirathan deleted the wip/akirathan/14122-no-trufflefile branch November 13, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: No changelog needed Do not require a changelog entry for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite File to use java.nio.path instead of TruffleFile.

4 participants