Skip to content

Commit 97c53cd

Browse files
committed
5.6.36-82.0
1 parent d71df7e commit 97c53cd

35 files changed

+1817
-190
lines changed

storage/tokudb/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SET(TOKUDB_VERSION 5.6.35-80.0)
1+
SET(TOKUDB_VERSION 5.6.36-82.0)
22
# PerconaFT only supports x86-64 and cmake-2.8.9+
33
IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND
44
NOT CMAKE_VERSION VERSION_LESS "2.8.9")
@@ -111,7 +111,8 @@ SET(TOKUDB_SOURCES
111111
tokudb_background.cc
112112
tokudb_information_schema.cc
113113
tokudb_sysvars.cc
114-
tokudb_thread.cc)
114+
tokudb_thread.cc
115+
tokudb_dir_cmd.cc)
115116
MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY
116117
LINK_LIBRARIES tokufractaltree_static tokuportability_static ${ZLIB_LIBRARY} stdc++)
117118
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin")

storage/tokudb/PerconaFT/buildheader/make_tdb.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ static void print_db_env_struct (void) {
425425
"bool (*set_dir_per_db)(DB_ENV *, bool new_val)",
426426
"bool (*get_dir_per_db)(DB_ENV *)",
427427
"const char *(*get_data_dir)(DB_ENV *env)",
428+
"int (*dirtool_attach)(DB_ENV *, DB_TXN *, const char *, const char *)",
429+
"int (*dirtool_detach)(DB_ENV *, DB_TXN *, const char *)",
430+
"int (*dirtool_move)(DB_ENV *, DB_TXN *, const char *, const char *)",
428431
NULL};
429432

430433
sort_and_dump_fields("db_env", true, extra);

storage/tokudb/PerconaFT/ft/ft-ops.cc

Lines changed: 257 additions & 136 deletions
Large diffs are not rendered by default.

storage/tokudb/PerconaFT/src/ydb.cc

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const char *toku_copyright_string = "Copyright (c) 2006, 2015, Percona and/or it
7070
#include "util/status.h"
7171
#include "util/context.h"
7272

73+
#include <functional>
74+
7375
// Include ydb_lib.cc here so that its constructor/destructor gets put into
7476
// ydb.o, to make sure they don't get erased at link time (when linking to
7577
// a static libtokufractaltree.a that was compiled with gcc). See #5094.
@@ -1314,6 +1316,159 @@ static const char *env_get_data_dir(DB_ENV *env) {
13141316
return env->i->real_data_dir;
13151317
}
13161318

