Skip to content

Commit

Permalink
Bump file format version
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Aug 12, 2024
1 parent e2f2200 commit bb126af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* None.

### Compatibility
* Fileformat: Generates files with format v24. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.
* Fileformat: Generates files with format v25. Reads and automatically upgrade from fileformat v10. If you want to upgrade from an earlier file format version you will have to use RealmCore v13.x.y or earlier.

-----------

Expand Down
7 changes: 4 additions & 3 deletions src/realm/backup_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ using VersionList = BackupHandler::VersionList;
using VersionTimeList = BackupHandler::VersionTimeList;

// Note: accepted versions should have new versions added at front
const VersionList BackupHandler::accepted_versions_ = {24, 23, 22, 21, 20, 11, 10};
const VersionList BackupHandler::accepted_versions_ = {25, 24, 23, 22, 21, 20, 11, 10};

// the pair is <version, age-in-seconds>
// we keep backup files in 3 months.
static constexpr int three_months = 3 * 31 * 24 * 60 * 60;
const VersionTimeList BackupHandler::delete_versions_{{23, three_months}, {22, three_months}, {21, three_months},
{20, three_months}, {11, three_months}, {10, three_months}};
const VersionTimeList BackupHandler::delete_versions_{{24, three_months}, {23, three_months}, {22, three_months},
{21, three_months}, {20, three_months}, {11, three_months},
{10, three_months}};


// helper functions
Expand Down
1 change: 1 addition & 0 deletions src/realm/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ int Group::read_only_version_check(SlabAlloc& alloc, ref_type top_ref, const std
case 0:
file_format_ok = (top_ref == 0);
break;
case 24:
case g_current_file_format_version:
file_format_ok = true;
break;
Expand Down
5 changes: 4 additions & 1 deletion src/realm/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,14 +764,17 @@ class Group : public ArrayParent {
/// Backlinks in BPlusTree
/// Sort order of Strings changed (affects sets and the string index)
///
/// 25 Enhanced layout of NodeHeader to support compression.
/// Integer arrays are stored in a compressed format.
///
/// IMPORTANT: When introducing a new file format version, be sure to review
/// the file validity checks in Group::open() and DB::do_open, the file
/// format selection logic in
/// Group::get_target_file_format_version_for_session(), and the file format
/// upgrade logic in Group::upgrade_file_format(), AND the lists of accepted
/// file formats and the version deletion list residing in "backup_restore.cpp"

static constexpr int g_current_file_format_version = 24;
static constexpr int g_current_file_format_version = 25;

int get_file_format_version() const noexcept;
void set_file_format_version(int) noexcept;
Expand Down
7 changes: 6 additions & 1 deletion src/realm/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void Transaction::upgrade_file_format(int target_file_format_version)
// Be sure to revisit the following upgrade logic when a new file format
// version is introduced. The following assert attempt to help you not
// forget it.
REALM_ASSERT_EX(target_file_format_version == 24, target_file_format_version);
REALM_ASSERT_EX(target_file_format_version == 25, target_file_format_version);

// DB::do_open() must ensure that only supported version are allowed.
// It does that by asking backup if the current file format version is
Expand Down Expand Up @@ -584,6 +584,11 @@ void Transaction::upgrade_file_format(int target_file_format_version)
t->migrate_col_keys();
}
}
if (current_file_format_version < 25) {
for (auto k : table_keys) {
get_table(k);
}
}
// NOTE: Additional future upgrade steps go here.
}

Expand Down

0 comments on commit bb126af

Please sign in to comment.