-
Notifications
You must be signed in to change notification settings - Fork 585
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
After initiating Compact the db.realm.tmp_compaction_space temp file is not removed #4526
Comments
@GitMurf Thanks for reporting this. Just to clarify, have you observed this behavior on both Win and Mac, or do they behave differently? |
@fronck sorry for the slow response. I tried to get my hands on a Mac to test with but wasn't able to. At this time I can only confirm this happens on Windows. Do you need me to try and find someone with a Mac to test this on or can you look into this with just the repro of Windows? Thanks much! |
@GitMurf Thanks for the update. We can try to reproduce on a Mac. |
@GitMurf I have not been able to reproduce it on a Mac. First I have generated a Realm file with the following script: const Realm = require("realm");
const KeyValueSchema = {
name: "KeyValue",
primaryKey: "key",
properties: {
key: "string",
value: "int",
},
};
const config = {
schema: [KeyValueSchema],
};
let realm = new Realm(config);
for(let i = 0; i < 100; i++) {
realm.write(() => {
realm.create(KeyValueSchema.name, { key: `__ ${i} __`, value: i });
});
}
for(let i = 0; i < 25; i++) {
realm.write(() => {
realm.delete(realm.objectForPrimaryKey(KeyValueSchema.name, `__ ${i} __`));
});
}
realm.close(); The deletions are added to the script to generate some unused free space for the compaction to remove. The compaction is done by the script: const Realm = require("realm");
const KeyValueSchema = {
name: "KeyValue",
primaryKey: "key",
properties: {
key: "string",
value: "int",
},
};
const config = {
schema: [KeyValueSchema],
shouldCompactOnLaunch: () => true,
};
let realm = new Realm(config);
realm.close(); As the following screenshot demonstrates, the initial file is larger than the compacted line but no extra files are produced: During compaction, aux. files are created. On Windows, deleting a file is not atomic. Your observation can be explained if your app was terminated while cleaning up after compaction. |
@GitMurf See also realm/realm-core#4111 |
How frequently does the bug occur?
All the time
Description
When I run either a
RealmDB.compact()
OR doshouldCompactOnLaunch
the Realm DB file compacts fine but it leaves behind thedb.realm.tmp_compaction_space
temporary file that was copied during the compaction process. The problem then is that the database size is always taking up twice as much space (as it is duplicated to the new realm db file).Should this be being deleted automatically? Is there a setting or something I need to configure to have it deleted? Do I have to delete it myself?
Stacktrace & log output
No response
Can you reproduce the bug?
Yes, always
Reproduction Steps
As the description above says, simply initiate
RealmDB.compact()
ORshouldCompactOnLaunch
. It leaves behind the copied temp database file.Version
Current
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
Windows 11 and Mac
Build environment
No response
Cocoapods version
No response
The text was updated successfully, but these errors were encountered: