Skip to content

Commit eb4ab2c

Browse files
committed
MDEV-35061 XA PREPARE "not supported by the engine" from storage engine mhnsw, memory leak
disallow explicit XA PREPARE over mhnsw indexes
1 parent 09cd817 commit eb4ab2c

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

mysql-test/main/vector_innodb.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,18 @@ insert into t values (1,x'00000000'),(2,x'00000000');
171171
lock table t write;
172172
delete from t;
173173
drop table t;
174+
#
175+
# MDEV-35061 XA PREPARE "not supported by the engine" from storage engine mhnsw, memory leak
176+
#
177+
connect con1,localhost,root;
178+
create table t (a int, v blob not null, vector(v)) engine=innodb;
179+
xa start 'x';
180+
insert into t values (1,x'00000000');
181+
xa end 'x';
182+
xa prepare 'x';
183+
ERROR HY000: Got error 138 "Unsupported extension used for table" from storage engine mhnsw
184+
disconnect con1;
185+
connection default;
186+
xa recover;
187+
formatID gtrid_length bqual_length data
188+
DROP TABLE t;

mysql-test/main/vector_innodb.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,19 @@ insert into t values (1,x'00000000'),(2,x'00000000');
159159
lock table t write;
160160
delete from t;
161161
drop table t;
162+
163+
--echo #
164+
--echo # MDEV-35061 XA PREPARE "not supported by the engine" from storage engine mhnsw, memory leak
165+
--echo #
166+
connect con1,localhost,root;
167+
create table t (a int, v blob not null, vector(v)) engine=innodb;
168+
xa start 'x';
169+
insert into t values (1,x'00000000');
170+
xa end 'x';
171+
--error ER_GET_ERRNO
172+
xa prepare 'x';
173+
disconnect con1;
174+
connection default;
175+
#xa commit 'x';
176+
xa recover;
177+
DROP TABLE t;

sql/handler.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,9 +1508,7 @@ static int prepare_or_error(transaction_participant *ht, THD *thd, bool all)
15081508
int err= ht->prepare(thd, all);
15091509
status_var_increment(thd->status_var.ha_prepare_count);
15101510
if (err)
1511-
{
1512-
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
1513-
}
1511+
my_error(ER_GET_ERRNO, MYF(0), err, hton_name(ht)->str);
15141512
#ifdef WITH_WSREP
15151513
if (run_wsrep_hooks && !err && ht->flags & HTON_WSREP_REPLICATION &&
15161514
wsrep_after_prepare(thd, all))

sql/log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ inline bool normalize_binlog_name(char *to, const char *from, bool is_relay_log)
14761476

14771477
static inline TC_LOG *get_tc_log_implementation()
14781478
{
1479-
if (total_ha_2pc <= 1)
1479+
if (total_ha_2pc <= 2) // online_alter_tp and MHNSW_Trx::tp
14801480
return &tc_log_dummy;
14811481
if (opt_bin_log)
14821482
return &mysql_bin_log;

sql/vector_mhnsw.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ class MHNSW_Trx : public MHNSW_Share
520520
static int do_commit(THD *thd, bool);
521521
static int do_savepoint_rollback(THD *thd, void *);
522522
static int do_rollback(THD *thd, bool);
523+
static int do_prepare(THD *thd, bool);
523524
};
524525

525526
struct transaction_participant MHNSW_Trx::tp=
@@ -531,7 +532,7 @@ struct transaction_participant MHNSW_Trx::tp=
531532
[](THD *thd){ return true; }, /*savepoint_rollback_can_release_mdl*/
532533
nullptr, /*savepoint_release*/
533534
MHNSW_Trx::do_commit, MHNSW_Trx::do_rollback,
534-
nullptr, /* prepare */
535+
MHNSW_Trx::do_prepare, /* prepare */
535536
nullptr, /* recover */
536537
nullptr, nullptr, /* commit/rollback_by_xid */
537538
nullptr, nullptr, /* recover_rollback_by_xid/recovery_done */
@@ -606,6 +607,13 @@ int MHNSW_Trx::do_commit(THD *thd, bool)
606607
return 0;
607608
}
608609

610+
int MHNSW_Trx::do_prepare(THD *thd, bool)
611+
{
612+
/* Explicit XA is not supported yet */
613+
return thd->transaction->xid_state.is_explicit_XA()
614+
? HA_ERR_UNSUPPORTED : 0;
615+
}
616+
609617
MHNSW_Trx *MHNSW_Trx::get_from_thd(TABLE *table, bool for_update)
610618
{
611619
if (!table->file->has_transactions())

0 commit comments

Comments
 (0)