Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix incorrect materialized view row count (backport #51944) #52018

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.common.collect.Maps;
import com.starrocks.catalog.MaterializedIndex.IndexExtState;
import com.starrocks.common.Config;
import com.starrocks.common.Pair;
import com.starrocks.common.util.FrontendDaemon;
import com.starrocks.common.util.concurrent.lock.LockType;
import com.starrocks.common.util.concurrent.lock.Locker;
Expand Down Expand Up @@ -115,8 +116,7 @@ protected void runAfterCatalogReady() {
}

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