-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](fe) move some variables from Replica to LocalReplica which are not used in CloudReplica to reduce memory #59460
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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 org.apache.doris.catalog; | ||
|
|
||
| import org.apache.doris.thrift.TUniqueId; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| public class LocalReplica extends Replica { | ||
| private static final Logger LOG = LogManager.getLogger(LocalReplica.class); | ||
|
|
||
| @SerializedName(value = "rds", alternate = {"remoteDataSize"}) | ||
| private volatile long remoteDataSize = 0; | ||
| @SerializedName(value = "ris", alternate = {"remoteInvertedIndexSize"}) | ||
| private Long remoteInvertedIndexSize = 0L; | ||
| @SerializedName(value = "rss", alternate = {"remoteSegmentSize"}) | ||
| private Long remoteSegmentSize = 0L; | ||
|
|
||
| private TUniqueId cooldownMetaId; | ||
| private long cooldownTerm = -1; | ||
|
|
||
| public LocalReplica() { | ||
| super(); | ||
| } | ||
|
|
||
| public LocalReplica(ReplicaContext context) { | ||
| super(context); | ||
| } | ||
|
|
||
| // for rollup | ||
| // the new replica's version is -1 and last failed version is -1 | ||
| public LocalReplica(long replicaId, long backendId, int schemaHash, ReplicaState state) { | ||
| super(replicaId, backendId, schemaHash, state); | ||
| } | ||
|
|
||
| // for create tablet and restore | ||
| public LocalReplica(long replicaId, long backendId, ReplicaState state, long version, int schemaHash) { | ||
| super(replicaId, backendId, state, version, schemaHash); | ||
| } | ||
|
|
||
| public LocalReplica(long replicaId, long backendId, long version, int schemaHash, long dataSize, | ||
| long remoteDataSize, long rowCount, ReplicaState state, long lastFailedVersion, long lastSuccessVersion) { | ||
| super(replicaId, backendId, version, schemaHash, dataSize, remoteDataSize, rowCount, state, lastFailedVersion, | ||
| lastSuccessVersion); | ||
| this.remoteDataSize = remoteDataSize; | ||
| } | ||
|
|
||
| @Override | ||
| public long getRemoteDataSize() { | ||
| return remoteDataSize; | ||
| } | ||
|
|
||
| @Override | ||
| public void setRemoteDataSize(long remoteDataSize) { | ||
| this.remoteDataSize = remoteDataSize; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getRemoteInvertedIndexSize() { | ||
| return remoteInvertedIndexSize; | ||
| } | ||
|
|
||
| @Override | ||
| public void setRemoteInvertedIndexSize(long remoteInvertedIndexSize) { | ||
| this.remoteInvertedIndexSize = remoteInvertedIndexSize; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getRemoteSegmentSize() { | ||
| return remoteSegmentSize; | ||
| } | ||
|
|
||
| @Override | ||
| public void setRemoteSegmentSize(long remoteSegmentSize) { | ||
| this.remoteSegmentSize = remoteSegmentSize; | ||
| } | ||
|
|
||
| @Override | ||
| public TUniqueId getCooldownMetaId() { | ||
| return cooldownMetaId; | ||
| } | ||
|
|
||
| @Override | ||
| public void setCooldownMetaId(TUniqueId cooldownMetaId) { | ||
| this.cooldownMetaId = cooldownMetaId; | ||
| } | ||
|
|
||
| @Override | ||
| public long getCooldownTerm() { | ||
| return cooldownTerm; | ||
| } | ||
|
|
||
| @Override | ||
| public void setCooldownTerm(long cooldownTerm) { | ||
| this.cooldownTerm = cooldownTerm; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,8 +96,6 @@ public static class ReplicaContext { | |
| private int schemaHash = -1; | ||
| @SerializedName(value = "ds", alternate = {"dataSize"}) | ||
| private volatile long dataSize = 0; | ||
| @SerializedName(value = "rds", alternate = {"remoteDataSize"}) | ||
| private volatile long remoteDataSize = 0; | ||
| @SerializedName(value = "rc", alternate = {"rowCount"}) | ||
| private volatile long rowCount = 0; | ||
| @SerializedName(value = "st", alternate = {"state"}) | ||
|
|
@@ -120,14 +118,6 @@ public static class ReplicaContext { | |
| @Getter | ||
| @SerializedName(value = "lss", alternate = {"localSegmentSize"}) | ||
| private Long localSegmentSize = 0L; | ||
| @Setter | ||
| @Getter | ||
| @SerializedName(value = "ris", alternate = {"remoteInvertedIndexSize"}) | ||
| private Long remoteInvertedIndexSize = 0L; | ||
| @Setter | ||
| @Getter | ||
| @SerializedName(value = "rss", alternate = {"remoteSegmentSize"}) | ||
| private Long remoteSegmentSize = 0L; | ||
|
|
||
| private volatile long totalVersionCount = -1; | ||
| private volatile long visibleVersionCount = -1; | ||
|
|
@@ -137,9 +127,6 @@ public static class ReplicaContext { | |
| // bad means this Replica is unrecoverable, and we will delete it | ||
| private boolean bad = false; | ||
|
|
||
| private TUniqueId cooldownMetaId; | ||
| private long cooldownTerm = -1; | ||
|
|
||
| // A replica version should increase monotonically, | ||
| // but backend may missing some versions due to disk failure or bugs. | ||
| // FE should found these and mark the replica as missing versions. | ||
|
|
@@ -217,7 +204,6 @@ public Replica(long replicaId, long backendId, long version, int schemaHash, | |
| this.schemaHash = schemaHash; | ||
|
|
||
| this.dataSize = dataSize; | ||
| this.remoteDataSize = remoteDataSize; | ||
| this.rowCount = rowCount; | ||
| this.state = state; | ||
| if (this.state == null) { | ||
|
|
@@ -280,11 +266,33 @@ public void setDataSize(long dataSize) { | |
| } | ||
|
|
||
| public long getRemoteDataSize() { | ||
| return remoteDataSize; | ||
| return 0; | ||
| } | ||
|
|
||
| public void setRemoteDataSize(long remoteDataSize) { | ||
| this.remoteDataSize = remoteDataSize; | ||
| if (remoteDataSize > 0) { | ||
| throw new UnsupportedOperationException("setRemoteDataSize is not supported in Replica"); | ||
| } | ||
| } | ||
|
|
||
| public Long getRemoteInvertedIndexSize() { | ||
| return 0L; | ||
| } | ||
|
|
||
| public void setRemoteInvertedIndexSize(long remoteInvertedIndexSize) { | ||
| if (remoteInvertedIndexSize > 0) { | ||
| throw new UnsupportedOperationException("setRemoteInvertedIndexSize is not supported in Replica"); | ||
| } | ||
| } | ||
|
|
||
| public Long getRemoteSegmentSize() { | ||
| return 0L; | ||
| } | ||
|
|
||
| public void setRemoteSegmentSize(long remoteSegmentSize) { | ||
| if (remoteSegmentSize > 0) { | ||
| throw new UnsupportedOperationException("setRemoteSegmentSize is not supported in Replica"); | ||
| } | ||
| } | ||
|
Comment on lines
+282
to
296
|
||
|
|
||
| public long getRowCount() { | ||
|
|
@@ -344,19 +352,19 @@ public boolean setBad(boolean bad) { | |
| } | ||
|
|
||
| public TUniqueId getCooldownMetaId() { | ||
| return cooldownMetaId; | ||
| return null; | ||
| } | ||
|
|
||
| public void setCooldownMetaId(TUniqueId cooldownMetaId) { | ||
| this.cooldownMetaId = cooldownMetaId; | ||
| throw new UnsupportedOperationException("setCooldownMetaId is not supported in Replica"); | ||
| } | ||
|
|
||
| public long getCooldownTerm() { | ||
| return cooldownTerm; | ||
| return -1; | ||
| } | ||
|
|
||
| public void setCooldownTerm(long cooldownTerm) { | ||
| this.cooldownTerm = cooldownTerm; | ||
| throw new UnsupportedOperationException("setCooldownTerm is not supported in Replica"); | ||
| } | ||
|
|
||
| public boolean needFurtherRepair() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing UnsupportedOperationException in setter may break existing code paths. The setRemoteDataSize method now throws UnsupportedOperationException when value > 0, but the base class Replica has an updateWithReport method (line 414) that calls this setter. If a CloudReplica receives a tablet report with remoteDataSize > 0, this will throw an exception and break the report handling. Consider either overriding updateWithReport in subclasses or checking the replica type before calling these setters.