Skip to content

Commit 1edaad2

Browse files
Revert "Revert "Fix leak of mytile_group_by_handler::aggr_array. (#374)" (#…"
This reverts commit df752f8.
1 parent a95da6a commit 1edaad2

File tree

6 files changed

+40
-40
lines changed

6 files changed

+40
-40
lines changed

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ WORKDIR /tmp
5555

5656
ENV MARIADB_VERSION="mariadb-11.0.2"
5757

58-
ARG MYTILE_VERSION="0.34.1"
58+
ARG MYTILE_VERSION="0.34.0"
5959

6060
ARG TILEDB_VERSION="2.26.0"
6161
ARG TILEDB_VERSION_SHORT_SHA="983b716"

docker/Dockerfile-R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ WORKDIR /tmp
7272

7373
ENV MARIADB_VERSION="mariadb-11.0.2"
7474

75-
ARG MYTILE_VERSION="0.34.1"
75+
ARG MYTILE_VERSION="0.34.0"
7676

7777
ARG TILEDB_VERSION="2.26.0"
7878
ARG TILEDB_VERSION_SHORT_SHA="983b716"

docker/Dockerfile-min

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ENV MTR_MEM=/tmp \
5353
MARIADB_VERSION="mariadb-11.0.2"
5454
WORKDIR /tmp
5555

56-
ARG MYTILE_VERSION="0.34.1"
56+
ARG MYTILE_VERSION="0.34.0"
5757

5858
ARG TILEDB_VERSION="2.26.0"
5959
ARG TILEDB_VERSION_SHORT_SHA="983b716"

docker/Dockerfile-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ WORKDIR /tmp
5454

5555
ENV MARIADB_VERSION="mariadb-11.0.2"
5656

57-
ARG MYTILE_VERSION="0.34.1"
57+
ARG MYTILE_VERSION="0.34.0"
5858

5959
ARG TILEDB_VERSION="2.26.0"
6060
ARG TILEDB_VERSION_SHORT_SHA="983b716"

mytile/ha_mytile.cc

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int tile::mytile_group_by_handler::end_scan() {
149149

150150
this->pushdown_ranges.clear();
151151
this->pushdown_in_ranges.clear();
152-
delete this->aggr_array;
152+
this->aggr_array.reset();
153153
DBUG_RETURN(0);
154154
}
155155

@@ -170,7 +170,7 @@ int tile::mytile_group_by_handler::init_scan() {
170170
tile::build_subarray(thd, this->valid_ranges, this->valid_in_ranges,
171171
empty_read, domain, this->pushdown_ranges,
172172
this->pushdown_in_ranges, this->tiledb_sub,
173-
this->ctx.get(), this->aggr_array);
173+
this->ctx.get(), this->aggr_array.get());
174174
} catch (const tiledb::TileDBError &e) {
175175
// Log errors
176176
my_printf_error(ER_UNKNOWN_ERROR, "[init_scan] error for table %s : %s",
@@ -641,41 +641,35 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
641641

642642
// open array here before init scan because we need to check if the aggregate
643643
// requested can be processed by TileDB.
644-
tiledb::Array *aggr_array;
644+
std::unique_ptr<tiledb::Array> aggr_array;
645645
std::shared_ptr<tiledb::Config> cfg;
646646
std::shared_ptr<tiledb::Context> ctx;
647647

648648
cfg = std::make_shared<tiledb::Config>(tile::build_config(thd));
649649
ctx = std::make_shared<tiledb::Context>(tile::build_context(*cfg));
650+
tiledb_encryption_type_t encryption_type =
651+
encryption_key.empty() ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM;
650652

651653
if (open_at != UINT64_MAX) {
652654
#if TILEDB_VERSION_MAJOR >= 2 && TILEDB_VERSION_MINOR >= 15
653-
aggr_array = new tiledb::Array(
655+
aggr_array = std::make_unique<tiledb::Array>(
654656
*ctx, uri, TILEDB_READ,
655657
tiledb::TemporalPolicy(tiledb::TimeTravel, open_at),
656-
tiledb::EncryptionAlgorithm(
657-
encryption_key.empty() ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM,
658-
encryption_key.c_str()));
658+
tiledb::EncryptionAlgorithm(encryption_type, encryption_key.c_str()));
659659
#else
660-
aggr_array = new tiledb::Array(*ctx, uri, TILEDB_READ,
661-
encryption_key.empty() ? TILEDB_NO_ENCRYPTION
662-
: TILEDB_AES_256_GCM,
663-
encryption_key, open_at);
660+
aggr_array = std::make_unique<tiledb::Array>(
661+
*ctx, uri, TILEDB_READ, encryption_type, encryption_key, open_at);
664662
#endif
665663

666664
} else {
667665

668666
#if TILEDB_VERSION_MAJOR >= 2 && TILEDB_VERSION_MINOR >= 15
669-
aggr_array = new tiledb::Array(
667+
aggr_array = std::make_unique<tiledb::Array>(
670668
*ctx, uri, TILEDB_READ, tiledb::TemporalPolicy(),
671-
tiledb::EncryptionAlgorithm(
672-
encryption_key.empty() ? TILEDB_NO_ENCRYPTION : TILEDB_AES_256_GCM,
673-
encryption_key.c_str()));
669+
tiledb::EncryptionAlgorithm(encryption_type, encryption_key.c_str()));
674670
#else
675-
aggr_array = new tiledb::Array(*ctx, uri, TILEDB_READ,
676-
encryption_key.empty() ? TILEDB_NO_ENCRYPTION
677-
: TILEDB_AES_256_GCM,
678-
encryption_key);
671+
aggr_array = std::make_unique<tiledb::Array>(
672+
*ctx, uri, TILEDB_READ, encryption_type, encryption_key);
679673
#endif
680674
}
681675

@@ -696,10 +690,10 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
696690
}
697691

698692
if (isp && !aggregate_is_supported(column_with_aggregate, isp->sum_func(),
699-
aggr_array)) {
693+
aggr_array.get())) {
700694
if (aggr_array != nullptr && aggr_array->is_open()) {
701695
aggr_array->close();
702-
delete aggr_array;
696+
aggr_array.reset();
703697
}
704698
return 0;
705699
}
@@ -708,9 +702,14 @@ static group_by_handler *mytile_create_group_by_handler(THD *thd,
708702

709703
/* Create handler and return it */
710704
handler = new tile::mytile_group_by_handler(
711-
thd, aggr_array, ctx, qc, valid_ranges, valid_in_ranges, ranges,
712-
in_ranges, encryption_key, open_at);
705+
thd, std::move(aggr_array), ctx, qc, valid_ranges, valid_in_ranges,
706+
ranges, in_ranges, encryption_key, open_at);
713707
return handler;
708+
} else {
709+
if (aggr_array != nullptr && aggr_array->is_open()) {
710+
aggr_array->close();
711+
aggr_array.reset();
712+
}
714713
}
715714
return 0;
716715
}
@@ -763,17 +762,18 @@ tile::mytile::mytile(handlerton *hton, TABLE_SHARE *table_arg)
763762
: handler(hton, table_arg){};
764763

