@@ -1083,49 +1083,52 @@ class DataServiceImpl extends WithLogContext implements DataService {
10831083 try {
10841084 const coll = this . _collection ( ns , 'CRUD' ) ;
10851085 const collStats = await coll
1086- . aggregate ( [
1087- { $collStats : { storageStats : { } } } ,
1088- {
1089- $group : {
1090- _id : null ,
1091- capped : { $first : '$storageStats.capped' } ,
1092- count : { $sum : '$storageStats.count' } ,
1093- size : { $sum : { $toDouble : '$storageStats.size' } } ,
1094- storageSize : {
1095- $sum : { $toDouble : '$storageStats.storageSize' } ,
1096- } ,
1097- totalIndexSize : {
1098- $sum : { $toDouble : '$storageStats.totalIndexSize' } ,
1099- } ,
1100- freeStorageSize : {
1101- $sum : { $toDouble : '$storageStats.freeStorageSize' } ,
1102- } ,
1103- unscaledCollSize : {
1104- $sum : {
1105- $multiply : [
1106- { $toDouble : '$storageStats.avgObjSize' } ,
1107- { $toDouble : '$storageStats.count' } ,
1108- ] ,
1086+ . aggregate (
1087+ [
1088+ { $collStats : { storageStats : { } } } ,
1089+ {
1090+ $group : {
1091+ _id : null ,
1092+ capped : { $first : '$storageStats.capped' } ,
1093+ count : { $sum : '$storageStats.count' } ,
1094+ size : { $sum : { $toDouble : '$storageStats.size' } } ,
1095+ storageSize : {
1096+ $sum : { $toDouble : '$storageStats.storageSize' } ,
11091097 } ,
1098+ totalIndexSize : {
1099+ $sum : { $toDouble : '$storageStats.totalIndexSize' } ,
1100+ } ,
1101+ freeStorageSize : {
1102+ $sum : { $toDouble : '$storageStats.freeStorageSize' } ,
1103+ } ,
1104+ unscaledCollSize : {
1105+ $sum : {
1106+ $multiply : [
1107+ { $toDouble : '$storageStats.avgObjSize' } ,
1108+ { $toDouble : '$storageStats.count' } ,
1109+ ] ,
1110+ } ,
1111+ } ,
1112+ nindexes : { $max : '$storageStats.nindexes' } ,
11101113 } ,
1111- nindexes : { $max : '$storageStats.nindexes' } ,
11121114 } ,
1113- } ,
1114- {
1115- $addFields : {
1116- // `avgObjSize` is the average of per-shard `avgObjSize` weighted by `count`
1117- avgObjSize : {
1118- $cond : {
1119- if : { $ne : [ '$count' , 0 ] } ,
1120- then : {
1121- $divide : [ '$unscaledCollSize' , { $toDouble : '$count' } ] ,
1115+ {
1116+ $addFields : {
1117+ // `avgObjSize` is the average of per-shard `avgObjSize` weighted by `count`
1118+ avgObjSize : {
1119+ $cond : {
1120+ if : { $ne : [ '$count' , 0 ] } ,
1121+ then : {
1122+ $divide : [ '$unscaledCollSize' , { $toDouble : '$count' } ] ,
1123+ } ,
1124+ else : 0 ,
11221125 } ,
1123- else : 0 ,
11241126 } ,
11251127 } ,
11261128 } ,
1127- } ,
1128- ] )
1129+ ] ,
1130+ { enableUtf8Validation : false }
1131+ )
11291132 . toArray ( ) ;
11301133
11311134 if ( ! collStats || collStats [ 0 ] === undefined ) {
@@ -1165,7 +1168,11 @@ class DataServiceImpl extends WithLogContext implements DataService {
11651168 @op ( mongoLogId ( 1_001_000_031 ) )
11661169 async killOp ( id : number , comment ?: string ) : Promise < Document > {
11671170 const db = this . _database ( 'admin' , 'META' ) ;
1168- return runCommand ( db , { killOp : 1 , id, comment } ) ;
1171+ return runCommand (
1172+ db ,
1173+ { killOp : 1 , id, comment } ,
1174+ { enableUtf8Validation : false }
1175+ ) ;
11691176 }
11701177
11711178 isWritable ( ) : boolean {
@@ -1183,10 +1190,14 @@ class DataServiceImpl extends WithLogContext implements DataService {
11831190 @op ( mongoLogId ( 1_001_000_100 ) )
11841191 private async _connectionStatus ( ) : Promise < ConnectionStatusWithPrivileges > {
11851192 const adminDb = this . _database ( 'admin' , 'META' ) ;
1186- return await runCommand ( adminDb , {
1187- connectionStatus : 1 ,
1188- showPrivileges : true ,
1189- } ) ;
1193+ return await runCommand (
1194+ adminDb ,
1195+ {
1196+ connectionStatus : 1 ,
1197+ showPrivileges : true ,
1198+ } ,
1199+ { enableUtf8Validation : false }
1200+ ) ;
11901201 }
11911202
11921203 private async _getPrivilegesOrFallback (
@@ -1341,12 +1352,16 @@ class DataServiceImpl extends WithLogContext implements DataService {
13411352
13421353 const listDatabases = async ( ) => {
13431354 try {
1344- const { databases } = await runCommand ( adminDb , {
1345- listDatabases : 1 ,
1346- nameOnly,
1347- } as {
1348- listDatabases : 1 ;
1349- } ) ;
1355+ const { databases } = await runCommand (
1356+ adminDb ,
1357+ {
1358+ listDatabases : 1 ,
1359+ nameOnly,
1360+ } as {
1361+ listDatabases : 1 ;
1362+ } ,
1363+ { enableUtf8Validation : false }
1364+ ) ;
13501365 return databases ;
13511366 } catch ( err ) {
13521367 // Currently Compass should not fail if listDatabase failed for any
@@ -2112,15 +2127,23 @@ class DataServiceImpl extends WithLogContext implements DataService {
21122127 } )
21132128 async serverStatus ( ) : Promise < Document > {
21142129 const admin = this . _database ( 'admin' , 'META' ) ;
2115- return await runCommand ( admin , { serverStatus : 1 } ) ;
2130+ return await runCommand (
2131+ admin ,
2132+ { serverStatus : 1 } ,
2133+ { enableUtf8Validation : false }
2134+ ) ;
21162135 }
21172136
21182137 @op ( mongoLogId ( 1_001_000_062 ) , ( _ , result ) => {
21192138 return result ? { result } : undefined ;
21202139 } )
21212140 async top ( ) : Promise < { totals : Record < string , unknown > } > {
21222141 const adminDb = this . _database ( 'admin' , 'META' ) ;
2123- return await runCommand ( adminDb , { top : 1 } ) ;
2142+ return await runCommand (
2143+ adminDb ,
2144+ { top : 1 } ,
2145+ { enableUtf8Validation : false }
2146+ ) ;
21242147 }
21252148
21262149 @op (
@@ -2457,7 +2480,11 @@ class DataServiceImpl extends WithLogContext implements DataService {
24572480 name : string
24582481 ) : Promise < ReturnType < typeof adaptDatabaseInfo > & { name : string } > {
24592482 const db = this . _database ( name , 'META' ) ;
2460- const stats = await runCommand ( db , { dbStats : 1 } ) ;
2483+ const stats = await runCommand (
2484+ db ,
2485+ { dbStats : 1 } ,
2486+ { enableUtf8Validation : false }
2487+ ) ;
24612488 const normalized = adaptDatabaseInfo ( stats ) ;
24622489 return { name, ...normalized } ;
24632490 }
0 commit comments