[fix](meta) fix concurrent modification exception and potential NPE (#17602)
This commit is contained in:
@ -27,14 +27,12 @@ import org.apache.doris.thrift.TDescriptorTable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -185,7 +183,7 @@ public class DescriptorTable {
|
||||
|
||||
public TDescriptorTable toThrift() {
|
||||
TDescriptorTable result = new TDescriptorTable();
|
||||
HashSet<TableIf> referencedTbls = Sets.newHashSet();
|
||||
Map<Long, TableIf> referencedTbls = Maps.newHashMap();
|
||||
for (TupleDescriptor tupleD : tupleDescs.values()) {
|
||||
// inline view of a non-constant select has a non-materialized tuple descriptor
|
||||
// in the descriptor table just for type checking, which we need to skip
|
||||
@ -195,7 +193,7 @@ public class DescriptorTable {
|
||||
// but its table has no id
|
||||
if (tupleD.getTable() != null
|
||||
&& tupleD.getTable().getId() >= 0) {
|
||||
referencedTbls.add(tupleD.getTable());
|
||||
referencedTbls.put(tupleD.getTable().getId(), tupleD.getTable());
|
||||
}
|
||||
for (SlotDescriptor slotD : tupleD.getMaterializedSlots()) {
|
||||
result.addToSlotDescriptors(slotD.toThrift());
|
||||
@ -203,9 +201,11 @@ public class DescriptorTable {
|
||||
}
|
||||
}
|
||||
|
||||
referencedTbls.addAll(referencedTables);
|
||||
for (TableIf tbl : referencedTables) {
|
||||
referencedTbls.put(tbl.getId(), tbl);
|
||||
}
|
||||
|
||||
for (TableIf tbl : referencedTbls) {
|
||||
for (TableIf tbl : referencedTbls.values()) {
|
||||
result.addToTableDescriptors(tbl.toThrift());
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -335,11 +335,24 @@ public class GlobalTransactionMgr implements Writable {
|
||||
return !dbTransactionMgr.getCommittedTxnList().isEmpty();
|
||||
}
|
||||
|
||||
for (TransactionState transactionState : dbTransactionMgr.getCommittedTxnList()) {
|
||||
List<TransactionState> committedTxnList = dbTransactionMgr.getCommittedTxnList();
|
||||
for (TransactionState transactionState : committedTxnList) {
|
||||
if (transactionState.getTableIdList().contains(tableId)) {
|
||||
if (partitionId == null) {
|
||||
return true;
|
||||
} else if (transactionState.getTableCommitInfo(tableId).getPartitionCommitInfo(partitionId) != null) {
|
||||
}
|
||||
TableCommitInfo tableCommitInfo = transactionState.getTableCommitInfo(tableId);
|
||||
if (tableCommitInfo == null) {
|
||||
// FIXME: this is a bug, should not happen
|
||||
// If table id is in transaction state's table list, and it is COMMITTED,
|
||||
// table commit info should not be null.
|
||||
// return true to avoid following process.
|
||||
LOG.warn("unexpected error. tableCommitInfo is null. dbId: {} tableId: {}, partitionId: {},"
|
||||
+ " transactionState: {}",
|
||||
dbId, tableId, partitionId, transactionState);
|
||||
return true;
|
||||
}
|
||||
if (tableCommitInfo.getPartitionCommitInfo(partitionId) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user