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 07c67c43
authored
Jan 28, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix transaction memory leak issue
1 parent
048516f8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
7 deletions
lib/dialects/connector-manager.js
lib/dialects/mariadb/connector-manager.js
lib/dialects/mysql/connector-manager.js
lib/dialects/postgres/connector-manager.js
lib/transaction-manager.js
lib/transaction.js
lib/dialects/connector-manager.js
View file @
07c67c4
...
@@ -24,5 +24,11 @@ module.exports = (function(){
...
@@ -24,5 +24,11 @@ module.exports = (function(){
this
.
connect
()
this
.
connect
()
}
}
ConnectorManager
.
prototype
.
cleanup
=
function
()
{
if
(
this
.
onProcessExit
)
{
process
.
removeListener
(
'exit'
,
this
.
onProcessExit
)
}
}
return
ConnectorManager
return
ConnectorManager
})()
})()
lib/dialects/mariadb/connector-manager.js
View file @
07c67c4
...
@@ -142,7 +142,7 @@ module.exports = (function() {
...
@@ -142,7 +142,7 @@ module.exports = (function() {
})
})
}
}
process
.
on
(
'exit'
,
function
()
{
this
.
onProcessExit
=
function
()
{
//be nice & close our connections on exit
//be nice & close our connections on exit
if
(
self
.
pool
)
{
if
(
self
.
pool
)
{
self
.
pool
.
drain
()
self
.
pool
.
drain
()
...
@@ -151,7 +151,9 @@ module.exports = (function() {
...
@@ -151,7 +151,9 @@ module.exports = (function() {
}
}
return
return
})
}.
bind
(
this
);
process
.
on
(
'exit'
,
this
.
onProcessExit
)
}
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
...
...
lib/dialects/mysql/connector-manager.js
View file @
07c67c4
...
@@ -143,7 +143,7 @@ module.exports = (function() {
...
@@ -143,7 +143,7 @@ module.exports = (function() {
})
})
}
}
process
.
on
(
'exit'
,
function
()
{
this
.
onProcessExit
=
function
()
{
//be nice & close our connections on exit
//be nice & close our connections on exit
if
(
self
.
pool
)
{
if
(
self
.
pool
)
{
self
.
pool
.
drain
()
self
.
pool
.
drain
()
...
@@ -152,7 +152,9 @@ module.exports = (function() {
...
@@ -152,7 +152,9 @@ module.exports = (function() {
}
}
return
return
})
}.
bind
(
this
);
process
.
on
(
'exit'
,
this
.
onProcessExit
)
}
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
);
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
);
...
...
lib/dialects/postgres/connector-manager.js
View file @
07c67c4
...
@@ -30,9 +30,11 @@ module.exports = (function() {
...
@@ -30,9 +30,11 @@ module.exports = (function() {
this
.
clientDrained
=
true
this
.
clientDrained
=
true
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
process
.
on
(
'exit'
,
function
()
{
this
.
onProcessExit
=
function
()
{
this
.
disconnect
()
this
.
disconnect
()
}.
bind
(
this
))
}.
bind
(
this
);
process
.
on
(
'exit'
,
this
.
onProcessExit
)
}
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
...
...
lib/transaction-manager.js
View file @
07c67c4
...
@@ -35,6 +35,11 @@ TransactionManager.prototype.getConnectorManager = function(uuid) {
...
@@ -35,6 +35,11 @@ TransactionManager.prototype.getConnectorManager = function(uuid) {
return
this
.
connectorManagers
[
uuid
]
return
this
.
connectorManagers
[
uuid
]
}
}
TransactionManager
.
prototype
.
releaseConnectionManager
=
function
(
uuid
)
{
this
.
connectorManagers
[
uuid
].
cleanup
();
delete
this
.
connectorManagers
[
uuid
]
}
TransactionManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
TransactionManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
options
.
uuid
=
'default'
options
.
uuid
=
'default'
...
...
lib/transaction.js
View file @
07c67c4
...
@@ -25,6 +25,7 @@ Transaction.prototype.commit = function() {
...
@@ -25,6 +25,7 @@ Transaction.prototype.commit = function() {
.
getQueryInterface
()
.
getQueryInterface
()
.
commitTransaction
(
this
,
{})
.
commitTransaction
(
this
,
{})
.
proxy
(
this
)
.
proxy
(
this
)
.
done
(
this
.
cleanup
.
bind
(
this
))
}
}
...
@@ -34,6 +35,7 @@ Transaction.prototype.rollback = function() {
...
@@ -34,6 +35,7 @@ Transaction.prototype.rollback = function() {
.
getQueryInterface
()
.
getQueryInterface
()
.
rollbackTransaction
(
this
,
{})
.
rollbackTransaction
(
this
,
{})
.
proxy
(
this
)
.
proxy
(
this
)
.
done
(
this
.
cleanup
.
bind
(
this
))
}
}
Transaction
.
prototype
.
prepareEnvironment
=
function
(
callback
)
{
Transaction
.
prototype
.
prepareEnvironment
=
function
(
callback
)
{
...
@@ -76,8 +78,12 @@ Transaction.prototype.setIsolationLevel = function(callback) {
...
@@ -76,8 +78,12 @@ Transaction.prototype.setIsolationLevel = function(callback) {
.
error
(
onError
.
bind
(
this
))
.
error
(
onError
.
bind
(
this
))
}
}
Transaction
.
prototype
.
cleanup
=
function
()
{
this
.
sequelize
.
transactionManager
.
releaseConnectionManager
(
this
.
id
)
}
// private
// private
var
onError
=
function
(
err
)
{
var
onError
=
function
(
err
)
{
this
.
emit
(
'error'
,
err
)
this
.
emit
(
'error'
,
err
)
}
}
\ No newline at end of file
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