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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
fd8b0f26
Commit
fd8b0f26
authored
Dec 13, 2004
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - Handle shm-transporter wo/ busy-wait + also
handled mixed tcp/shm transporters + bug#7124
parent
4614cdfa
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
336 additions
and
248 deletions
+336
-248
ndb/src/common/transporter/SHM_Transporter.cpp
ndb/src/common/transporter/SHM_Transporter.cpp
+39
-44
ndb/src/common/transporter/SHM_Transporter.hpp
ndb/src/common/transporter/SHM_Transporter.hpp
+24
-9
ndb/src/common/transporter/TransporterRegistry.cpp
ndb/src/common/transporter/TransporterRegistry.cpp
+213
-185
ndb/src/kernel/main.cpp
ndb/src/kernel/main.cpp
+3
-0
ndb/src/mgmsrv/ConfigInfo.cpp
ndb/src/mgmsrv/ConfigInfo.cpp
+53
-10
ndb/src/ndbapi/TransporterFacade.cpp
ndb/src/ndbapi/TransporterFacade.cpp
+4
-0
No files found.
ndb/src/common/transporter/SHM_Transporter.cpp
View file @
fd8b0f26
...
@@ -26,6 +26,8 @@
...
@@ -26,6 +26,8 @@
#include <InputStream.hpp>
#include <InputStream.hpp>
#include <OutputStream.hpp>
#include <OutputStream.hpp>
extern
int
g_shm_pid
;
SHM_Transporter
::
SHM_Transporter
(
TransporterRegistry
&
t_reg
,
SHM_Transporter
::
SHM_Transporter
(
TransporterRegistry
&
t_reg
,
const
char
*
lHostName
,
const
char
*
lHostName
,
const
char
*
rHostName
,
const
char
*
rHostName
,
...
@@ -52,6 +54,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
...
@@ -52,6 +54,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
#ifdef DEBUG_TRANSPORTER
#ifdef DEBUG_TRANSPORTER
printf
(
"shm key (%d - %d) = %d
\n
"
,
lNodeId
,
rNodeId
,
shmKey
);
printf
(
"shm key (%d - %d) = %d
\n
"
,
lNodeId
,
rNodeId
,
shmKey
);
#endif
#endif
m_signal_threshold
=
4096
;
}
}
SHM_Transporter
::~
SHM_Transporter
(){
SHM_Transporter
::~
SHM_Transporter
(){
...
@@ -182,42 +185,6 @@ SHM_Transporter::setupBuffers(){
...
@@ -182,42 +185,6 @@ SHM_Transporter::setupBuffers(){
#endif
#endif
}
}
#if 0
SendStatus
SHM_Transporter::prepareSend(const SignalHeader * const signalHeader,
Uint8 prio,
const Uint32 * const signalData,
const LinearSegmentPtr ptr[3],
bool force){
if(isConnected()){
const Uint32 lenBytes = m_packer.getMessageLength(signalHeader, ptr);
Uint32 * insertPtr = (Uint32 *)writer->getWritePtr(lenBytes);
if(insertPtr != 0){
m_packer.pack(insertPtr, prio, signalHeader, signalData, ptr);
/**
* Do funky membar stuff
*/
writer->updateWritePtr(lenBytes);
return SEND_OK;
} else {
// NdbSleep_MilliSleep(3);
//goto tryagain;
return SEND_BUFFER_FULL;
}
}
return SEND_DISCONNECTED;
}
#endif
bool
bool
SHM_Transporter
::
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
)
SHM_Transporter
::
connect_server_impl
(
NDB_SOCKET_TYPE
sockfd
)
{
{
...
@@ -247,10 +214,17 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
...
@@ -247,10 +214,17 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd)
}
}
// Send ok to client
// Send ok to client
s_output
.
println
(
"shm server 1 ok
"
);
s_output
.
println
(
"shm server 1 ok
: %d"
,
g_shm_pid
);
// Wait for ok from client
// Wait for ok from client
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
if
(
s_input
.
gets
(
buf
,
256
)
==
0
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
DBUG_RETURN
(
false
);
}
if
(
sscanf
(
buf
,
"shm client 1 ok: %d"
,
&
m_remote_pid
)
!=
1
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
NDB_CLOSE_SOCKET
(
sockfd
);
DBUG_RETURN
(
false
);
DBUG_RETURN
(
false
);
}
}
...
@@ -289,6 +263,12 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
...
@@ -289,6 +263,12 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
DBUG_RETURN
(
false
);
DBUG_RETURN
(
false
);
}
}
if
(
sscanf
(
buf
,
"shm server 1 ok: %d"
,
&
m_remote_pid
)
!=
1
)
{
NDB_CLOSE_SOCKET
(
sockfd
);
DBUG_RETURN
(
false
);
}
// Create
// Create
if
(
!
_shmSegCreated
){
if
(
!
_shmSegCreated
){
if
(
!
ndb_shm_get
())
{
if
(
!
ndb_shm_get
())
{
...
@@ -313,7 +293,7 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
...
@@ -313,7 +293,7 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd)
}
}
// Send ok to server
// Send ok to server
s_output
.
println
(
"shm client 1 ok
"
);
s_output
.
println
(
"shm client 1 ok
: %d"
,
g_shm_pid
);
int
r
=
connect_common
(
sockfd
);
int
r
=
connect_common
(
sockfd
);
...
@@ -344,18 +324,33 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
...
@@ -344,18 +324,33 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd)
return
false
;
return
false
;
}
}
if
(
!
setupBuffersDone
)
{
if
(
!
setupBuffersDone
)
{
setupBuffers
();
setupBuffers
();
setupBuffersDone
=
true
;
setupBuffersDone
=
true
;
}
}
if
(
setupBuffersDone
)
{
if
(
setupBuffersDone
)
{
NdbSleep_MilliSleep
(
m_timeOutMillis
);
NdbSleep_MilliSleep
(
m_timeOutMillis
);
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
if
(
*
serverStatusFlag
==
1
&&
*
clientStatusFlag
==
1
)
{
m_last_signal
=
0
;
return
true
;
return
true
;
}
}
}
DBUG_PRINT
(
"error"
,
(
"Failed to set up buffers to node %d"
,
DBUG_PRINT
(
"error"
,
(
"Failed to set up buffers to node %d"
,
remoteNodeId
));
remoteNodeId
));
return
false
;
return
false
;
}
}
void
SHM_Transporter
::
doSend
()
{
if
(
m_last_signal
)
{
m_last_signal
=
0
;
kill
(
m_remote_pid
,
SIGUSR1
);
}
}
ndb/src/common/transporter/SHM_Transporter.hpp
View file @
fd8b0f26
...
@@ -53,12 +53,19 @@ public:
...
@@ -53,12 +53,19 @@ public:
*/
*/
bool
initTransporter
();
bool
initTransporter
();
Uint32
*
getWritePtr
(
Uint32
lenBytes
,
Uint32
prio
){
Uint32
*
getWritePtr
(
Uint32
lenBytes
,
Uint32
prio
)
{
return
(
Uint32
*
)
writer
->
getWritePtr
(
lenBytes
);
return
(
Uint32
*
)
writer
->
getWritePtr
(
lenBytes
);
}
}
void
updateWritePtr
(
Uint32
lenBytes
,
Uint32
prio
){
void
updateWritePtr
(
Uint32
lenBytes
,
Uint32
prio
)
{
writer
->
updateWritePtr
(
lenBytes
);
writer
->
updateWritePtr
(
lenBytes
);
m_last_signal
+=
lenBytes
;
if
(
m_last_signal
>=
m_signal_threshold
)
{
doSend
();
}
}
}
void
getReceivePtr
(
Uint32
**
ptr
,
Uint32
**
eod
){
void
getReceivePtr
(
Uint32
**
ptr
,
Uint32
**
eod
){
...
@@ -123,6 +130,14 @@ protected:
...
@@ -123,6 +130,14 @@ protected:
*/
*/
void
setupBuffers
();
void
setupBuffers
();
/**
* doSend (i.e signal receiver)
*/
void
doSend
();
int
m_remote_pid
;
Uint32
m_last_signal
;
Uint32
m_signal_threshold
;
private:
private:
bool
_shmSegCreated
;
bool
_shmSegCreated
;
bool
_attached
;
bool
_attached
;
...
...
ndb/src/common/transporter/TransporterRegistry.cpp
View file @
fd8b0f26
This diff is collapsed.
Click to expand it.
ndb/src/kernel/main.cpp
View file @
fd8b0f26
...
@@ -49,6 +49,8 @@ void catchsigs(bool ignore); // for process signal handling
...
@@ -49,6 +49,8 @@ void catchsigs(bool ignore); // for process signal handling
extern
"C"
void
handler_shutdown
(
int
signum
);
// for process signal handling
extern
"C"
void
handler_shutdown
(
int
signum
);
// for process signal handling
extern
"C"
void
handler_error
(
int
signum
);
// for process signal handling
extern
"C"
void
handler_error
(
int
signum
);
// for process signal handling
extern
int
g_shm_pid
;
// Shows system information
// Shows system information
void
systemInfo
(
const
Configuration
&
conf
,
void
systemInfo
(
const
Configuration
&
conf
,
const
LogLevel
&
ll
);
const
LogLevel
&
ll
);
...
@@ -145,6 +147,7 @@ int main(int argc, char** argv)
...
@@ -145,6 +147,7 @@ int main(int argc, char** argv)
}
}
g_eventLogger
.
info
(
"Angel pid: %d ndb pid: %d"
,
getppid
(),
getpid
());
g_eventLogger
.
info
(
"Angel pid: %d ndb pid: %d"
,
getppid
(),
getpid
());
g_shm_pid
=
getpid
();
theConfig
->
setupConfiguration
();
theConfig
->
setupConfiguration
();
systemInfo
(
*
theConfig
,
*
theConfig
->
m_logLevel
);
systemInfo
(
*
theConfig
,
*
theConfig
->
m_logLevel
);
...
...
ndb/src/mgmsrv/ConfigInfo.cpp
View file @
fd8b0f26
...
@@ -82,7 +82,7 @@ static bool transformConnection(InitConfigFileParser::Context & ctx, const char
...
@@ -82,7 +82,7 @@ static bool transformConnection(InitConfigFileParser::Context & ctx, const char
static
bool
applyDefaultValues
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
applyDefaultValues
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
checkMandatory
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
checkMandatory
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
fixPortNumber
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
fixPortNumber
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
fixShm
k
ey
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
fixShm
K
ey
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
checkDbConstraints
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
checkDbConstraints
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
);
static
bool
checkConnectionConstraints
(
InitConfigFileParser
::
Context
&
,
const
char
*
);
static
bool
checkConnectionConstraints
(
InitConfigFileParser
::
Context
&
,
const
char
*
);
static
bool
checkTCPConstraints
(
InitConfigFileParser
::
Context
&
,
const
char
*
);
static
bool
checkTCPConstraints
(
InitConfigFileParser
::
Context
&
,
const
char
*
);
...
@@ -131,13 +131,15 @@ ConfigInfo::m_SectionRules[] = {
...
@@ -131,13 +131,15 @@ ConfigInfo::m_SectionRules[] = {
{
"TCP"
,
fixHostname
,
"HostName2"
},
{
"TCP"
,
fixHostname
,
"HostName2"
},
{
"SCI"
,
fixHostname
,
"HostName1"
},
{
"SCI"
,
fixHostname
,
"HostName1"
},
{
"SCI"
,
fixHostname
,
"HostName2"
},
{
"SCI"
,
fixHostname
,
"HostName2"
},
{
"SHM"
,
fixHostname
,
"HostName1"
},
{
"SHM"
,
fixHostname
,
"HostName2"
},
{
"OSE"
,
fixHostname
,
"HostName1"
},
{
"OSE"
,
fixHostname
,
"HostName1"
},
{
"OSE"
,
fixHostname
,
"HostName2"
},
{
"OSE"
,
fixHostname
,
"HostName2"
},
{
"TCP"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"TCP"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"SHM"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"SHM"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"SCI"
,
fixPortNumber
,
0
},
// has to come after fixHostName
{
"SCI"
,
fixPortNumber
,
0
},
// has to come after fixHostName
//
{ "SHM", fixShmKey, 0 },
{
"SHM"
,
fixShmKey
,
0
},
/**
/**
* fixExtConnection must be after fixNodeId
* fixExtConnection must be after fixNodeId
...
@@ -168,6 +170,8 @@ ConfigInfo::m_SectionRules[] = {
...
@@ -168,6 +170,8 @@ ConfigInfo::m_SectionRules[] = {
{
"TCP"
,
checkTCPConstraints
,
"HostName2"
},
{
"TCP"
,
checkTCPConstraints
,
"HostName2"
},
{
"SCI"
,
checkTCPConstraints
,
"HostName1"
},
{
"SCI"
,
checkTCPConstraints
,
"HostName1"
},
{
"SCI"
,
checkTCPConstraints
,
"HostName2"
},
{
"SCI"
,
checkTCPConstraints
,
"HostName2"
},
{
"SHM"
,
checkTCPConstraints
,
"HostName1"
},
{
"SHM"
,
checkTCPConstraints
,
"HostName2"
},
{
"*"
,
checkMandatory
,
0
},
{
"*"
,
checkMandatory
,
0
},
...
@@ -1687,14 +1691,25 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
...
@@ -1687,14 +1691,25 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0
,
0
},
0
,
0
},
{
{
CFG_CONNECTION_
NOD
E_1
,
CFG_CONNECTION_
HOSTNAM
E_1
,
"
NodeId
1"
,
"
HostName
1"
,
"SHM"
,
"SHM"
,
"
Id of node ("
DB_TOKEN_PRINT
", "
API_TOKEN_PRINT
" or "
MGM_TOKEN_PRINT
")
on one side of the connection"
,
"
Name/IP of computer
on one side of the connection"
,
ConfigInfo
::
USED
,
ConfigInfo
::
INTERNAL
,
false
,
false
,
ConfigInfo
::
STRING
,
ConfigInfo
::
STRING
,
MANDATORY
,
UNDEFINED
,
0
,
0
},
{
CFG_CONNECTION_HOSTNAME_2
,
"HostName2"
,
"SHM"
,
"Name/IP of computer on one side of the connection"
,
ConfigInfo
::
INTERNAL
,
false
,
ConfigInfo
::
STRING
,
UNDEFINED
,
0
,
0
},
0
,
0
},
{
{
...
@@ -1709,6 +1724,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
...
@@ -1709,6 +1724,17 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0"
,
"0"
,
STR_VALUE
(
MAX_INT_RNIL
)
},
STR_VALUE
(
MAX_INT_RNIL
)
},
{
CFG_CONNECTION_NODE_1
,
"NodeId1"
,
"SHM"
,
"Id of node ("
DB_TOKEN_PRINT
", "
API_TOKEN_PRINT
" or "
MGM_TOKEN_PRINT
") on one side of the connection"
,
ConfigInfo
::
USED
,
false
,
ConfigInfo
::
STRING
,
MANDATORY
,
0
,
0
},
{
{
CFG_CONNECTION_NODE_2
,
CFG_CONNECTION_NODE_2
,
"NodeId2"
,
"NodeId2"
,
...
@@ -3025,15 +3051,32 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
...
@@ -3025,15 +3051,32 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
<<
"per connection, please remove from config. "
<<
"per connection, please remove from config. "
<<
"Will be changed to "
<<
port
<<
endl
;
<<
"Will be changed to "
<<
port
<<
endl
;
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
,
true
);
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
,
true
);
}
else
}
else
{
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
);
ctx
.
m_currentSection
->
put
(
"PortNumber"
,
port
);
}
DBUG_PRINT
(
"info"
,
(
"connection %d-%d port %d host %s"
,
DBUG_PRINT
(
"info"
,
(
"connection %d-%d port %d host %s"
,
id1
,
id2
,
port
,
hostname
.
c_str
()));
id1
,
id2
,
port
,
hostname
.
c_str
()));
DBUG_RETURN
(
true
);
DBUG_RETURN
(
true
);
}
}
static
bool
fixShmKey
(
InitConfigFileParser
::
Context
&
ctx
,
const
char
*
)
{
Uint32
id1
=
0
,
id2
=
0
,
key
=
0
;
require
(
ctx
.
m_currentSection
->
get
(
"NodeId1"
,
&
id1
));
require
(
ctx
.
m_currentSection
->
get
(
"NodeId2"
,
&
id2
));
if
(
ctx
.
m_currentSection
->
get
(
"ShmKey"
,
&
key
))
return
true
;
key
=
(
id1
>
id2
?
id1
<<
16
|
id2
:
id2
<<
16
|
id1
);
ctx
.
m_currentSection
->
put
(
"ShmKey"
,
key
);
return
true
;
}
/**
/**
* DB Node rule: Check various constraints
* DB Node rule: Check various constraints
*/
*/
...
...
ndb/src/ndbapi/TransporterFacade.cpp
View file @
fd8b0f26
...
@@ -450,8 +450,12 @@ runReceiveResponse_C(void * me)
...
@@ -450,8 +450,12 @@ runReceiveResponse_C(void * me)
return
me
;
return
me
;
}
}
extern
int
g_shm_pid
;
void
TransporterFacade
::
threadMainReceive
(
void
)
void
TransporterFacade
::
threadMainReceive
(
void
)
{
{
g_shm_pid
=
getpid
();
theTransporterRegistry
->
startReceiving
();
theTransporterRegistry
->
startReceiving
();
NdbMutex_Lock
(
theMutexPtr
);
NdbMutex_Lock
(
theMutexPtr
);
theTransporterRegistry
->
update_connections
();
theTransporterRegistry
->
update_connections
();
...
...
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