Skip to content
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

Add upgrade() to Admin API #1204

Merged
merged 5 commits into from
Oct 23, 2023
Merged

Add upgrade() to Admin API #1204

merged 5 commits into from
Oct 23, 2023

Conversation

Torch3333
Copy link
Contributor

@Torch3333 Torch3333 commented Oct 18, 2023

Description

Considering we have the two following requirement:

  1. As a ScalarDB user, I want to be able to upgrade my ScalarDB environment (schema metadata and coordinator table) to support backward incompatible changes introduced by a new version.
  2. As a ScalarDB user, I want to be able to upgrade my ScalarDB environment to support backward incompatible changes introduced by the namespace management feature.

To address story 2 while also being able to address the more general story 1 for future work, we choose a generic API name, upgrade(). Currently, this method will only address the need to upgrade the environment because of the namespace management feature, but we can append new behaviors anytime to handle new features that break the backward compatibility of the environment.

Related issues and/or PRs

Changes made

Add a new void upgrade(Map<String, String> options) method to the Admin API, which will create the namespace metadata table and create metadata for the existing namespace.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

  • A new --upgrade command will be added to the Schema Loader in another PR
  • The documentation will be updated in another PR.
  • upgrade() is not supported in the ScalarDB Server and JDBC Transaction Admin since these two components will be deleted before the 4.0.0 release.

Release notes

Added a new method, void upgrade(Map<String,String> options), to the Admin API. Running this method when updating an existing environment to ScalarDB 4.X is necessary to support backward incompatible changes introduced by the new "namespaces management" feature.

@Torch3333 Torch3333 self-assigned this Oct 18, 2023
@Torch3333 Torch3333 added the enhancement New feature or request label Oct 18, 2023
@Torch3333 Torch3333 changed the base branch from master to repair_namespace October 18, 2023 14:52
Base automatically changed from repair_namespace to master October 19, 2023 00:00
Comment on lines 435 to 443
/**
* Upgrades the Scalar DB environment to support the latest version of the Scalar DB API.
* Typically, you will be requested, as indicated on the release notes, to run this method after
* updating the Scalar DB version of your application environment.
*
* @param options options to upgrade
* @throws ExecutionException if the operation fails
*/
void upgrade(Map<String, String> options) throws ExecutionException;
Copy link
Contributor Author

@Torch3333 Torch3333 Oct 19, 2023

Choose a reason for hiding this comment

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

The new upgrade() Admin API.

@@ -406,6 +406,26 @@ public Set<String> getNamespaceNames() throws ExecutionException {
}
}

@Override
public void upgrade(Map<String, String> options) throws ExecutionException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upgrade() implementation of the CassandraAdmin

@@ -647,6 +647,33 @@ public Set<String> getNamespaceNames() throws ExecutionException {
}
}

@Override
public void upgrade(Map<String, String> options) throws ExecutionException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upgrade() implementation of the CosmosAdmin

@@ -1363,6 +1363,50 @@ public Set<String> getNamespaceNames() throws ExecutionException {
}
}

@Override
public void upgrade(Map<String, String> options) throws ExecutionException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upgrade() implementation of the DynamoAdmin

@@ -1008,4 +1013,39 @@ private boolean isNamespacesTableEmpty(Connection connection) throws SQLExceptio
return !results.next();
}
}

@Override
public void upgrade(Map<String, String> options) throws ExecutionException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upgrade() implementation of the JdbcAdmin

@Torch3333 Torch3333 changed the title Add upgrade to Admin API Add upgrade method to Admin API Oct 19, 2023
@Torch3333 Torch3333 changed the title Add upgrade method to Admin API Add upgrade() to Admin API Oct 19, 2023
@Torch3333 Torch3333 marked this pull request as ready for review October 19, 2023 01:06
@Torch3333 Torch3333 requested review from a team, komamitsu, brfrn169 and feeblefakie and removed request for a team October 19, 2023 01:06
Copy link
Collaborator

@brfrn169 brfrn169 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

core/src/main/java/com/scalar/db/api/Admin.java Outdated Show resolved Hide resolved
core/src/main/java/com/scalar/db/api/Admin.java Outdated Show resolved Hide resolved
public void upgrade(Map<String, String> options) throws ExecutionException {
try {
if (!tableMetadataContainerExists()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just quick silly questions.

  • It's impossible to create the table metadata container if not exists?
  • If not possible, don't need to throw an exception?

Copy link
Contributor Author

@Torch3333 Torch3333 Oct 19, 2023

Choose a reason for hiding this comment

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

There may be a misunderstanding here.
This check verifies if the table metadata container does not exist, if true this means there is no table installed, so there is no namespace to import to the namespaces metadata table.
A limitation is that if there was a namespace that did not contain a ScalarDB-managed table, we wouldn't import it to the namespace table. It's because we assume such namespace are the storage system namespaces or are user-one but not used for ScalarDB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this answer your question ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you! Understood 👍

@Override
public void upgrade(Map<String, String> options) throws ExecutionException {
if (!metadataTableExists()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar question to the above one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My answer is the same as #1204 (comment)

Co-authored-by: Mitsunori Komatsu <komamitsu@gmail.com>
@Torch3333 Torch3333 requested a review from komamitsu October 19, 2023 03:54
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

public void upgrade(Map<String, String> options) throws ExecutionException {
try {
if (!tableMetadataContainerExists()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you! Understood 👍

@Torch3333
Copy link
Contributor Author

I pushed a fix for missing @Override annotation on some methods.
5879099

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@feeblefakie feeblefakie merged commit 3e4b05b into master Oct 23, 2023
23 checks passed
@feeblefakie feeblefakie deleted the add_upgrade branch October 23, 2023 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants