forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix](bloom filter) Fix bloom filter memory leak (apache#34871)
* Issue: Doris occasionally encounters an issue where memory usage becomes exceptionally high and does not decrease. The leaked memory is occupied by Bloom filters stored in memory. Reason: The segment cache stores segment objects read from files into memory. It functions as an LRU cache with an eviction strategy: when the number of segments exceeds the maximum number, or the total memory size of segment objects in the cache exceeds the maximum usage, it evicts the older segments. However, there is a piece of logic in the code that first reads the segment object into memory, assuming it occupies memory size A, then places the read segment object into the cache (at this point, the cache considers the segment object size to be A). It then reads the segment's Bloom filter from the file and assigns it to the segment's Bloom filter member variable, assuming the Bloom filter occupies memory size B. Thus, the total size of the segment object at this point is A+B. However, the cache does not update this size, leading to the actual size of the segment object stored in the cache (A+B) being larger than the size considered by the cache (A). When the number of segment objects in the cache increases to a certain extent, the used memory will surge dramatically. However, the cache does not perceive the size as reaching the eviction limit, so it does not evict the segment objects. In such cases, a memory leak issue arises. Solution: Since each segment object only reads the Bloom filter once, the issue can be resolved by changing the logic from reading the segment, placing it into the cache, and then reading the Bloom filter to reading the segment, reading the Bloom filter, and then placing it into the cache.
- Loading branch information
1 parent
0ede95b
commit cc1d148
Showing
12 changed files
with
533 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
regression-test/data/data_model_p0/unique/test_default_value.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
1 1 3 a | ||
|
||
-- !select2 -- | ||
1 1 3 \N | ||
2 2 4 \N | ||
3 3 3 {"b":"b"} | ||
|
7 changes: 7 additions & 0 deletions
7
regression-test/data/data_model_p0/unique/test_sequence_column.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
1 1 5 a | ||
|
||
-- !all -- | ||
1 1 5 a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
1 1 3 {"b":"b"} | ||
|
13 changes: 13 additions & 0 deletions
13
...n-test/data/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select_1 -- | ||
true 1 1 {"a":"a"} | ||
|
||
-- !select_2 -- | ||
true 1 1 {"b":"b"} | ||
|
||
-- !select_1 -- | ||
true 1 1 {"a":"a"} | ||
|
||
-- !select_2 -- | ||
true 1 1 {"b":"b"} | ||
|
69 changes: 69 additions & 0 deletions
69
regression-test/data/unique_with_mow_p0/test_delete_sign.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select_0 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_1 -- | ||
|
||
-- !select_2 -- | ||
|
||
-- !select_3 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_4 -- | ||
|
||
-- !select_5 -- | ||
|
||
-- !select_6 -- | ||
|
||
-- !select_7 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_8 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_9 -- | ||
true 1 30 {"b":"b"} | ||
|
||
-- !select_10 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_11 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_12 -- | ||
true 1 30 {"b":"b"} | ||
|
||
-- !select_0 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_1 -- | ||
|
||
-- !select_2 -- | ||
|
||
-- !select_3 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_4 -- | ||
|
||
-- !select_5 -- | ||
|
||
-- !select_6 -- | ||
|
||
-- !select_7 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_8 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_9 -- | ||
true 1 30 {"b":"b"} | ||
|
||
-- !select_10 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_11 -- | ||
true 1 10 {"c":"c"} | ||
|
||
-- !select_12 -- | ||
true 1 30 {"b":"b"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !select1 -- | ||
1 1 3 {"c":"c"} | ||
|
61 changes: 61 additions & 0 deletions
61
regression-test/suites/data_model_p0/unique/test_default_value.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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. | ||
|
||
suite("test_default_value") { | ||
def tableName = "test_default_value" | ||
// test default value X txn | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint default 999, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`keyword` VARCHAR(128), | ||
INDEX idx_col1 (user_id) USING INVERTED | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"replication_num" = "1" | ||
); | ||
""" | ||
sql "begin" | ||
sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" | ||
sql "commit" | ||
|
||
qt_select1 "SELECT * from ${tableName}" | ||
|
||
// test default value X variant | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`vv` variant default NULL | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"replication_num" = "1" | ||
); | ||
""" | ||
sql """insert into ${tableName} (user_id, group_id, id) values (1,1,5),(2,2,4),(1,1,3)""" | ||
sql """insert into ${tableName} values(3,3,3,'{"b":"b"}')""" | ||
|
||
qt_select2 "SELECT * from ${tableName}" | ||
} |
88 changes: 88 additions & 0 deletions
88
regression-test/suites/data_model_p0/unique/test_sequence_column.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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. | ||
|
||
suite("test_sequence_column") { | ||
// test sequence X inverted index | ||
def tableName = "test_sequence_column" | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`keyword` VARCHAR(128), | ||
INDEX idx_col1 (user_id) USING INVERTED | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"function_column.sequence_col" = 'id', | ||
"replication_num" = "1" | ||
); | ||
""" | ||
sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" | ||
|
||
qt_select1 "SELECT * from ${tableName}" | ||
|
||
// test sequence X row store | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`keyword` VARCHAR(128), | ||
INDEX idx_col1 (user_id) USING INVERTED | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"function_column.sequence_col" = 'id', | ||
"replication_num" = "1", | ||
"store_row_column" = "true" | ||
); | ||
""" | ||
sql "insert into ${tableName} values(1,1,5,'a'),(1,1,4,'a'),(1,1,3,'a')" | ||
|
||
order_qt_all "SELECT * from ${tableName}" | ||
|
||
// test sequence X variant | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
try{ | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`keyword` VARCHAR(128), | ||
`var` variant, | ||
INDEX idx_col1 (user_id) USING INVERTED | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"function_column.sequence_col" = 'var', | ||
"replication_num" = "1", | ||
"store_row_column" = "true" | ||
); | ||
""" | ||
}catch(Exception e){ | ||
assertTrue(e.getMessage().contains("Sequence type only support integer types and date types")) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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. | ||
|
||
suite("test_txn") { | ||
def tableName = "test_txn" | ||
// test txn X inverted index | ||
sql "DROP TABLE IF EXISTS ${tableName}" | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} ( | ||
`user_id` bigint default 999, | ||
`group_id` bigint, | ||
`id` bigint, | ||
`vv` variant, | ||
INDEX idx_col1 (user_id) USING INVERTED | ||
) ENGINE=OLAP | ||
UNIQUE KEY(user_id, group_id) | ||
DISTRIBUTED BY HASH (user_id) BUCKETS 1 | ||
PROPERTIES( | ||
"store_row_column" = "true", | ||
"replication_num" = "1" | ||
); | ||
""" | ||
sql "begin" | ||
sql """insert into ${tableName} values(1,1,5,'{"b":"b"}'),(1,1,4,'{"b":"b"}'),(1,1,3,'{"b":"b"}')""" | ||
sql "commit" | ||
|
||
qt_select1 "SELECT * from ${tableName}" | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...t/suites/unique_with_mow_p0/partial_update/test_partial_update_with_inverted_index.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
// 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. | ||
|
||
suite("test_partial_update_with_inverted_index", "p0") { | ||
|
||
String db = context.config.getDbNameByFile(context.file) | ||
sql "select 1;" // to create database | ||
|
||
for (def use_row_store : [false, true]) { | ||
logger.info("current params: use_row_store: ${use_row_store}") | ||
|
||
connect(user = context.config.jdbcUser, password = context.config.jdbcPassword, url = context.config.jdbcUrl) { | ||
sql "use ${db};" | ||
def tableName = "test_partial_update_with_inverted_index" | ||
// create table | ||
sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
sql """ CREATE TABLE ${tableName} ( | ||
col1 BOOLEAN, | ||
col2 TINYINT, | ||
col3 SMALLINT, | ||
col4 variant, | ||
INDEX idx_col1 (`col1`) USING INVERTED, | ||
INDEX idx_col2 (`col2`) USING INVERTED, | ||
INDEX idx_col3 (`col3`) USING INVERTED, | ||
INDEX idx_col4 (`col4`) USING INVERTED | ||
) unique key(col1, col2) distributed by hash(col1) buckets 1 | ||
properties( | ||
"replication_num" = "1", | ||
"store_row_column" = "${use_row_store}" | ||
); """ | ||
|
||
sql """ | ||
insert into ${tableName} values(true, 1, 1, '{"a":"a"}'); | ||
""" | ||
qt_select_1 "select * from ${tableName};" | ||
|
||
sql "set enable_unique_key_partial_update=true;" | ||
sql "set enable_insert_strict=false;" | ||
sql """ | ||
insert into ${tableName} (col1, col2, col4)values(true, 1, '{"b":"b"}'); | ||
""" | ||
qt_select_2 "select * from ${tableName};" | ||
} | ||
} | ||
} |
Oops, something went wrong.