-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add concurrent writes reconciliation for blind append INSERT operations
Allow committing blind append INSERT operations in a concurrent context by placing these operations right after any other previously concurrently completed write operations. Disallow committing blind insert operations in any of the following cases: - table schema change has been committed in the meantime - table protocol change has been committed in the meantime INSERT operations that contain subqueries reading the same table are subject to concurrent write failures.
- Loading branch information
1 parent
916af43
commit efe6102
Showing
11 changed files
with
638 additions
and
27 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeCommitSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.deltalake; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import io.trino.plugin.deltalake.transactionlog.CommitInfoEntry; | ||
import io.trino.plugin.deltalake.transactionlog.DeltaLakeTransactionLogEntry; | ||
import io.trino.plugin.deltalake.transactionlog.MetadataEntry; | ||
import io.trino.plugin.deltalake.transactionlog.ProtocolEntry; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class DeltaLakeCommitSummary | ||
{ | ||
private final List<MetadataEntry> metadataUpdates; | ||
private final Optional<ProtocolEntry> protocol; | ||
private final Optional<Boolean> isBlindAppend; | ||
|
||
public DeltaLakeCommitSummary(List<DeltaLakeTransactionLogEntry> transactionLogEntries) | ||
{ | ||
requireNonNull(transactionLogEntries, "transactionLogEntries is null"); | ||
ImmutableList.Builder<MetadataEntry> metadataUpdatesBuilder = ImmutableList.builder(); | ||
Optional<ProtocolEntry> optionalProtocol = Optional.empty(); | ||
Optional<CommitInfoEntry> optionalCommitInfo = Optional.empty(); | ||
|
||
for (DeltaLakeTransactionLogEntry transactionLogEntry : transactionLogEntries) { | ||
if (transactionLogEntry.getMetaData() != null) { | ||
metadataUpdatesBuilder.add(transactionLogEntry.getMetaData()); | ||
} | ||
else if (transactionLogEntry.getProtocol() != null) { | ||
optionalProtocol = Optional.of(transactionLogEntry.getProtocol()); | ||
} | ||
else if (transactionLogEntry.getCommitInfo() != null) { | ||
optionalCommitInfo = Optional.of(transactionLogEntry.getCommitInfo()); | ||
} | ||
} | ||
|
||
metadataUpdates = metadataUpdatesBuilder.build(); | ||
protocol = optionalProtocol; | ||
isBlindAppend = optionalCommitInfo.flatMap(CommitInfoEntry::isBlindAppend); | ||
} | ||
|
||
public List<MetadataEntry> getMetadataUpdates() | ||
{ | ||
return metadataUpdates; | ||
} | ||
|
||
public Optional<ProtocolEntry> getProtocol() | ||
{ | ||
return protocol; | ||
} | ||
|
||
public Optional<Boolean> getIsBlindAppend() | ||
{ | ||
return isBlindAppend; | ||
} | ||
} |
152 changes: 125 additions & 27 deletions
152
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...main/java/io/trino/plugin/deltalake/transactionlog/writer/TransactionFailedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.plugin.deltalake.transactionlog.writer; | ||
|
||
/** | ||
* Exception thrown to point out that other transaction log files | ||
* have been created during the time on which the current transaction | ||
* has been executing and their already committed changes are in | ||
* irremediable conflict with the changes from the current transaction. | ||
*/ | ||
public class TransactionFailedException | ||
extends RuntimeException | ||
{ | ||
public TransactionFailedException(String message) | ||
{ | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.