[Bug]Toolkit db mv may delete the source database after a copy failure, causing data loss
Mantenedores costumam responder em até 1 dia
Um pull request relacionado já foi integrado.
- #6946 de @halibobo1205 — integrado
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 52/100
Direção de pesquisa
Start at the Toolkit db mv command and trace the Files.copy, source-deletion, symbolic-link, and status-reporting flow shown in the issue. Verify failure handling with a disposable database and isolated filesystem, then confirm that a copy failure preserves sources, cleans incomplete destination data, avoids move db done., and returns a non-zero status.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Bug Description
When Toolkit db mv copies database files, an IOException from an individual Files.copy call is printed but not propagated or recorded as an overall migration failure:
try {
Files.copy(original, destination, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
spec.commandLine().getErr().println(e);
}
After copying, the command still attempts to delete the source directory. If deletion succeeds, it replaces the original path with a symbolic link to the destination:
if (FileUtils.deleteDir(p.original.toFile())) {
Files.createSymbolicLink(p.original, p.destination);
}
If copying fails because the destination runs out of disk space or inodes, or because of another I/O error, the source database may be deleted and replaced with a symbolic link to an incomplete LevelDB/RocksDB database. The command may still print move db done. and exit with status 0.
The node may then fail to start and require recovery from a backup or a full resynchronization.
Environment
Network
N/A (offline maintenance tool)
Software Versions
OS: macOS 15 / Linux
JVM: Java 8 / Java 17
Git Commit: f8b05d40abc949fa588ab64d8fd8fd82845ebeed
Version: GreatVoyage-v4.8.2.1
Code: N/A
Expected Behavior
If any file copy fails, the command should:
- Preserve all source databases.
- Not create a symbolic link to an incomplete destination.
- Attempt to clean up incomplete destination data created by the migration.
- Not print
move db done.. - Return a non-zero exit status.
Source directories should be deleted and replaced with symbolic links only after all databases have been copied successfully. A source deletion or symbolic-link creation failure should also return a non-zero status and provide recovery instructions.
Actual Behavior
A copy exception is printed and ignored. The command still attempts to delete the source directory and, if deletion succeeds, creates the symbolic link. Copy and finalization failures are not reliably propagated to the caller, so the command may still print move db done. and return 0.
Frequency
- Always (100%)
- Frequently (>50%)
- Sometimes (10-50%)
- Rarely (<10%)
The data-loss path is consistently reached when a file copy fails but the subsequent source deletion and symbolic-link creation succeed.
Steps to Reproduce
Use only a disposable database from a stopped node and an isolated test filesystem. Do not fill a production disk to reproduce this issue.
- Configure the destination on an isolated test filesystem whose available space is smaller than the source database.
- Ensure that the destination database path does not exist.
- Run:
java -jar Toolkit.jar db mv -d output-directory -c config.conf
echo $?
- Wait for the copy to fail because the destination filesystem runs out of space, then inspect the source path, destination directory, and exit status.
Based on the current code flow, if the subsequent deletion and symbolic-link creation succeed, the source path will become a symbolic link to an incomplete destination, while the command still reports success and returns 0.
Logs and Error Messages
The following is the expected error form for a full destination filesystem. It illustrates the current code flow and is not a captured reproduction log. Exact text depends on the operating system and filesystem.
java.nio.file.FileSystemException: <destination file>: No space left on device
move db done.
(exit code 0)
Additional Context (Optional)
Related Issues
N/A
Possible Solution
Use a two-phase migration:
- Copy all databases first. If any copy fails, preserve every source database, attempt to remove incomplete destination data, and return a non-zero status.
- Delete the source directories and create symbolic links only after all copies succeed.
A source deletion or symbolic-link creation failure should also return a non-zero status and provide recovery instructions.
- Linguagem predominante
- Java
- Estrelas
- 4.2k
- Forks
- 1.8k
- Merge médio
- 2d 15h
- PRs com merge (30d)
- 41
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de tronprotocol/java-tron
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 70/100
tronprotocol/java-tron#7044 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
type:feature
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
tronprotocol/java-tron#7013 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
[Feature] Validate ECKey inputs and improve key handlingTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertatype:feature
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 40/100
tronprotocol/java-tron#6994 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
type:feature
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
tronprotocol/java-tron#6989 · 7 comentários ·
Mantenedores costumam responder em até 1 dia
-
[Feature] decouple json-rpc filter processing from ManagerTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertatype:feature
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 48/100
tronprotocol/java-tron#6963 · 8 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de tronprotocol/java-tron
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
objectionary/lints#1640 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
openhab/openhab-addons#22168 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
wildfly/wildfly-channel#446 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
5.0.x backport enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
spring-cloud/spring-cloud-function#1507 ·
Mantenedores costumam responder em até 1 dia