Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用backupOneToDirectory做备份失败 #1432

Open
Yuanxilin opened this issue Nov 12, 2024 · 1 comment
Open

调用backupOneToDirectory做备份失败 #1432

Yuanxilin opened this issue Nov 12, 2024 · 1 comment

Comments

@Yuanxilin
Copy link

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

Java

The version of MMKV

1.3.9

The platform of MMKV

Android

The installation of MMKV

Gradle

What's the issue?

I failed to call backupOneToDirectory.
The original code is

  `boolean ret1 = MMKV.backupOneToDirectory("osds", GlobalParam.applicationContext.getFilesDir().getAbsolutePath() + "/mmkvbackup", null);`

What's the log of MMKV when that happened?

11-12 18:31:53.639 I/MMKV ( 2518): current API level = 25, libc++_shared=0
11-12 18:31:53.640 I/MMKV ( 2518): MMKV.cpp:166::initialize version v1.3.9, page size 4096, arch arm64-v8a
11-12 18:31:53.640 I/MMKV ( 2518): MMKV.cpp:177::initialize armv8 AES instructions is supported
11-12 18:31:53.640 I/MMKV ( 2518): MMKV.cpp:185::initialize armv8 CRC32 instructions is supported
11-12 18:31:53.640 I/MMKV ( 2518): MMKV.cpp:225::initializeMMKV root dir: /mnt/sdcard/
11-12 18:31:53.640 I/MMKV ( 2518): MemoryFile.cpp:98::open open fd[0x23], /mnt/sdcard//osds
11-12 18:31:53.640 I/MMKV ( 2518): MemoryFile.cpp:203::mmap mmap to address [0x79797e6000], oldPtr [0x0], [/mnt/sdcard//osds]
11-12 18:31:53.640 I/MMKV ( 2518): MemoryFile.cpp:98::open open fd[0x24], /mnt/sdcard//osds.crc
11-12 18:31:53.640 I/MMKV ( 2518): MemoryFile.cpp:203::mmap mmap to address [0x79557a3000], oldPtr [0x0], [/mnt/sdcard//osds.crc]
11-12 18:31:53.641 I/MMKV ( 2518): <MMKV_IO.cpp:214::loadMetaInfoAndCheck> meta file [osds] has flag [0]
11-12 18:31:53.641 I/MMKV ( 2518): <MMKV_IO.cpp:84::loadFromFile> loading [osds] with 2398 actual size, file size 4096, InterProcess 0, meta info version:4
11-12 18:31:53.641 I/MMKV ( 2518): <MMKV_IO.cpp:89::loadFromFile> loading [osds] with crc 3049731699 sequence 27 version 4
11-12 18:31:53.641 I/MMKV ( 2518): <MMKV_IO.cpp:133::loadFromFile> loaded [osds] with 81 key-values
11-12 18:31:54.423 I/MMKV ( 2593): current API level = 25, libc++_shared=0
11-12 18:31:54.423 I/MMKV ( 2593): MMKV.cpp:166::initialize version v1.3.9, page size 4096, arch arm64-v8a
11-12 18:31:54.424 I/MMKV ( 2593): MMKV.cpp:177::initialize armv8 AES instructions is supported
11-12 18:31:54.424 I/MMKV ( 2593): MMKV.cpp:185::initialize armv8 CRC32 instructions is supported
11-12 18:31:54.424 I/MMKV ( 2593): MMKV.cpp:225::initializeMMKV root dir: /mnt/sdcard/
11-12 18:31:54.424 I/MMKV ( 2593): MemoryFile.cpp:98::open open fd[0x23], /mnt/sdcard//osds
11-12 18:31:54.424 I/MMKV ( 2593): MemoryFile.cpp:203::mmap mmap to address [0x79592da000], oldPtr [0x0], [/mnt/sdcard//osds]
11-12 18:31:54.425 I/MMKV ( 2593): MemoryFile.cpp:98::open open fd[0x24], /mnt/sdcard//osds.crc
11-12 18:31:54.425 I/MMKV ( 2593): MemoryFile.cpp:203::mmap mmap to address [0x795559b000], oldPtr [0x0], [/mnt/sdcard//osds.crc]
11-12 18:31:54.426 I/MMKV ( 2593): <MMKV_IO.cpp:214::loadMetaInfoAndCheck> meta file [osds] has flag [0]
11-12 18:31:54.426 I/MMKV ( 2593): <MMKV_IO.cpp:84::loadFromFile> loading [osds] with 2544 actual size, file size 4096, InterProcess 0, meta info version:4
11-12 18:31:54.426 I/MMKV ( 2593): <MMKV_IO.cpp:89::loadFromFile> loading [osds] with crc 2870570006 sequence 27 version 4
11-12 18:31:54.426 I/MMKV ( 2593): <MMKV_IO.cpp:133::loadFromFile> loaded [osds] with 81 key-values
11-12 18:31:54.718 I/MMKV ( 2518): MMKV.cpp:1263::backupOneToDirectory backup one cached mmkv[osds] from [/mnt/sdcard//osds] to [/data/user/0/com.brawin.brplay/files/mmkvbackup/osds]
11-12 18:31:54.718 I/MMKV ( 2518): MMKV.cpp:1174::sync MMKV::sync, SyncFlag = 1
11-12 18:31:54.726 I/MMKV ( 2518): MemoryFile.cpp:98::open open fd[0x5a], /mnt/sdcard//osds
11-12 18:31:54.726 I/MMKV ( 2518): <MemoryFile_Linux.cpp:118::copyFileContent> copy content from /mnt/sdcard//osds to fd[89] finish
11-12 18:31:54.726 I/MMKV ( 2518): MemoryFile.cpp:104::close closing fd[0x5a], /mnt/sdcard//osds
11-12 18:31:54.726 I/MMKV ( 2518): MemoryFile.cpp:507::copyFile copyfile [/mnt/sdcard//osds] to [/mnt/sdcard//.tmp/MMKV.D5zUMK]
11-12 18:31:54.726 W/MMKV ( 2518): <MemoryFile_Linux.cpp:65::tryAtomicRename> fail on renameat2() [/mnt/sdcard//.tmp/MMKV.D5zUMK] to [/data/user/0/com.brawin.brplay/files/mmkvbackup/osds], 88(Socket operation on non-socket)
11-12 18:31:54.726 W/MMKV ( 2518): <MemoryFile_Linux.cpp:73::tryAtomicRename> fail on syscall(SYS_renameat2) [/mnt/sdcard//.tmp/MMKV.D5zUMK] to [/data/user/0/com.brawin.brplay/files/mmkvbackup/osds], 18(Cross-device link)
11-12 18:31:54.727 E/MMKV ( 2518): <MemoryFile_Linux.cpp:79::tryAtomicRename> fail to rename [/mnt/sdcard//.tmp/MMKV.D5zUMK] to [/data/user/0/com.brawin.brplay/files/mmkvbackup/osds], 18(Cross-device link)
11-12 18:31:54.728 I/MMKV ( 2518): MMKV.cpp:1274::backupOneToDirectory finish backup one mmkv[osds], ret: 0

@lingol
Copy link
Collaborator

lingol commented Nov 12, 2024

There's some logic on handling opened MMKV files that don't handle failure on rename() correctly on cross-device operation.
Try do it on the same storage device.

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

No branches or pull requests

2 participants