-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Mixed usage of snapshotCreationTs, metadataCommitTs & tableAccessTs when using REST Catalog #11103
Comments
cc: @rdblue (since you authored the original LoadTableResponse class) This message is centered on issue 2. Summarizing the problem, when obtaining TableMetadata from LoadTableResponse, the TableMetadata is reconstructed, during which, the last-update-ms information is lost (and replaced with Code ref: There are 2 ways forward that I could think of:
Let me know if the issue and the 2 options proposed make sense. Or if there's a better way forward. Thanks! |
Why are these timestamps important? They are primarily for debugging and should not affect any correctness. |
Correct, these timestamps won't impact critical operations like commit. Functionally, only that the spark users might not obtain a correct last modified time for the latest metadata commit. The issue pops up when running this Spark integration test on REST Catalog (RESTCatalogAdapter on top of JdbcCatalog): https://github.com/apache/iceberg/blob/2240154/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMetadataTables.java#L446. This test is validating that the latest metadata commit time equal to the latest snapshot commit time (if the latest change is a new snapshot commit). Hadoop and Hive Catalog will enforce this equality, but REST Catalog will not (because no matter what The integration test above somehow indicates that there's a correctness concept on |
I realized I've been putting many thought threads that doesn't directly related to this problem, making it hard for people to read. The problem really is: the current RESTCatalog client implementation will NOT honor the The issue was discovered when running RCK REST Catalog test server on existing Spark 3.5 integration tests: #11079 |
I agree with your observation @haizhou-zhao you mentioned in your last comment. https://github.com/apache/iceberg/blob/afda8be/core/src/main/java/org/apache/iceberg/rest/responses/LoadTableResponse.java#L64 writes a new metadata log entry and also updates |
I've been talking with with @haizhou-zhao on Slack and I think this is the correct issue to look into. The REST service should update the timestamp when it writes and commits metadata using the changes sent from the client. But the REST client should not modify the timestamp that it receives from the service. I suspect this is happening when the metadata is rebuilt to add the metadata location. |
I've opened #11151 to fix this issue |
fixed by #11151 |
Apache Iceberg version
1.6.1 (latest release)
Query engine
Spark
Please describe the bug 🐞
Background
When using Spark (or likewise execution engines) on top of REST Catalog to commit a new snapshot, there are 3 critical timestamps:
SnapshotProducer
to produce a new snapshot - referred to assnapshotCreationTs
: refmetadataCommitTs
tableAccessTs
: refDesired behavior
spark.sql("SELECT * from ${db}.${table}.metadata_log_entries")
means the user is looking formetadataCommitTs
;while
spark.sql("SELECT * from ${db}.${table}.snapshots")
means the user is looking forsnapshotCreationTs
.Issue 1
Traditionally, with Hadoop and Hive Catalog, Spark (using Iceberg client) is responsible for both generating new snapshots and committing the new metadata files. And those catalogs are capable of enforcing
snapshotCreationTs
andmetadataCommitTs
to take on the exact same value for every new snapshot committed. However, with REST Catalog, because Spark only controls new snapshot generation while REST Catalog Server controls metadata commit, based on REST Catalog implementation (which is not controllable by this repo),snapshotCreationTs
andmetadataCommitTs
may or may not be the same.The current implementation in some cases assumes that the two timestamp takes on exact same value. For example, this integration test: ref.
It would be best to clarify whether a valid REST Catalog implementation should always enforce
snapshotCreationTs
andmetadataCommitTs
to take on the same value. For the current reference implementation (RESTCatalogAdapter on top of JdbcCatalog), the answer is positive (they take on the same value). However, should it be (or feasible to be) enforced for all REST Catalog implementations.Issue 2
Currently, when loading Table from REST Catalog using LoadTableResponse, the
lastUpdatedMillis
attribute of the metadata (which may be taking the value ofmetadataCommitTs
orsnapshotCreationTs
on REST Catalog side based on impl detail) will be incorrectly replaced bytableAccessTs
(ref1, ref2). Because Spark depends onlastUpdatedMillis
to generate the latestmetadataCommitTs
onmetadata_log_entries
(ref), there will always be a wrong time stamp onmetadata_log_entries
if REST Catalog is used.Willingness to contribute
The text was updated successfully, but these errors were encountered: