Skip to content

Commit 548d47d

Browse files
HCK-10544: $collstats error AWS (#25)
<!--do not remove this marker, its needed to replace info when ticket title is updated --> <!--jira-description-action-hidden-marker-start--> <table> <td> <a href="https://hackolade.atlassian.net/browse/HCK-10544" title="HCK-10544" target="_blank"><img alt="Sub-bug" src="https://hackolade.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10303?size=medium" />HCK-10544</a> Documents count failed to fetch using a built-in `$collStats` pipeline </td></table> <br /> <!--jira-description-action-hidden-marker-end--> ## Technical details * handled unsupported pipeline of getting documents count on AWS with a direct invoke of a similar command
1 parent f14b11b commit 548d47d

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

forward_engineering/helpers/applyToInstanceHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const applyToInstanceHelper = {
5454
try {
5555
logger.clear();
5656
log.info(getSystemInfo(connectionInfo.appVersion));
57-
log.info(connectionInfo);
57+
log.info(connectionInfo, 'connectionInfo');
5858

5959
await connectionHelper.connect(connectionInfo, sshService);
6060
connectionHelper.close(sshService);

reverse_engineering/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
try {
2323
logger.clear();
2424
log.info(getSystemInfo(connectionInfo.appVersion));
25-
log.info(connectionInfo);
25+
log.info(connectionInfo, 'connectionInfo');
2626

2727
await connectionHelper.connect(connectionInfo, sshService);
2828

@@ -58,7 +58,7 @@ module.exports = {
5858

5959
logger.clear();
6060
log.info(getSystemInfo(connectionInfo.appVersion));
61-
log.info(connectionInfo);
61+
log.info(connectionInfo, 'connectionInfo');
6262

6363
const includeSystemCollection = connectionInfo.includeSystemCollection;
6464
const connection = await connectionHelper.connect(connectionInfo, sshService);

shared/logHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const toTime = number => {
4545

4646
const createLogger = ({ title, logger, hiddenKeys }) => {
4747
return {
48-
info(message) {
49-
logger.log('info', { message }, title, hiddenKeys);
48+
info(message, infoTitle) {
49+
logger.log('info', message, infoTitle || title, hiddenKeys);
5050
},
5151

5252
progress(message, dbName = '', tableName = '') {

shared/mongoDbClient.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,24 @@ const createConnection = ({ connection }) => {
222222
});
223223
};
224224

225+
const getCountByDirectCommand = ({ db, collectionName, scale = 1000000 }) =>
226+
db.command({ collStats: collectionName, scale }).catch(err => Promise.reject(getError(err)));
227+
225228
const getCount = (dbName, collectionName) => {
226229
return new Promise((resolve, reject) => {
227230
const db = connection.db(dbName);
228231
const collection = db.collection(collectionName);
229232

230233
collection.estimatedDocumentCount((err, count) => {
231-
if (err) {
232-
return reject(getError(err));
233-
} else {
234+
if (!err) {
234235
return resolve(count);
235236
}
237+
238+
if (err.message.includes('Unrecognized pipeline stage name: $collStats')) {
239+
return getCountByDirectCommand({ db, collectionName }).then(resolve).catch(reject);
240+
}
241+
242+
return reject(getError(err));
236243
});
237244
});
238245
};

0 commit comments

Comments
 (0)