765764
tile::mytile_group_by_handler::mytile_group_by_handler(
766-
THD *thd_arg, tiledb::Array *array,
765+
THD *thd_arg, std::unique_ptr<tiledb::Array> array,
767766
std::shared_ptr<tiledb::Context> &context,
768767
std::shared_ptr<tiledb::QueryCondition> &qc, bool val_ranges,
769768
bool val_in_ranges,
770769
std::vector<std::vector<std::shared_ptr<tile::range>>> &ranges,
771770
std::vector<std::vector<std::shared_ptr<tile::range>>> &in_ranges,
772771
const std::string encryption_key, const uint64_t open_at)
773-
: group_by_handler(thd_arg, mytile_hton), aggr_array(array), ctx(context),
774-
tiledb_qc(qc), valid_ranges(val_ranges), valid_in_ranges(val_in_ranges),
775-
pushdown_ranges(ranges), pushdown_in_ranges(in_ranges),
776-
encryption_key(encryption_key), open_at(open_at){};
772+
: group_by_handler(thd_arg, mytile_hton), aggr_array(std::move(array)),
773+
ctx(context), tiledb_qc(qc), valid_ranges(val_ranges),
774+
valid_in_ranges(val_in_ranges), pushdown_ranges(ranges),
775+
pushdown_in_ranges(in_ranges), encryption_key(encryption_key),
776+
open_at(open_at){};
777777

