Fix appdb get query
the get() query was wrong when we had multiple port bindings. we did apps JOIN X JOIN Y JOIN Z. This will return apps times x times y times z rows. this just accidentally worked in the past. when we have multiple mounts, we get duplicate values now. the fix is do the joins separately and then merge them together. an alternate approach to this mega query is to SET TRANSACTION SERIALIZABLE and do multiple selects. but that requires database.js support which is a bit of work (and not sure how it works with "connections").
This commit is contained in:
19
src/apps.js
19
src/apps.js
@@ -6,7 +6,6 @@ exports = module.exports = {
|
||||
removeRestrictedFields,
|
||||
|
||||
get,
|
||||
getByContainerId,
|
||||
getByIpAddress,
|
||||
getByFqdn,
|
||||
getAll,
|
||||
@@ -508,24 +507,6 @@ function get(appId, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getByContainerId(containerId, callback) {
|
||||
assert.strictEqual(typeof containerId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
getDomainObjectMap(function (error, domainObjectMap) {
|
||||
if (error) return callback(error);
|
||||
|
||||
appdb.getByContainerId(containerId, function (error, app) {
|
||||
if (error && error.reason === BoxError.NOT_FOUND) return callback(new BoxError(BoxError.NOT_FOUND, 'No such app'));
|
||||
if (error) return callback(error);
|
||||
|
||||
postProcess(app, domainObjectMap);
|
||||
|
||||
callback(null, app);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// returns the app associated with this IP (app or scheduler)
|
||||
function getByIpAddress(ip, callback) {
|
||||
assert.strictEqual(typeof ip, 'string');
|
||||
|
||||
Reference in New Issue
Block a user