Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 692cb488
authored
May 02, 2013
by
Joshua Frederick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding connection validation and handling of PROTOCOL_CONNECTION_LOST errors
1 parent
ffb50122
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
lib/dialects/mysql/connector-manager.js
lib/dialects/mysql/connector-manager.js
View file @
692cb48
...
@@ -19,7 +19,9 @@ module.exports = (function() {
...
@@ -19,7 +19,9 @@ module.exports = (function() {
this
.
poolCfg
=
Utils
.
_
.
defaults
(
this
.
config
.
pool
,
{
this
.
poolCfg
=
Utils
.
_
.
defaults
(
this
.
config
.
pool
,
{
maxConnections
:
10
,
maxConnections
:
10
,
minConnections
:
0
,
minConnections
:
0
,
maxIdleTime
:
1000
maxIdleTime
:
1000
,
handleDisconnects
:
false
,
validate
:
validateConnection
});
});
this
.
pendingQueries
=
0
;
this
.
pendingQueries
=
0
;
this
.
useReplicaton
=
!!
config
.
replication
;
this
.
useReplicaton
=
!!
config
.
replication
;
...
@@ -83,6 +85,7 @@ module.exports = (function() {
...
@@ -83,6 +85,7 @@ module.exports = (function() {
destroy
:
function
(
client
)
{
destroy
:
function
(
client
)
{
disconnect
.
call
(
self
,
client
)
disconnect
.
call
(
self
,
client
)
},
},
validate
:
self
.
poolCfg
.
validate
,
max
:
self
.
poolCfg
.
maxConnections
,
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
min
:
self
.
poolCfg
.
minConnections
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
...
@@ -98,6 +101,7 @@ module.exports = (function() {
...
@@ -98,6 +101,7 @@ module.exports = (function() {
destroy
:
function
(
client
)
{
destroy
:
function
(
client
)
{
disconnect
.
call
(
self
,
client
)
disconnect
.
call
(
self
,
client
)
},
},
validate
:
self
.
poolCfg
.
validate
,
max
:
self
.
poolCfg
.
maxConnections
,
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
min
:
self
.
poolCfg
.
minConnections
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
...
@@ -115,6 +119,7 @@ module.exports = (function() {
...
@@ -115,6 +119,7 @@ module.exports = (function() {
},
},
max
:
self
.
poolCfg
.
maxConnections
,
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
min
:
self
.
poolCfg
.
minConnections
,
validate
:
self
.
poolCfg
.
validate
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
})
})
}
}
...
@@ -247,10 +252,25 @@ module.exports = (function() {
...
@@ -247,10 +252,25 @@ module.exports = (function() {
connection
.
query
(
"SET time_zone = '+0:00'"
);
connection
.
query
(
"SET time_zone = '+0:00'"
);
// client.setMaxListeners(self.maxConcurrentQueries)
// client.setMaxListeners(self.maxConcurrentQueries)
this
.
isConnecting
=
false
this
.
isConnecting
=
false
if
(
config
.
pool
.
handleDisconnects
)
{
handleDisconnect
(
this
.
pool
,
connection
)
}
done
(
null
,
connection
)
done
(
null
,
connection
)
}
}
var
handleDisconnect
=
function
(
pool
,
client
)
{
client
.
on
(
'error'
,
function
(
err
)
{
if
(
err
.
code
!==
'PROTOCOL_CONNECTION_LOST'
)
{
throw
err
}
pool
.
destroy
(
client
)
})
}
var
validateConnection
=
function
(
client
)
{
return
client
&&
client
.
state
!=
'disconnected'
}
var
enqueue
=
function
(
queueItem
,
options
)
{
var
enqueue
=
function
(
queueItem
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
if
(
this
.
activeQueue
.
length
<
this
.
maxConcurrentQueries
)
{
if
(
this
.
activeQueue
.
length
<
this
.
maxConcurrentQueries
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment