Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
ce554d56
Commit
ce554d56
authored
Jul 06, 2006
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #20820 auto inc table not handled correctly when restored from cluster backup
parent
123c0a98
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
26 deletions
+65
-26
mysql-test/include/ndb_default_cluster.inc
mysql-test/include/ndb_default_cluster.inc
+1
-1
mysql-test/r/ndb_default_cluster.require
mysql-test/r/ndb_default_cluster.require
+1
-1
mysql-test/r/ndb_restore.result
mysql-test/r/ndb_restore.result
+17
-7
mysql-test/t/ndb_restore.test
mysql-test/t/ndb_restore.test
+17
-6
ndb/tools/restore/consumer_restore.cpp
ndb/tools/restore/consumer_restore.cpp
+29
-11
No files found.
mysql-test/include/ndb_default_cluster.inc
View file @
ce554d56
--
require
r
/
ndb_default_cluster
.
require
--
require
r
/
ndb_default_cluster
.
require
disable_query_log
;
disable_query_log
;
show
status
like
"Ndb_con
nected
_host"
;
show
status
like
"Ndb_con
fig_from
_host"
;
enable_query_log
;
enable_query_log
;
mysql-test/r/ndb_default_cluster.require
View file @
ce554d56
Variable_name Value
Variable_name Value
Ndb_con
nected
_host localhost
Ndb_con
fig_from
_host localhost
mysql-test/r/ndb_restore.result
View file @
ce554d56
use test;
use test;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9
,t10
;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c
,t10_c
;
CREATE TABLE `t1` (
CREATE TABLE `t1` (
`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment,
`goaledatta` char(2) NOT NULL default '',
`goaledatta` char(2) NOT NULL default '',
...
@@ -116,6 +116,8 @@ CREATE TABLE `t9` (
...
@@ -116,6 +116,8 @@ CREATE TABLE `t9` (
PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`)
PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`)
) ENGINE=myisam DEFAULT CHARSET=latin1;
) ENGINE=myisam DEFAULT CHARSET=latin1;
INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3);
create table t10 (a int auto_increment key);
insert into t10 values (1),(2),(3);
create table t1_c engine=ndbcluster as select * from t1;
create table t1_c engine=ndbcluster as select * from t1;
create table t2_c engine=ndbcluster as select * from t2;
create table t2_c engine=ndbcluster as select * from t2;
create table t3_c engine=ndbcluster as select * from t3;
create table t3_c engine=ndbcluster as select * from t3;
...
@@ -125,10 +127,12 @@ create table t6_c engine=ndbcluster as select * from t6;
...
@@ -125,10 +127,12 @@ create table t6_c engine=ndbcluster as select * from t6;
create table t7_c engine=ndbcluster as select * from t7;
create table t7_c engine=ndbcluster as select * from t7;
create table t8_c engine=ndbcluster as select * from t8;
create table t8_c engine=ndbcluster as select * from t8;
create table t9_c engine=ndbcluster as select * from t9;
create table t9_c engine=ndbcluster as select * from t9;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
create table t10_c engine=ndbcluster as select * from t10;
drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c;
show tables;
show tables;
Tables_in_test
Tables_in_test
t1
t1
t10
t2
t2
t3
t3
t4
t4
...
@@ -137,14 +141,15 @@ t6
...
@@ -137,14 +141,15 @@ t6
t7
t7
t8
t8
t9
t9
t
8
_c
t
3
_c
t9_c
t9_c
t1_c
t1_c
t8_c
t7_c
t7_c
t6_c
t6_c
t5_c
t5_c
t4_c
t4_c
t
3
_c
t
10
_c
t2_c
t2_c
select count(*) from t1;
select count(*) from t1;
count(*)
count(*)
...
@@ -245,6 +250,11 @@ from (select * from t9 union
...
@@ -245,6 +250,11 @@ from (select * from t9 union
select * from t9_c) a;
select * from t9_c) a;
count(*)
count(*)
3
3
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
select * from t10_c order by a;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
a
1
2
3
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9, t10;
drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c, t10_c;
520093696,1
520093696,1
mysql-test/t/ndb_restore.test
View file @
ce554d56
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
--
disable_warnings
--
disable_warnings
use
test
;
use
test
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
,
t10
;
drop
table
if
exists
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
;
drop
table
if
exists
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
,
t10_c
;
--
enable_warnings
--
enable_warnings
CREATE
TABLE
`t1`
(
CREATE
TABLE
`t1`
(
...
@@ -132,6 +132,13 @@ CREATE TABLE `t9` (
...
@@ -132,6 +132,13 @@ CREATE TABLE `t9` (
)
ENGINE
=
myisam
DEFAULT
CHARSET
=
latin1
;
)
ENGINE
=
myisam
DEFAULT
CHARSET
=
latin1
;
INSERT
INTO
`t9`
VALUES
(
'3g4jh8gar2t'
,
'joe'
,
'q3.net'
,
'elredun.com'
,
'q3.net'
,
'436643316120'
,
'436643316939'
,
'91341234568968'
,
'695595699'
,
'1.1.1.1'
,
'2.2.6.2'
,
'3'
,
'86989'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 18:35:04'
,
'2012-12-05 12:35:04'
,
3123123
,
9569
,
6565
,
1
),(
'4tt45345235'
,
'pap'
,
'q3plus.qt'
,
'q3plus.qt'
,
'q3.net'
,
'436643316120'
,
'436643316939'
,
'8956234534568968'
,
'5254595969'
,
'1.1.1.1'
,
'8.6.2.2'
,
'4'
,
'86989'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 12:55:34'
,
'2012-12-05 11:20:04'
,
3223433
,
3369
,
9565
,
2
),(
'4545435545'
,
'john'
,
'q3.net'
,
'q3.net'
,
'acne.li'
,
'436643316120'
,
'436643316939'
,
'45345234568968'
,
'995696699'
,
'1.1.1.1'
,
'2.9.9.2'
,
'2'
,
'86998'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 11:35:03'
,
'2012-12-05 08:50:04'
,
8823123
,
169
,
3565
,
3
);
INSERT
INTO
`t9`
VALUES
(
'3g4jh8gar2t'
,
'joe'
,
'q3.net'
,
'elredun.com'
,
'q3.net'
,
'436643316120'
,
'436643316939'
,
'91341234568968'
,
'695595699'
,
'1.1.1.1'
,
'2.2.6.2'
,
'3'
,
'86989'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 18:35:04'
,
'2012-12-05 12:35:04'
,
3123123
,
9569
,
6565
,
1
),(
'4tt45345235'
,
'pap'
,
'q3plus.qt'
,
'q3plus.qt'
,
'q3.net'
,
'436643316120'
,
'436643316939'
,
'8956234534568968'
,
'5254595969'
,
'1.1.1.1'
,
'8.6.2.2'
,
'4'
,
'86989'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 12:55:34'
,
'2012-12-05 11:20:04'
,
3223433
,
3369
,
9565
,
2
),(
'4545435545'
,
'john'
,
'q3.net'
,
'q3.net'
,
'acne.li'
,
'436643316120'
,
'436643316939'
,
'45345234568968'
,
'995696699'
,
'1.1.1.1'
,
'2.9.9.2'
,
'2'
,
'86998'
,
'34'
,
'x'
,
'x'
,
'2012-03-12 11:35:03'
,
'2012-12-05 08:50:04'
,
8823123
,
169
,
3565
,
3
);
# Bug #20820
# auto inc table not handled correctly when restored from cluster backup
# - before fix ndb_restore would not set auto inc value correct,
# seen by select below
create
table
t10
(
a
int
auto_increment
key
);
insert
into
t10
values
(
1
),(
2
),(
3
);
create
table
t1_c
engine
=
ndbcluster
as
select
*
from
t1
;
create
table
t1_c
engine
=
ndbcluster
as
select
*
from
t1
;
create
table
t2_c
engine
=
ndbcluster
as
select
*
from
t2
;
create
table
t2_c
engine
=
ndbcluster
as
select
*
from
t2
;
create
table
t3_c
engine
=
ndbcluster
as
select
*
from
t3
;
create
table
t3_c
engine
=
ndbcluster
as
select
*
from
t3
;
...
@@ -141,10 +148,11 @@ create table t6_c engine=ndbcluster as select * from t6;
...
@@ -141,10 +148,11 @@ create table t6_c engine=ndbcluster as select * from t6;
create
table
t7_c
engine
=
ndbcluster
as
select
*
from
t7
;
create
table
t7_c
engine
=
ndbcluster
as
select
*
from
t7
;
create
table
t8_c
engine
=
ndbcluster
as
select
*
from
t8
;
create
table
t8_c
engine
=
ndbcluster
as
select
*
from
t8
;
create
table
t9_c
engine
=
ndbcluster
as
select
*
from
t9
;
create
table
t9_c
engine
=
ndbcluster
as
select
*
from
t9
;
create
table
t10_c
engine
=
ndbcluster
as
select
*
from
t10
;
--
exec
$NDB_MGM
--
no
-
defaults
-
e
"start backup"
>>
$NDB_TOOLS_OUTPUT
--
exec
$NDB_MGM
--
no
-
defaults
-
e
"start backup"
>>
$NDB_TOOLS_OUTPUT
drop
table
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
;
drop
table
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
,
t10_c
;
--
exec
$NDB_TOOLS_DIR
/
ndb_restore
--
no
-
defaults
-
b
1
-
n
1
-
m
-
r
--
print
--
print_meta
$NDB_BACKUP_DIR
/
BACKUP
/
BACKUP
-
1
>>
$NDB_TOOLS_OUTPUT
--
exec
$NDB_TOOLS_DIR
/
ndb_restore
--
no
-
defaults
-
b
1
-
n
1
-
m
-
r
--
print
--
print_meta
$NDB_BACKUP_DIR
/
BACKUP
/
BACKUP
-
1
>>
$NDB_TOOLS_OUTPUT
--
exec
$NDB_TOOLS_DIR
/
ndb_restore
--
no
-
defaults
-
b
1
-
n
2
-
r
--
print
--
print_meta
$NDB_BACKUP_DIR
/
BACKUP
/
BACKUP
-
1
>>
$NDB_TOOLS_OUTPUT
--
exec
$NDB_TOOLS_DIR
/
ndb_restore
--
no
-
defaults
-
b
1
-
n
2
-
r
--
print
--
print_meta
$NDB_BACKUP_DIR
/
BACKUP
/
BACKUP
-
1
>>
$NDB_TOOLS_OUTPUT
...
@@ -205,9 +213,12 @@ select count(*)
...
@@ -205,9 +213,12 @@ select count(*)
from
(
select
*
from
t9
union
from
(
select
*
from
t9
union
select
*
from
t9_c
)
a
;
select
*
from
t9_c
)
a
;
# Bug #20820 cont'd
select
*
from
t10_c
order
by
a
;
--
disable_warnings
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
;
drop
table
if
exists
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
t7
,
t8
,
t9
,
t10
;
drop
table
if
exists
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
;
drop
table
if
exists
t1_c
,
t2_c
,
t3_c
,
t4_c
,
t5_c
,
t6_c
,
t7_c
,
t8_c
,
t9_c
,
t10_c
;
--
enable_warnings
--
enable_warnings
#
#
...
@@ -216,4 +227,4 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
...
@@ -216,4 +227,4 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c;
--
exec
$NDB_TOOLS_DIR
/
ndb_select_all
--
no
-
defaults
-
d
sys
-
D
,
SYSTAB_0
|
grep
520093696
--
exec
$NDB_TOOLS_DIR
/
ndb_select_all
--
no
-
defaults
-
d
sys
-
D
,
SYSTAB_0
|
grep
520093696
# End of
4.1 tests
# End of
5.0 tests (4.1 test intermixed to save test time)
ndb/tools/restore/consumer_restore.cpp
View file @
ce554d56
...
@@ -145,17 +145,38 @@ BackupRestore::finalize_table(const TableS & table){
...
@@ -145,17 +145,38 @@ BackupRestore::finalize_table(const TableS & table){
bool
ret
=
true
;
bool
ret
=
true
;
if
(
!
m_restore
&&
!
m_restore_meta
)
if
(
!
m_restore
&&
!
m_restore_meta
)
return
ret
;
return
ret
;
if
(
table
.
have_auto_inc
())
if
(
!
table
.
have_auto_inc
())
return
ret
;
Uint64
max_val
=
table
.
get_max_auto_val
();
do
{
{
Uint64
max_val
=
table
.
get_max_auto_val
();
Uint64
auto_val
=
~
(
Uint64
)
0
;
Uint64
auto_val
;
int
r
=
m_ndb
->
readAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
auto_val
);
int
r
=
m_ndb
->
readAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
auto_val
);
if
(
r
==
-
1
&&
m_ndb
->
getNdbError
().
code
!=
626
)
if
(
r
==
-
1
&&
m_ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
NdbSleep_MilliSleep
(
50
);
continue
;
// retry
}
else
if
(
r
==
-
1
&&
m_ndb
->
getNdbError
().
code
!=
626
)
{
ret
=
false
;
ret
=
false
;
else
if
(
r
==
-
1
||
max_val
+
1
>
auto_val
)
}
ret
=
m_ndb
->
setAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
max_val
+
1
,
false
)
!=
-
1
;
else
if
((
r
==
-
1
&&
m_ndb
->
getNdbError
().
code
==
626
)
||
}
max_val
+
1
>
auto_val
||
auto_val
==
~
(
Uint64
)
0
)
return
ret
;
{
r
=
m_ndb
->
setAutoIncrementValue
(
get_table
(
table
.
m_dictTable
),
max_val
+
1
,
false
);
if
(
r
==
-
1
&&
m_ndb
->
getNdbError
().
status
==
NdbError
::
TemporaryError
)
{
NdbSleep_MilliSleep
(
50
);
continue
;
// retry
}
ret
=
(
r
==
0
);
}
return
(
ret
);
}
while
(
1
);
}
}
bool
bool
...
@@ -217,9 +238,6 @@ BackupRestore::table(const TableS & table){
...
@@ -217,9 +238,6 @@ BackupRestore::table(const TableS & table){
err
<<
"Unable to find table: "
<<
split
[
2
].
c_str
()
<<
endl
;
err
<<
"Unable to find table: "
<<
split
[
2
].
c_str
()
<<
endl
;
return
false
;
return
false
;
}
}
if
(
m_restore_meta
){
m_ndb
->
setAutoIncrementValue
(
tab
,
~
(
Uint64
)
0
,
false
);
}
const
NdbDictionary
::
Table
*
null
=
0
;
const
NdbDictionary
::
Table
*
null
=
0
;
m_new_tables
.
fill
(
table
.
m_dictTable
->
getTableId
(),
null
);
m_new_tables
.
fill
(
table
.
m_dictTable
->
getTableId
(),
null
);
m_new_tables
[
table
.
m_dictTable
->
getTableId
()]
=
tab
;
m_new_tables
[
table
.
m_dictTable
->
getTableId
()]
=
tab
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment