Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Rename database file to sfs.db #245

Merged
merged 3 commits into from
Nov 16, 2023
Merged

Conversation

irq0
Copy link
Member

@irq0 irq0 commented Nov 13, 2023

Use 'sfs.db' instead of 's3gw.db'. Rename 's3gw.db' -> 'sfs.db' if it
exists on startup.

Fixes: https://github.com/aquarist-labs/s3gw/issues/766

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

Marcel Lauhoff added 2 commits November 13, 2023 14:46
Use constants DB_FILENAME and DB_WAL_FILENAME to refer to our database
filename.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
@irq0
Copy link
Member Author

irq0 commented Nov 13, 2023

The last commit in chain has basic migration code. Happy to drop it

@@ -414,4 +416,24 @@ void DBConn::maybe_upgrade_metadata() {
}
}

void DBConn::maybe_rename_database_file() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we may also have to rename the -wal and -shm files. I think those can be left behind if the database is not properly closed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, if you killall -9 radosgw the -wal and -shm files will remain, then the next time you start it up, you'll see something like [SQLITE] (283) recovered 26 frames from WAL file /scratch/s3gw/qa/s3gw.db-wal in the log. So if we keep the migration code, we'd need to migrate those two as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, the rename code is a bit naive. Perhaps too naive. Not only do we need to rename the extra files, there may also be temporary files (according to docs) that share the basename. If the database is still open renaming is also a big mistake.

A safer option would be the backup API - I think we should rather use that

tserong
tserong previously approved these changes Nov 14, 2023
Copy link
Member

@tserong tserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm in favour of dropping the migration code and just putting a (large, bold) note in the release announcement that the DB name has changed and that existing deployments need to manually mv s3gw.db sfs.db.

@jecluis
Copy link
Member

jecluis commented Nov 14, 2023

LGTM, but I'm in favour of dropping the migration code and just putting a (large, bold) note in the release announcement that the DB name has changed and that existing deployments need to manually mv s3gw.db sfs.db.

This would not be feasible in kubernetes. Possible, yes, but asking that from the user would be annoying. We either assume their volumes are to be blown away, or we do the migration.

TBH, I'm in favor of doing the migration (it doesn't look too difficult or error prone), and we can always remove it further down the line, before GA.

But this also really depends on when we want to consider the on-disk format "stable". If only after this, then blow away; but if we think we are already there, then migration is the way to go.

@tserong
Copy link
Member

tserong commented Nov 14, 2023

TBH, I'm in favor of doing the migration (it doesn't look too difficult or error prone), and we can always remove it further down the line, before GA.

That'll work. Put the migration in now, drop it in the next release or next release +1 and expect current early adopters to remain on the train (and mention these changes in release notes as we go). I just didn't want to keep that code forever.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
@irq0
Copy link
Member Author

irq0 commented Nov 15, 2023

Last push changes the migration code to use the sqlite3 backup API

Copy link
Member

@jecluis jecluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor things, lgtm

Comment on lines +420 to +425
if (!std::filesystem::exists(getLegacyDBPath(cct))) {
return;
}
if (std::filesystem::exists(getDBPath(cct))) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could have been a single if

return db_path.string();
}

static std::string getLegacyDBPath(CephContext* cct) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be perfectly honest, I really dislike that we have this function as camelCase when all other functions are snake case. More of an itch for me than anything else.

@@ -78,7 +79,7 @@ class TestSFSWALCheckpoint : public ::testing::Test {
size_t num_threads, size_t num_objects
) {
std::atomic<std::uintmax_t> max_wal_size{0};
fs::path wal(test_dir / "s3gw.db-wal");
fs::path wal(test_dir / sqlite::DB_WAL_FILENAME);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we maybe define this as a function of DB_FILENAME, instead of having to keep a #define in the header solely for this test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would leak an sqlite implementation detail that a reader does not need to know about. I'd rather have this

@jecluis jecluis added this to the v0.23.0 milestone Nov 15, 2023
@jecluis jecluis added kind/enhancement Change that positively impacts existing code area/rgw-sfs RGW & SFS related priority/0 Needs to go into the next release or force a patch labels Nov 15, 2023
@irq0 irq0 merged commit 53aa541 into aquarist-labs:s3gw Nov 16, 2023
8 checks passed
@irq0 irq0 deleted the pr/database-file-rename branch November 16, 2023 09:47
irq0 pushed a commit to irq0/fsck.sfs that referenced this pull request Nov 16, 2023
Since aquarist-labs/ceph#245 rgw/sfs uses
'sfs.db' instead of 's3gw.db'

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/rgw-sfs RGW & SFS related kind/enhancement Change that positively impacts existing code priority/0 Needs to go into the next release or force a patch
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

rgw/sfs: rename 's3gw.db' to 'sfs.db'
3 participants