778778
int tile::mytile::create(const char *name, TABLE *table_arg,
779779
HA_CREATE_INFO *create_info) {
@@ -1231,8 +1231,8 @@ int tile::mytile::create_array(const char *name, TABLE *table_arg,
12311231
tiledb::FilterList filter_list(context);
12321232
if (field->option_struct->filters != nullptr) {
12331233
filter_list =
1234-
tile::parse_filter_list(context, field->option_struct->filters);
1235-
}
1234+
tile::parse_filter_list(context, field->option_struct->filters);
1235+
}
12361236

12371237
auto dim = create_field_dimension(context, field, arrayType);
12381238
if (filter_list.nfilters() > 0) {
@@ -1281,7 +1281,7 @@ int tile::mytile::create_array(const char *name, TABLE *table_arg,
12811281
tiledb::FilterList filter_list(context);
12821282
if (field->option_struct->filters != nullptr) {
12831283
filter_list =
1284-
tile::parse_filter_list(context, field->option_struct->filters);
1284+
tile::parse_filter_list(context, field->option_struct->filters);
12851285
}
12861286

12871287
auto dim = create_field_dimension(context, field, arrayType);
@@ -4378,7 +4378,7 @@ mysql_declare_plugin(mytile){
43784378
PLUGIN_LICENSE_PROPRIETARY, /* the plugin license (PLUGIN_LICENSE_XXX) */
43794379
mytile_init_func, /* Plugin Init */
43804380
NULL, /* Plugin Deinit */
4381-
0x0341, /* version number (0.34.1) */
4381+
0x0340, /* version number (0.34.0) */
43824382
tile::statusvars::mytile_status_variables, /* status variables */
43834383
tile::sysvars::mytile_system_variables, /* system variables */
43844384
NULL, /* config options */
@@ -4395,9 +4395,9 @@ maria_declare_plugin(mytile){
43954395
PLUGIN_LICENSE_PROPRIETARY, /* the plugin license (PLUGIN_LICENSE_XXX) */
43964396
mytile_init_func, /* Plugin Init */
43974397
NULL, /* Plugin Deinit */
4398-
0x0341, /* version number (0.34.1) */
4398+
0x0340, /* version number (0.34.0) */
43994399
tile::statusvars::mytile_status_variables, /* status variables */
44004400
tile::sysvars::mytile_system_variables, /* system variables */
4401-
"0.34.1", /* string version */
4401+
"0.34.0", /* string version */
44024402
MariaDB_PLUGIN_MATURITY_BETA /* maturity */
44034403
} maria_declare_plugin_end;

mytile/ha_mytile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class mytile_group_by_handler : public group_by_handler {
7070
bool first_row;
7171

7272
// The array we run the aggregates on
73-
tiledb::Array *aggr_array;
73+
std::unique_ptr<tiledb::Array> aggr_array;
7474

7575
// The context
7676
std::shared_ptr<tiledb::Context> ctx;
@@ -116,7 +116,7 @@ class mytile_group_by_handler : public group_by_handler {
116116
* @param val_in_ranges
117117
*/
118118
mytile_group_by_handler(
119-
THD *thd_arg, tiledb::Array *array,
119+
THD *thd_arg, std::unique_ptr<tiledb::Array> array,
120120
std::shared_ptr<tiledb::Context> &context,
121121
std::shared_ptr<tiledb::QueryCondition> &qc, bool val_ranges,
122122
bool val_in_ranges,

0 commit comments

Comments
 (0)