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

[admin] Add create_time to database and table metadata. #289

Merged
merged 3 commits into from
Jan 18, 2025

Conversation

loserwang1024
Copy link
Collaborator

Purpose

Linked issue: close #281

/** Get the database in ZK. */
public Optional<DatabaseRegistration> getDatabase(String database) throws Exception {
Optional<byte[]> bytes = getOrEmpty(DatabaseZNode.path(database));
return bytes.map(DatabaseZNode::decode);
Copy link
Member

Choose a reason for hiding this comment

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

  1. we should add a unit test in ZooKeeperClientTest that getDatabase from a legacy node. this may throw a json parse exception.
  2. we can try catch the parse exception and return a default DatabaseRegistration with the created_time and modified_time extracted from `zkClient.checkExists().forPath(path).getCtime()/.getMtime()``.
  3. add the same unit test for getTable as well.
  4. decode legacy table node will not throw parse exception but with -1 time, we can check if it is -1 time, and get the created_time and modified_time extracted from zkClient.checkExists().forPath(path).getCtime()/.getMtime().

Copy link
Collaborator Author

@loserwang1024 loserwang1024 Jan 7, 2025

Choose a reason for hiding this comment

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

we can try catch the parse exception and return a default DatabaseRegistration with the created_time and modified_time extracted from `zkClient.checkExists().forPath(path).getCtime()/.getMtime()``.

I have considered it because it will be more easier, but the meta data will be bounded to zookeeper. It maybe easy now, but will be tricky if we remove the zookeeper later. @wuchong , WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

This is a backward-compatibility, in the past, we only support zookeeper metastore. The standard support of created_time/modified_time is your current implementation (adding additional properties in serialized data).

*
* <p>Table properties are controlled by Fluss and will change the behavior of the table.
*/
public <T> Builder property(ConfigOption<T> configOption, T value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this method can be removed since we don't have any pre-defined ConfigOption for database...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I will modify property as customProperty which Jark Wu has addvised.

@loserwang1024 loserwang1024 force-pushed the create_time branch 2 times, most recently from 033073b to 2c01767 Compare January 9, 2025 12:09
@loserwang1024
Copy link
Collaborator Author

@wuchong @luoyuxia , CC

@wuchong
Copy link
Member

wuchong commented Jan 15, 2025

#312 is introducing a compatibility breaking change which requires all the tables to be re-created. So v0.6 is not a compatible version.

How about making modified_time and created_time required in this PR to simplify the compatible logic? Currently, many code still create TableInfo with -1 createdTime and modifiedTime which is not correct and may introduce future bugs. If they are required, we can fix them together.

@wuchong
Copy link
Member

wuchong commented Jan 18, 2025

Please do not squash commits even if it is a big change.

@@ -79,20 +96,18 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(tablePath, tableDescriptor, tableId, schemaId);
return Objects.hash(tablePath, tableDescriptor, tableId, schemaId, createdTime, modifiedTime);
Copy link
Member

Choose a reason for hiding this comment

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

remove createdTime, modifiedTime from hashCode() if they are not compared in equals().

r.getSchemaId()));
r.getSchemaId(),
r.hasCreatedTime() ? r.getCreatedTime() : -1,
r.hasModifiedTime() ? r.getModifiedTime() : -1));
Copy link
Member

Choose a reason for hiding this comment

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

they are required fields now, no need to check hasXxx()

tableDescriptor.getCustomProperties());
tableDescriptor.getCustomProperties(),
System.currentTimeMillis(),
System.currentTimeMillis());
Copy link
Member

Choose a reason for hiding this comment

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

We should use a same time for them when creation.

@wuchong
Copy link
Member

wuchong commented Jan 18, 2025

I pushed a commit to fix the problems.

@wuchong wuchong merged commit 290d4a6 into alibaba:main Jan 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add create_time to database and table metadata.
3 participants