mongodb fails to delete a temporary file
See original GitHub issueUsing maven dependency:
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>1.50.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
Within Intellij, if I debug a test and shut the test down prematurely (e.g. at a breakpoint) the temporary file that embedded mongo creates does not get deleted (I guess the shutdown hook never runs):
C:\Users\XXX\AppData\Local\Temp\extract-XXX-extractmongod.exe
Additionally, after installing BitDefender, this seems to happen even if I run a whole run without pausing and killing prematurely. I get the message at the end of the test:
[mongod output] 2016-09-16 13:50:24.716 WARN 13120 --- [ Thread-11] d.f.embed.process.io.file.Files : could not delete C:\Users\XXX\AppData\Local\Temp\extract-XXX-extractmongod.exe. Will try to delete it again when program exits.
2016-09-16 13:50:24.721 WARN 13120 --- [ Thread-19] d.f.embed.process.io.file.Files : could not delete C:\Users\XXX\AppData\Local\Temp\extract-XXX-extractmongod.exe. Will try to delete it again when program exits.
Exception in thread "Thread-11" java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
at java.lang.Runtime.addShutdownHook(Runtime.java:211)
at de.flapdoodle.embed.process.io.file.FileCleaner.forceDeleteOnExit(FileCleaner.java:52)
at de.flapdoodle.embed.process.io.file.Files.forceDelete(Files.java:125)
at de.flapdoodle.embed.process.extract.ExtractedFileSets.delete(ExtractedFileSets.java:76)
at de.flapdoodle.embed.process.store.ExtractedArtifactStore.removeFileSet(ExtractedArtifactStore.java:147)
at de.flapdoodle.embed.process.runtime.Executable.stop(Executable.java:77)
at de.flapdoodle.embed.process.runtime.Executable$JobKiller.run(Executable.java:90)
at java.lang.Thread.run(Thread.java:745)
It would be good to have a utility function that I can use to just delete this file at the start of a test.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to delete temporary MapReduce collections in mongoDB
They should be deleted when the connection to the database is closed. See the answers to this question for details and a way...
Read more >Temporary files not removed when starting up after a clean ...
In SERVER-44391 , we started retaining temporary files in the data directory when starting up after a clean shutdown.
Read more >Mongod – Failed to unlink socket file /tmp/mongodb-27017
Mongod – Failed to unlink socket file /tmp/mongodb-27017 ... Remove the temporary socket with this command: sudo rm -rf /tmp/mongodb-27017.
Read more >Can I delete manually data files for entire database in MongoDB
Stopping all mongod and mongos services · Delete all dbPath at PRIMARY hosts · Delete all dbPath at ARBITER hosts · Delete folder...
Read more >Failed to unlink socket file /tmp/mongodb-27017 - Mkyong.com
To fix it, delete the /tmp/mongodb-27017.sock file manually and start the mongod process. Check the /tmp/mongodb-27017.sock permission again, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Faced same issue, following is a work around that can be used. This should be executed before the start of embedded mongo db
It happens when some failure shuts down mongo or tests with mongo prematurely as @manishpatelUK kindly pointed out. Possible solution: delete this file backing up it beforehand. Worked for me.