Skip to content

Commit

Permalink
fix(core): fix bug: The instance occasionally crashes if both fields …
Browse files Browse the repository at this point in the history
…specified for an equi-join are of the string data types (stoneatom#1476)
  • Loading branch information
wisehead committed Apr 6, 2023
1 parent 9d45726 commit 7c3c30a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
21 changes: 21 additions & 0 deletions mysql-test/suite/tianmu/r/hash_join.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DROP DATABASE IF EXISTS hash_join_test;
CREATE DATABASE hash_join_test;
USE hash_join_test;
CREATE TABLE `test1` (
`id` varchar(64) NOT NULL COMMENT 'ID'
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
CREATE TABLE `test2` (
`user_id` varchar(32) NOT NULL COMMENT '用户ID'
) ENGINE=TIANMU DEFAULT CHARSET=utf8;
insert test1 values('aaa');
insert test1 values('bbb');
insert test1 values('ccc');
insert test2 values('aaa');
insert test2 values('bbb');
insert test2 values('ccc');
select test1.id,test2.user_id from test2,test1 where test2.user_id = test1.id ;
id user_id
aaa aaa
bbb bbb
ccc ccc
DROP DATABASE hash_join_test;
29 changes: 29 additions & 0 deletions mysql-test/suite/tianmu/t/hash_join.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--source include/have_tianmu.inc

--disable_warnings
DROP DATABASE IF EXISTS hash_join_test;
--enable_warnings

CREATE DATABASE hash_join_test;

USE hash_join_test;

CREATE TABLE `test1` (
`id` varchar(64) NOT NULL COMMENT 'ID'
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;

CREATE TABLE `test2` (
`user_id` varchar(32) NOT NULL COMMENT '用户ID'
) ENGINE=TIANMU DEFAULT CHARSET=utf8;

insert test1 values('aaa');
insert test1 values('bbb');
insert test1 values('ccc');

insert test2 values('aaa');
insert test2 values('bbb');
insert test2 values('ccc');

select test1.id,test2.user_id from test2,test1 where test2.user_id = test1.id ;

DROP DATABASE hash_join_test;
5 changes: 4 additions & 1 deletion storage/tianmu/core/parallel_hash_join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ namespace Tianmu {
namespace core {
namespace {
const int kJoinSplittedMinPacks = 5;
const int kTraversedPacksPerFragment = 30;
// bug 1476: change this threhold from 30 to INT_MAX32 to disable the parallel hash join
// because the result is sometimes wrong if parallel hash join is enabled.
// we'll re-enable the hash join later if the bug is fixed in near future.
const int kTraversedPacksPerFragment = INT_MAX32 / 2;

int EvaluateTraversedFragments(int packs_count) {
const int kMaxTraversedFragmentCount = 8;
Expand Down

0 comments on commit 7c3c30a

Please sign in to comment.