1319+
static int env_dirtool_attach(DB_ENV *env,
1320+
DB_TXN *txn,
1321+
const char *dname,
1322+
const char *iname) {
1323+
int r;
1324+
DBT dname_dbt;
1325+
DBT iname_dbt;
1326+
1327+
HANDLE_PANICKED_ENV(env);
1328+
if (!env_opened(env)) {
1329+
return EINVAL;
1330+
}
1331+
HANDLE_READ_ONLY_TXN(txn);
1332+
toku_fill_dbt(&dname_dbt, dname, strlen(dname) + 1);
1333+
toku_fill_dbt(&iname_dbt, iname, strlen(iname) + 1);
1334+
1335+
r = toku_db_put(env->i->directory,
1336+
txn,
1337+
&dname_dbt,
1338+
&iname_dbt,
1339+
0,
1340+
true);
1341+
return r;
1342+
}
1343+
1344+
static int env_dirtool_detach(DB_ENV *env,
1345+
DB_TXN *txn,
1346+
const char *dname) {
1347+
int r;
1348+
DBT dname_dbt;
1349+
DBT old_iname_dbt;
1350+
1351+
HANDLE_PANICKED_ENV(env);
1352+
if (!env_opened(env)) {
1353+
return EINVAL;
1354+
}
1355+
HANDLE_READ_ONLY_TXN(txn);
1356+
1357+
toku_fill_dbt(&dname_dbt, dname, strlen(dname) + 1);
1358+
toku_init_dbt_flags(&old_iname_dbt, DB_DBT_REALLOC);
1359+
1360+
r = toku_db_get(env->i->directory,
1361+
txn,
1362+
&dname_dbt,
1363+
&old_iname_dbt,
1364+
DB_SERIALIZABLE); // allocates memory for iname
1365+
if (r == DB_NOTFOUND)
1366+
return EEXIST;
1367+
toku_free(old_iname_dbt.data);
1368+
1369+
r = toku_db_del(env->i->directory, txn, &dname_dbt, DB_DELETE_ANY, true);
1370+
1371+
return r;
1372+
}
1373+
1374+
static int env_dirtool_move(DB_ENV *env,
1375+
DB_TXN *txn,
1376+
const char *old_dname,
1377+
const char *new_dname) {
1378+
int r;
1379+
DBT old_dname_dbt;
1380+
DBT new_dname_dbt;
1381+
DBT iname_dbt;
1382+
1383+
HANDLE_PANICKED_ENV(env);
1384+
if (!env_opened(env)) {
1385+
return EINVAL;
1386+
}
1387+
HANDLE_READ_ONLY_TXN(txn);
1388+
1389+
toku_fill_dbt(&old_dname_dbt, old_dname, strlen(old_dname) + 1);
1390+
toku_fill_dbt(&new_dname_dbt, new_dname, strlen(new_dname) + 1);
1391+
toku_init_dbt_flags(&iname_dbt, DB_DBT_REALLOC);
1392+
1393+
r = toku_db_get(env->i->directory,
1394+
txn,
1395+
&old_dname_dbt,
1396+
&iname_dbt,
1397+
DB_SERIALIZABLE); // allocates memory for iname
1398+
if (r == DB_NOTFOUND)
1399+
return EEXIST;
1400+
1401+
r = toku_db_del(
1402+
env->i->directory, txn, &old_dname_dbt, DB_DELETE_ANY, true);
1403+
if (r != 0)
1404+
goto exit;
1405+
1406+
r = toku_db_put(
1407+
env->i->directory, txn, &new_dname_dbt, &iname_dbt, 0, true);
1408+
1409+
exit:
1410+
toku_free(iname_dbt.data);
1411+
return r;
1412+
}
1413+
1414+
static int locked_env_op(DB_ENV *env,
1415+
DB_TXN *txn,
1416+
std::function<int(DB_TXN *)> f) {
1417+
int ret, r;
1418+
HANDLE_READ_ONLY_TXN(txn);
1419+
HANDLE_ILLEGAL_WORKING_PARENT_TXN(env, txn);
1420+
1421+
DB_TXN *child_txn = NULL;
1422+
int using_txns = env->i->open_flags & DB_INIT_TXN;
1423+
if (using_txns) {
1424+
ret = toku_txn_begin(env, txn, &child_txn, 0);
1425+
lazy_assert_zero(ret);
1426+
}
1427+
1428+
// cannot begin a checkpoint
1429+
toku_multi_operation_client_lock();
1430+
r = f(child_txn);
1431+
toku_multi_operation_client_unlock();
1432+
1433+
if (using_txns) {
1434+
if (r == 0) {
1435+
ret = locked_txn_commit(child_txn, 0);
1436+
lazy_assert_zero(ret);
1437+
} else {
1438+
ret = locked_txn_abort(child_txn);
1439+
lazy_assert_zero(ret);
1440+
}
1441+
}
1442+
return r;
1443+
1444+
}
1445+
1446+
static int locked_env_dirtool_attach(DB_ENV *env,
1447+
DB_TXN *txn,
1448+
const char *dname,
1449+
const char *iname) {
1450+
auto f = std::bind(
1451+
env_dirtool_attach, env, std::placeholders::_1, dname, iname);
1452+
return locked_env_op(env, txn, f);
1453+
}
1454+
1455+
static int locked_env_dirtool_detach(DB_ENV *env,
1456+
DB_TXN *txn,
1457+
const char *dname) {
1458+
auto f = std::bind(
1459+
env_dirtool_detach, env, std::placeholders::_1, dname);
1460+
return locked_env_op(env, txn, f);
1461+
}
1462+
1463+
static int locked_env_dirtool_move(DB_ENV *env,
1464+
DB_TXN *txn,
1465+
const char *old_dname,
1466+
const char *new_dname) {
1467+
auto f = std::bind(
1468+
env_dirtool_move, env, std::placeholders::_1, old_dname, new_dname);
1469+
return locked_env_op(env, txn, f);
1470+
}
1471+
13171472
static int env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbname, uint32_t flags);
13181473

