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

rgw/sfs: change db schema as described in ADR. #150

Merged
merged 3 commits into from
May 18, 2023

Conversation

0xavi0
Copy link

@0xavi0 0xavi0 commented May 16, 2023

Changes the db schema following this ADR.

It deletes repeated fields that we had in objects vs versioned_objects tables and creates new fields in the versioned_objects table.

Logic of sfs was intentionally not updated in this PR. (For example new field version_type is added to the schema, but still not used).
Updates in logic, specially in versioning logic, will come in a future PR.

New Features:

Sqliteorm type bindings for the following types.

  • uuid_d
  • ceph::real_time
  • rgw::sal::sfs::ObjetState
  • rgw::sal::sfs::VersionType

In general, any enum type that has a LAST_VALUE item assigned to the last valid value and that also starts with 0 is eligible to be binded to sqliteorm, as the type binding for enums is generic.

For example: you can create an enum like:

enum class TestEnum  {
  WHATEVER = 0,
  SOMETHING_ELSE,
  AND_THIS,
  LAST_VALUE = AND_THIS
};

and use it right away in sqliteorm.

Custom type bindings code are using exceptions because they are specialisations of sqlite_orm.

Object has no explicit conversion code

As all the types in the object table are compatible with sqliteorm we don't need extra conversion layer.
This is a preview of what we can do with the rest of database objects once BLOBS are also type bound in the future.
That was not done in this PR to avoid too many changes.

Note: The new type VersionType was added as a new file version_type.h because we are in a re-design process and I wasn't sure if it should be located in any other existing file that might be eligible to be deleted in the near future.

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

Signed-off-by: Xavi Garcia xavi.garcia@suse.com

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)

@0xavi0 0xavi0 requested review from jecluis, irq0 and giubacc May 16, 2023 14:21
@0xavi0 0xavi0 added kind/feature New functionality or support for something kind/quality Quality improvements, Refactoring, Automation via CI, E2E, Integration, CLI or REST API labels May 16, 2023
@0xavi0 0xavi0 self-assigned this May 16, 2023
@0xavi0 0xavi0 added this to the v0.17.0 milestone May 16, 2023
@0xavi0 0xavi0 force-pushed the 480-db-schema-change branch from 8e6cf59 to b726c3f Compare May 16, 2023 14:33
Changes the db schema following [this
ADR](https://github.com/aquarist-labs/s3gw/pull/497).

It also deletes repeated fields that we had in objects vs
versioned_objects tables.

Logic of `sfs` was intentionally not updated in this PR.
(For example new field `version_type` is added to the schema, but still
not used).
Updates in logic, specially in versioning logic, will come in a future
PR.

New Features:

**Sqliteorm type bindings for the following types.**
* `uuid_d`
* `ceph::real_time`
* `rgw::sal::sfs::ObjetState`
* `rgw::sal::sfs::VersionType`

In general, any enum type that has a `LAST_VALUE` item assigned to the
last valid value and that also starts with 0 is eligible to be binded to
sqliteorm, as the type binding for enums is generic.

For example: you can create an enum like:

```c++
enum class TestEnum  {
  WHATEVER = 0,
  SOMETHING_ELSE,
  AND_THIS,
  LAST_VALUE = AND_THIS
};
```
and use it right away in sqliteorm.

**Object has no explicit conversion code**
As all the types in the `object` are compatible with `sqliteorm` we
don't need extra conversion layer.
This is a preview of what we can do with the rest of database objects
once `BLOBS` are also type binded in the future.
That was not done in this PR to avoid too many changes.

Note: The new type `VersionType` was added as a new file `version_type.h`
because we are in a re-design process and I wasn't sure if it should be
located in any other existing file that might be eligible to be deleted
in the near future.

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

Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
@0xavi0 0xavi0 force-pushed the 480-db-schema-change branch from b726c3f to e805143 Compare May 16, 2023 14:40
This is so we throw the same kind of exception that all the sqliteorm
code and it's easier to catch them.

Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
irq0
irq0 previously approved these changes May 17, 2023
Copy link
Member

@irq0 irq0 left a comment

Choose a reason for hiding this comment

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

good stuff!

❤️ the type binding change

change creation -> create, deletion -> delete in versioned objects
table.

Signed-off-by: Xavi Garcia <xavi.garcia@suse.com>
@jecluis jecluis merged commit 3db8861 into aquarist-labs:s3gw May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature New functionality or support for something kind/quality Quality improvements, Refactoring, Automation via CI, E2E, Integration, CLI or REST API
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Reconcile possible duplicated columns in object and versioned object tables
3 participants