Skip to content

Commit f21e190

Browse files
committed
Use DB version to control 32/64-bit ownership format
1 parent d820353 commit f21e190

2 files changed

Lines changed: 7 additions & 39 deletions

File tree

glean/db/Glean/Database/Storage.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ import Glean.Types (PredicateStats, Repo, SchemaId)
3434

3535
-- | List of binary representation versions we can read
3636
readableVersions :: [DBVersion]
37-
readableVersions = [DBVersion 3]
37+
readableVersions = [DBVersion 3, DBVersion 4]
3838

3939
-- | List of binary representation versions we can write
4040
writableVersions :: [DBVersion]
41-
writableVersions = [DBVersion 3]
41+
writableVersions = [DBVersion 3, DBVersion 4]
4242

4343
-- | Check whether we can open a particular database version
4444
canOpenVersion :: Mode -> DBVersion -> Bool
@@ -51,7 +51,7 @@ canOpenVersion mode version = version `elem` versions
5151

5252
-- | Default current binary representation version
5353
currentVersion :: DBVersion
54-
currentVersion = maximum writableVersions
54+
currentVersion = DBVersion 3 -- update to 4 later
5555

5656
-- Choose which schema goes into a newly created DB
5757
data CreateSchema

glean/rocksdb/database-impl.cpp

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
#include "glean/rts/timer.h"
1313

14-
#ifndef OSS
15-
#include "justknobs/JustKnobProxy.h"
16-
#endif
17-
1814
namespace facebook {
1915
namespace glean {
2016
namespace rocks {
@@ -29,7 +25,6 @@ const char* admin_names[] = {
2925
"FIRST_UNIT_ID",
3026
"NEXT_UNIT_ID",
3127
"ORPHAN_FACTS",
32-
"OWNERSHIP_FORMAT_VERSION",
3328
};
3429

3530
namespace {
@@ -150,37 +145,10 @@ DatabaseImpl::DatabaseImpl(
150145
rts::error("unexpected database version {}", db_version);
151146
}
152147

153-
// Initialize ownership format version
154-
// For new DBs: Check JustKnob to decide whether to use 64-bit or 32-bit
155-
// format. For existing DBs: if no version marker exists, assume 32-bit format
156-
// Both formats are always readable regardless of gatekeeper value
157-
if (container_.mode == Mode::Create) {
158-
// New DB: check JustKnob to determine format
159-
#ifndef OSS
160-
static facebook::jk::BooleanKnob use64BitOwnership(
161-
"glean/ownership:64_bit_ids");
162-
uint32_t format_to_use = use64BitOwnership()
163-
? OWNERSHIP_FORMAT_VERSION_64BIT
164-
: OWNERSHIP_FORMAT_VERSION_32BIT;
165-
#else
166-
// OSS builds always use 32-bit format for now
167-
uint32_t format_to_use = OWNERSHIP_FORMAT_VERSION_32BIT;
168-
#endif
169-
ownership_format_version = static_cast<uint32_t>(initAdminValue(
170-
container_,
171-
AdminId::OWNERSHIP_FORMAT_VERSION,
172-
static_cast<uint64_t>(format_to_use),
173-
true, // write
174-
[] {}));
175-
} else {
176-
// Existing DB: read format version, default to 32-bit if not present
177-
ownership_format_version = static_cast<uint32_t>(initAdminValue(
178-
container_,
179-
AdminId::OWNERSHIP_FORMAT_VERSION,
180-
static_cast<uint64_t>(OWNERSHIP_FORMAT_VERSION_32BIT),
181-
false, // don't write
182-
[] {}));
183-
}
148+
ownership_format_version =
149+
version == 3
150+
? OWNERSHIP_FORMAT_VERSION_32BIT
151+
: OWNERSHIP_FORMAT_VERSION_64BIT;
184152

185153
VLOG(1) << folly::sformat(
186154
"ownership_format_version: {} ({})",

0 commit comments

Comments
 (0)