timothyw553 commented on code in PR #19263:
URL: https://github.com/apache/iceberg/pull/19263#discussion_r4795112169
##########
core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java:
##########
@@ -309,18 +311,38 @@ protected CommitStatus checkCommitStatus(String
newMetadataLocation, TableMetada
* may indicate the commit has failed but are not proof that this is the
case. Past locations must
* also be searched on the chance that a second committer was able to
successfully commit on top
* of our commit. When the {@code newMetadataLocation} is not found, the
method returns {@link
- * CommitStatus#FAILURE}.
+ * CommitStatus#FAILURE} while the location that {@code metadata} was built
on is still current or
+ * in the metadata log, and {@link CommitStatus#UNKNOWN} otherwise, because
later commits may have
+ * trimmed the new location from the log.
*
* @param newMetadataLocation the path of the new commit file
- * @param config metadata to use for configuration
+ * @param metadata the metadata being committed
* @return Commit Status of Success, Failure or Unknown
*/
- protected CommitStatus checkCommitStatusStrict(String newMetadataLocation,
TableMetadata config) {
- return checkCommitStatusStrict(
- tableName(),
- newMetadataLocation,
- config.properties(),
- () -> checkCurrentMetadataLocation(newMetadataLocation));
+ protected CommitStatus checkCommitStatusStrict(
+ String newMetadataLocation, TableMetadata metadata) {
+ CommitStatus status =
+ checkCommitStatusStrict(
+ tableName(),
+ newMetadataLocation,
+ metadata.properties(),
+ () -> checkCurrentMetadataLocation(newMetadataLocation));
+ List<MetadataLogEntry> previousFiles = metadata.previousFiles();
+ if (status == CommitStatus.FAILURE && !previousFiles.isEmpty()) {
+ String previousFileLocation = previousFiles.get(previousFiles.size() -
1).file();
Review Comment:
is `previousFiles.get(previousFiles.size() - 1)` always the base that the
conditional update actually checked? in a replacement transaction, refreshing
the base updates `currentMetadataLocation()` without rebuilding `metadata`, so
if another commit advances the table past that stale entry, checking it could
return `CommitStatus.UNKNOWN` on a normal retryable conflict. could we capture
`currentMetadataLocation()` before the status check and check (and log) that
instead, which also covers the empty `previousFiles()` case?
```diff
+ String baseLocation = currentMetadataLocation();
CommitStatus status =
checkCommitStatusStrict(
tableName(),
newMetadataLocation,
metadata.properties(),
() -> checkCurrentMetadataLocation(newMetadataLocation));
- List<MetadataLogEntry> previousFiles = metadata.previousFiles();
- if (status == CommitStatus.FAILURE && !previousFiles.isEmpty()) {
- String previousFileLocation = previousFiles.get(previousFiles.size()
- 1).file();
+ if (status == CommitStatus.FAILURE && baseLocation != null) {
TableMetadata current = current();
- if (current == null || !isCurrentOrPreviousLocation(current,
previousFileLocation)) {
+ if (current == null || !isCurrentOrPreviousLocation(current,
baseLocation)) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]