13191474
static int
@@ -2646,6 +2801,9 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) {
26462801
#define SENV(name) result->name = locked_env_ ## name
26472802
SENV(dbremove);
26482803
SENV(dbrename);
2804+
SENV(dirtool_attach);
2805+
SENV(dirtool_detach);
2806+
SENV(dirtool_move);
26492807
//SENV(set_noticecall);
26502808
#undef SENV
26512809
#define USENV(name) result->name = env_ ## name
@@ -2975,8 +3133,10 @@ env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbname, u
29753133
if (txn && r) {
29763134
if (r == EMFILE || r == ENFILE)
29773135
r = toku_ydb_do_error(env, r, "toku dbremove failed because open file limit reached\n");
2978-
else
3136+
else if (r != ENOENT)
29793137
r = toku_ydb_do_error(env, r, "toku dbremove failed\n");
3138+
else
3139+
r = 0;
29803140
goto exit;
29813141
}
29823142
if (txn) {

storage/tokudb/ha_tokudb.cc

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5254,17 +5254,17 @@ int ha_tokudb::fill_range_query_buf(
52545254
DEBUG_SYNC(ha_thd(), "tokudb_icp_asc_scan_out_of_range");
52555255
goto cleanup;
52565256
} else if (result == ICP_NO_MATCH) {
5257-
// if we are performing a DESC ICP scan and have no end_range
5258-
// to compare to stop using ICP filtering as there isn't much more
5259-
// that we can do without going through contortions with remembering
5260-
// and comparing key parts.
5257+
// Optimizer change for MyRocks also benefits us here in TokuDB as
5258+
// opt_range.cc QUICK_SELECT::get_next now sets end_range during
5259+
// descending scan. We should not ever hit this condition, but
5260+
// leaving this code in to prevent any possibility of a descending
5261+
// scan to the beginning of an index and catch any possibility
5262+
// in debug builds with an assertion
5263+
assert_debug(!(!end_range && direction < 0));
52615264
if (!end_range &&
52625265
direction < 0) {
5263-
52645266
cancel_pushed_idx_cond();
5265-
DEBUG_SYNC(ha_thd(), "tokudb_icp_desc_scan_invalidate");
52665267
}
5267-
52685268
error = TOKUDB_CURSOR_CONTINUE;
52695269
goto cleanup;
52705270
}
@@ -6122,7 +6122,6 @@ int ha_tokudb::info(uint flag) {
61226122
stats.records = share->row_count() + share->rows_from_locked_table;
61236123
stats.deleted = 0;
61246124
if (!(flag & HA_STATUS_NO_LOCK)) {
6125-
uint64_t num_rows = 0;
61266125

61276126
error = txn_begin(db_env, NULL, &txn, DB_READ_UNCOMMITTED, ha_thd());
61286127
if (error) {
@@ -6132,20 +6131,13 @@ int ha_tokudb::info(uint flag) {
61326131
// we should always have a primary key
61336132
assert_always(share->file != NULL);
61346133

6135-
error = estimate_num_rows(share->file, &num_rows, txn);
6136-
if (error == 0) {
6137-
share->set_row_count(num_rows, false);
6138-
stats.records = num_rows;
6139-
} else {
6140-
goto cleanup;
6141-
}
6142-
61436134
DB_BTREE_STAT64 dict_stats;
61446135
error = share->file->stat64(share->file, txn, &dict_stats);
61456136
if (error) {
61466137
goto cleanup;
61476138
}
6148-
6139+
share->set_row_count(dict_stats.bt_ndata, false);
6140+
stats.records = dict_stats.bt_ndata;
61496141
stats.create_time = dict_stats.bt_create_time_sec;
61506142
stats.update_time = dict_stats.bt_modify_time_sec;
61516143
stats.check_time = dict_stats.bt_verify_time_sec;
@@ -7841,7 +7833,7 @@ ha_rows ha_tokudb::records_in_range(uint keynr, key_range* start_key, key_range*
78417833
// As a result, equal may be 0 and greater may actually be equal+greater
78427834
// So, we call key_range64 on the key, and the key that is after it.
78437835
if (!start_key && !end_key) {
7844-
error = estimate_num_rows(kfile, &rows, transaction);
7836+
error = estimate_num_rows(share->file, &rows, transaction);
78457837
if (error) {
78467838
ret_val = HA_TOKUDB_RANGE_COUNT;
78477839
goto cleanup;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
SET GLOBAL tokudb_dir_per_db=ON;
2+
CREATE PROCEDURE create_table()
3+
BEGIN
4+
CREATE TABLE test.t1 (
5+
a INT
6+
) ENGINE = TokuDB
7+
PARTITION BY RANGE (a)
8+
(PARTITION p100 VALUES LESS THAN (100) ENGINE = TokuDB,
9+
PARTITION p_to_del VALUES LESS THAN (200) ENGINE = TokuDB,
10+
PARTITION p300 VALUES LESS THAN (300) ENGINE = TokuDB,
11+
PARTITION p400 VALUES LESS THAN (400) ENGINE = TokuDB
12+
);
13+
END|
14+
### Create partitioned table
15+
CALL create_table();
16+
## Looking for *.tokudb files in data_dir
17+
## Looking for *.tokudb files in data_dir/test
18+
t1_P_p100_main_id.tokudb
19+
t1_P_p100_status_id.tokudb
20+
t1_P_p300_main_id.tokudb
21+
t1_P_p300_status_id.tokudb
22+
t1_P_p400_main_id.tokudb
23+
t1_P_p400_status_id.tokudb
24+
t1_P_p_to_del_main_id.tokudb
25+
t1_P_p_to_del_status_id.tokudb
26+
### Stop server
27+
### Remove 'main' file of one of the partitions
28+
### Start server
29+
### Make sure 'main' partition file is deleted
30+
## Looking for *.tokudb files in data_dir
31+
## Looking for *.tokudb files in data_dir/test
32+
t1_P_p100_main_id.tokudb
33+
t1_P_p100_status_id.tokudb
34+
t1_P_p300_main_id.tokudb
35+
t1_P_p300_status_id.tokudb
36+
t1_P_p400_main_id.tokudb
37+
t1_P_p400_status_id.tokudb
38+
t1_P_p_to_del_status_id.tokudb
39+
### Make sure the table still exists
40+
SHOW TABLES;
41+
Tables_in_test
42+
t1
43+
### Drop table
44+
DROP TABLE t1;
45+
### Make sure the table is dropped
46+
SHOW TABLES;
47+
Tables_in_test
48+
### Check what files still exist after DROP TABLE
49+
## Looking for *.tokudb files in data_dir
50+
## Looking for *.tokudb files in data_dir/test
51+
### Remove the rest of the files
52+
### Make sure there are no tokudb files
53+
## Looking for *.tokudb files in data_dir
54+
## Looking for *.tokudb files in data_dir/test
55+
### Create the same table once more
56+
CALL create_table();
57+
## Looking for *.tokudb files in data_dir
58+
## Looking for *.tokudb files in data_dir/test
59+
t1_P_p100_main_id.tokudb
60+
t1_P_p100_status_id.tokudb
61+
t1_P_p300_main_id.tokudb
62+
t1_P_p300_status_id.tokudb
63+
t1_P_p400_main_id.tokudb
64+
t1_P_p400_status_id.tokudb
65+
t1_P_p_to_del_main_id.tokudb
66+
t1_P_p_to_del_status_id.tokudb
67+
### Restore state
68+
DROP TABLE t1;
69+
DROP PROCEDURE create_table;
70+
SET GLOBAL tokudb_dir_per_db=default;

0 commit comments

Comments
 (0)