Skip to content

Commit

Permalink
[BugFix] Fix incorrect materialized view row count
Browse files Browse the repository at this point in the history
Signed-off-by: kaijian.ding <[email protected]>
  • Loading branch information
kaijianding committed Oct 15, 2024
1 parent d69a058 commit 6fa0683
Showing 1 changed file with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.starrocks.catalog.MaterializedIndex.IndexExtState;
import com.starrocks.common.Config;
import com.starrocks.common.util.FrontendDaemon;
Expand Down Expand Up @@ -116,7 +115,6 @@ protected void runAfterCatalogReady() {

// NOTE: calculate the row first with read lock, then update the stats with write lock
locker.lockTableWithIntensiveDbLock(db.getId(), table.getId(), LockType.READ);
Map<Long, Long> indexRowCountMap = Maps.newHashMap();
try {
OlapTable olapTable = (OlapTable) table;
for (Partition partition : olapTable.getAllPartitions()) {
Expand All @@ -129,7 +127,7 @@ protected void runAfterCatalogReady() {
for (Tablet tablet : index.getTablets()) {
indexRowCount += tablet.getRowCount(version);
} // end for tablets
indexRowCountMap.put(index.getId(), indexRowCount);
index.setRowCount(indexRowCount);
if (!olapTable.isTempPartition(partition.getId())) {
totalRowCount += indexRowCount;
}
Expand All @@ -145,18 +143,6 @@ protected void runAfterCatalogReady() {
// update
locker.lockTableWithIntensiveDbLock(db.getId(), table.getId(), LockType.WRITE);
try {
OlapTable olapTable = (OlapTable) table;
for (Partition partition : olapTable.getAllPartitions()) {
for (PhysicalPartition physicalPartition : partition.getSubPartitions()) {
for (MaterializedIndex index :
physicalPartition.getMaterializedIndices(IndexExtState.VISIBLE)) {
Long indexRowCount = indexRowCountMap.get(index.getId());
if (indexRowCount != null) {
index.setRowCount(indexRowCount);
}
}
}
}
adjustStatUpdateRows(table.getId(), totalRowCount);
} finally {
locker.unLockTableWithIntensiveDbLock(db.getId(), table.getId(), LockType.WRITE);
Expand Down

0 comments on commit 6fa0683

Please sign in to comment.