rpuch commented on code in PR #6810:
URL: https://github.com/apache/ignite-3/pull/6810#discussion_r2448116796
##########
modules/index/src/main/java/org/apache/ignite/internal/index/IndexBuildTask.java:
##########
@@ -236,27 +257,68 @@ private CompletableFuture<Void> handleNextBatch() {
}
}
- private List<RowId> createBatchRowIds() {
+ private CompletableFuture<BatchToIndex> createBatchToIndex() {
RowId nextRowIdToBuild = indexStorage.getNextRowIdToBuild();
- List<RowId> batch = new ArrayList<>(batchSize);
+ List<RowId> rowIds = new ArrayList<>(batchSize);
+ Map<UUID, CommitPartitionId> transactionsToResolve = new HashMap<>();
- for (int i = 0; i < batchSize && nextRowIdToBuild != null; i++) {
- nextRowIdToBuild = partitionStorage.closestRowId(nextRowIdToBuild);
+ while (rowIds.size() < batchSize && nextRowIdToBuild != null) {
+ @Nullable RowMeta row =
partitionStorage.closestRow(nextRowIdToBuild);
- if (nextRowIdToBuild == null) {
+ if (row == null) {
break;
}
- batch.add(nextRowIdToBuild);
+ rowIds.add(row.rowId());
+
+ if (row.isWriteIntent()) {
+ UUID transactionId = row.transactionId();
+ assert transactionId != null;
+
+ // We only care about transactions which began after index
creation.
+ if
(TransactionIds.beginTimestamp(transactionId).compareTo(indexCreationActivationTs)
< 0) {
+ transactionsToResolve.put(
+ row.transactionId(),
+ new CommitPartitionId(row.commitTableOrZoneId(),
row.commitPartitionId())
+ );
+ }
+ }
- nextRowIdToBuild = nextRowIdToBuild.increment();
+ nextRowIdToBuild = row.rowId().increment();
}
- return batch;
+ Map<UUID, CompletableFuture<TxState>> txStateResolveFutures =
transactionsToResolve.entrySet().stream()
+ .map(entry -> Map.entry(entry.getKey(),
resolveFinalTxStateIfNeeded(entry.getKey(), entry.getValue())))
Review Comment:
It reads from the same partition, but write intents in this partition will
generally belong to different transactions, and each transaction may have its
own commit partition
--
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]