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
27a6a814
Commit
27a6a814
authored
Apr 27, 2005
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for avoiding gettin Invalid schema object version when doing local changes
parent
b580f8dd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
21 deletions
+99
-21
mysql-test/r/ndb_multi.result
mysql-test/r/ndb_multi.result
+21
-1
mysql-test/t/ndb_multi.test
mysql-test/t/ndb_multi.test
+24
-0
ndb/include/ndbapi/NdbDictionary.hpp
ndb/include/ndbapi/NdbDictionary.hpp
+4
-1
ndb/src/ndbapi/NdbDictionaryImpl.cpp
ndb/src/ndbapi/NdbDictionaryImpl.cpp
+7
-4
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+41
-13
sql/ha_ndbcluster.h
sql/ha_ndbcluster.h
+2
-2
No files found.
mysql-test/r/ndb_multi.result
View file @
27a6a814
...
...
@@ -13,6 +13,26 @@ a
show status like 'handler_discover%';
Variable_name Value
Handler_discover 0
select * from t1;
a
2
drop table t1;
create table t1 (a int) engine=ndbcluster;
insert into t1 value (2);
select * from t1;
a
2
show status like 'handler_discover%';
Variable_name Value
Handler_discover 0
drop table t1;
create table t1 (a int) engine=ndbcluster;
insert into t1 value (2);
select * from t1;
ERROR HY000: Got error 241 'Invalid schema object version' from ndbcluster
select * from t1;
a
2
flush status;
select * from t1;
a
...
...
@@ -20,7 +40,7 @@ a
update t1 set a=3 where a=2;
show status like 'handler_discover%';
Variable_name Value
Handler_discover
1
Handler_discover
0
create table t3 (a int not null primary key, b varchar(22),
c int, last_col text) engine=ndb;
insert into t3 values(1, 'Hi!', 89, 'Longtext column');
...
...
mysql-test/t/ndb_multi.test
View file @
27a6a814
...
...
@@ -18,6 +18,30 @@ select * from t1;
select
*
from
t2
;
show
status
like
'handler_discover%'
;
# Check dropping and recreating table on same server
connect
(
con1
,
localhost
,,,
test
);
connect
(
con2
,
localhost
,,,
test
);
connection
con1
;
select
*
from
t1
;
connection
con2
;
drop
table
t1
;
create
table
t1
(
a
int
)
engine
=
ndbcluster
;
insert
into
t1
value
(
2
);
connection
con1
;
select
*
from
t1
;
# Check dropping and recreating table on different server
connection
server2
;
show
status
like
'handler_discover%'
;
drop
table
t1
;
create
table
t1
(
a
int
)
engine
=
ndbcluster
;
insert
into
t1
value
(
2
);
connection
server1
;
# Currently a retry is required remotely
--
error
1296
select
*
from
t1
;
select
*
from
t1
;
# Connect to server2 and use the tables from there
connection
server2
;
flush
status
;
...
...
ndb/include/ndbapi/NdbDictionary.hpp
View file @
27a6a814
...
...
@@ -75,8 +75,11 @@ public:
Changed
,
///< The object has been modified in memory
///< and has to be commited in NDB Kernel for
///< changes to take effect
Retrieved
///< The object exist and has been read
Retrieved
,
///< The object exist and has been read
///< into main memory from NDB Kernel
Invalid
///< The object has been invalidated
///< and should not be used
};
/**
...
...
ndb/src/ndbapi/NdbDictionaryImpl.cpp
View file @
27a6a814
...
...
@@ -1448,6 +1448,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl)
// If in local cache it must be in global
if
(
!
cachedImpl
)
abort
();
cachedImpl
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
cachedImpl
);
m_globalHash
->
unlock
();
}
...
...
@@ -1747,8 +1748,8 @@ NdbDictionaryImpl::dropTable(const char * name)
DBUG_PRINT
(
"info"
,(
"INCOMPATIBLE_VERSION internal_name: %s"
,
internalTableName
));
m_localHash
.
drop
(
internalTableName
);
m_globalHash
->
lock
();
tab
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
tab
);
m_globalHash
->
unlock
();
DBUG_RETURN
(
dropTable
(
name
));
...
...
@@ -1792,10 +1793,11 @@ NdbDictionaryImpl::dropTable(NdbTableImpl & impl)
int
ret
=
m_receiver
.
dropTable
(
impl
);
if
(
ret
==
0
||
m_error
.
code
==
709
){
const
char
*
internalTableName
=
impl
.
m_internalName
.
c_str
();
m_localHash
.
drop
(
internalTableName
);
m_globalHash
->
lock
();
impl
.
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
&
impl
);
m_globalHash
->
unlock
();
...
...
@@ -1889,6 +1891,7 @@ NdbDictionaryImpl::invalidateObject(NdbTableImpl & impl)
m_localHash
.
drop
(
internalTableName
);
m_globalHash
->
lock
();
impl
.
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
&
impl
);
m_globalHash
->
unlock
();
return
0
;
...
...
@@ -2152,8 +2155,8 @@ NdbDictionaryImpl::dropIndex(const char * indexName,
m_ndb
.
internalizeTableName
(
indexName
);
// Index is also a table
m_localHash
.
drop
(
internalIndexName
);
m_globalHash
->
lock
();
idx
->
m_table
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
idx
->
m_table
);
m_globalHash
->
unlock
();
return
dropIndex
(
indexName
,
tableName
);
...
...
@@ -2187,8 +2190,8 @@ NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName)
int
ret
=
m_receiver
.
dropIndex
(
impl
,
*
timpl
);
if
(
ret
==
0
){
m_localHash
.
drop
(
internalIndexName
);
m_globalHash
->
lock
();
impl
.
m_table
->
m_status
=
NdbDictionary
::
Object
::
Invalid
;
m_globalHash
->
drop
(
impl
.
m_table
);
m_globalHash
->
unlock
();
}
...
...
sql/ha_ndbcluster.cc
View file @
27a6a814
...
...
@@ -331,11 +331,14 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd)
# The mapped error code
*/
void
ha_ndbcluster
::
invalidate
DictionaryCache
(
)
void
ha_ndbcluster
::
invalidate
_dictionary_cache
(
bool
global
)
{
NDBDICT
*
dict
=
get_ndb
()
->
getDictionary
();
DBUG_PRINT
(
"info"
,
(
"invalidating %s"
,
m_tabname
));
dict
->
invalidateTable
(
m_tabname
);
if
(
global
)
dict
->
invalidateTable
(
m_tabname
);
else
dict
->
removeCachedTable
(
m_tabname
);
table
->
version
=
0L
;
/* Free when thread is ready */
/* Invalidate indexes */
for
(
uint
i
=
0
;
i
<
table
->
keys
;
i
++
)
...
...
@@ -347,12 +350,21 @@ void ha_ndbcluster::invalidateDictionaryCache()
switch
(
idx_type
)
{
case
(
PRIMARY_KEY_ORDERED_INDEX
):
case
(
ORDERED_INDEX
):
dict
->
invalidateIndex
(
index
->
getName
(),
m_tabname
);
if
(
global
)
dict
->
invalidateIndex
(
index
->
getName
(),
m_tabname
);
else
dict
->
removeCachedIndex
(
index
->
getName
(),
m_tabname
);
break
;
case
(
UNIQUE_ORDERED_INDEX
):
dict
->
invalidateIndex
(
index
->
getName
(),
m_tabname
);
if
(
global
)
dict
->
invalidateIndex
(
index
->
getName
(),
m_tabname
);
else
dict
->
removeCachedIndex
(
index
->
getName
(),
m_tabname
);
case
(
UNIQUE_INDEX
):
dict
->
invalidateIndex
(
unique_index
->
getName
(),
m_tabname
);
if
(
global
)
dict
->
invalidateIndex
(
unique_index
->
getName
(),
m_tabname
);
else
dict
->
removeCachedIndex
(
unique_index
->
getName
(),
m_tabname
);
break
;
case
(
PRIMARY_KEY_INDEX
):
case
(
UNDEFINED_INDEX
):
...
...
@@ -371,7 +383,7 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans)
switch
(
err
.
classification
)
{
case
NdbError
:
:
SchemaError
:
{
invalidate
DictionaryCache
(
);
invalidate
_dictionary_cache
(
TRUE
);
if
(
err
.
code
==
284
)
{
...
...
@@ -767,7 +779,13 @@ int ha_ndbcluster::get_metadata(const char *path)
if
(
!
(
tab
=
dict
->
getTable
(
m_tabname
)))
ERR_RETURN
(
dict
->
getNdbError
());
DBUG_PRINT
(
"info"
,
(
"Table schema version: %d"
,
tab
->
getObjectVersion
()));
if
(
tab
->
getObjectStatus
()
==
NdbDictionary
::
Object
::
Invalid
)
{
invalidate_dictionary_cache
(
FALSE
);
if
(
!
(
tab
=
dict
->
getTable
(
m_tabname
)))
ERR_RETURN
(
dict
->
getNdbError
());
DBUG_PRINT
(
"info"
,
(
"Table schema version: %d"
,
tab
->
getObjectVersion
()));
}
/*
Compare FrmData in NDB with frm file from disk.
*/
...
...
@@ -786,7 +804,7 @@ int ha_ndbcluster::get_metadata(const char *path)
if
(
!
invalidating_ndb_table
)
{
DBUG_PRINT
(
"info"
,
(
"Invalidating table"
));
invalidate
DictionaryCache
(
);
invalidate
_dictionary_cache
(
TRUE
);
invalidating_ndb_table
=
TRUE
;
}
else
...
...
@@ -812,7 +830,7 @@ int ha_ndbcluster::get_metadata(const char *path)
if
(
error
)
DBUG_RETURN
(
error
);
m_table
V
ersion
=
tab
->
getObjectVersion
();
m_table
_v
ersion
=
tab
->
getObjectVersion
();
m_table
=
(
void
*
)
tab
;
m_table_info
=
NULL
;
// Set in external lock
...
...
@@ -3226,15 +3244,25 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
void
*
tab_info
;
if
(
!
(
tab
=
dict
->
getTable
(
m_tabname
,
&
tab_info
)))
ERR_RETURN
(
dict
->
getNdbError
());
DBUG_PRINT
(
"info"
,
(
"Table schema version: %d"
,
tab
->
getObjectVersion
()));
if
(
m_table
!=
(
void
*
)
tab
||
m_tableVersion
!=
tab
->
getObjectVersion
())
DBUG_PRINT
(
"info"
,
(
"Table schema version: %d"
,
tab
->
getObjectVersion
()));
// Check if thread has stale local cache
if
(
tab
->
getObjectStatus
()
==
NdbDictionary
::
Object
::
Invalid
)
{
invalidate_dictionary_cache
(
FALSE
);
if
(
!
(
tab
=
dict
->
getTable
(
m_tabname
)))
ERR_RETURN
(
dict
->
getNdbError
());
DBUG_PRINT
(
"info"
,
(
"Table schema version: %d"
,
tab
->
getObjectVersion
()));
}
if
(
m_table
!=
(
void
*
)
tab
||
m_table_version
<
tab
->
getObjectVersion
())
{
/*
The table has been altered, refresh the index list
*/
build_index_list
(
ndb
,
table
,
ILBP_OPEN
);
m_table
=
(
void
*
)
tab
;
m_table
V
ersion
=
tab
->
getObjectVersion
();
m_table
_v
ersion
=
tab
->
getObjectVersion
();
}
m_table_info
=
tab_info
;
}
...
...
@@ -4006,7 +4034,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_active_trans
(
NULL
),
m_active_cursor
(
NULL
),
m_table
(
NULL
),
m_table
V
ersion
(
-
1
),
m_table
_v
ersion
(
-
1
),
m_table_info
(
NULL
),
m_table_flags
(
HA_REC_NOT_IN_SEQ
|
HA_NULL_IN_KEY
|
...
...
sql/ha_ndbcluster.h
View file @
27a6a814
...
...
@@ -203,7 +203,7 @@ class ha_ndbcluster: public handler
void
print_results
();
longlong
get_auto_increment
();
void
invalidate
DictionaryCache
(
);
void
invalidate
_dictionary_cache
(
bool
global
);
int
ndb_err
(
NdbConnection
*
);
bool
uses_blob_value
(
bool
all_fields
);
...
...
@@ -215,7 +215,7 @@ class ha_ndbcluster: public handler
NdbConnection
*
m_active_trans
;
NdbResultSet
*
m_active_cursor
;
void
*
m_table
;
int
m_table
V
ersion
;
int
m_table
_v
ersion
;
void
*
m_table_info
;
char
m_dbname
[
FN_HEADLEN
];
//char m_schemaname[FN_HEADLEN];
...
...
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