You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "Cpaulyz (via GitHub)" <gi...@apache.org> on 2023/04/13 02:13:38 UTC
[GitHub] [iotdb] Cpaulyz commented on a diff in pull request #9602: [To rel/1.1] Fix SchemaEngine memory control concurrent bug
Cpaulyz commented on code in PR #9602:
URL: https://github.com/apache/iotdb/pull/9602#discussion_r1164894116
##########
server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java:
##########
@@ -69,19 +69,27 @@ public long getMemoryUsage() {
public void requestMemory(long size) {
memoryUsage.addAndGet(size);
if (memoryUsage.get() >= memoryCapacity) {
- logger.warn("Current series memory {} is too large...", memoryUsage);
- allowToCreateNewSeries = false;
+ synchronized (this) {
Review Comment:
The same
##########
server/src/main/java/org/apache/iotdb/db/metadata/rescon/MemSchemaEngineStatistics.java:
##########
@@ -69,19 +69,27 @@ public long getMemoryUsage() {
public void requestMemory(long size) {
memoryUsage.addAndGet(size);
if (memoryUsage.get() >= memoryCapacity) {
- logger.warn("Current series memory {} is too large...", memoryUsage);
- allowToCreateNewSeries = false;
+ synchronized (this) {
+ if (allowToCreateNewSeries && memoryUsage.get() >= memoryCapacity) {
+ logger.warn("Current series memory {} is too large...", memoryUsage);
+ allowToCreateNewSeries = false;
+ }
+ }
}
}
public void releaseMemory(long size) {
memoryUsage.addAndGet(-size);
- if (!allowToCreateNewSeries && memoryUsage.get() < memoryCapacity) {
- logger.info(
- "Current series memory {} come back to normal level, total series number is {}.",
- memoryUsage,
- totalSeriesNumber);
- allowToCreateNewSeries = true;
+ if (memoryUsage.get() < memoryCapacity) {
+ synchronized (this) {
Review Comment:
```suggestion
synchronized (allowToCreateNewSeriesLock) {
```
It is better to use a new object rather than this
--
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: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org