Skip to content

Commit 67bd156

Browse files
Fix migration issue discovered when restoring an OpenCRVS instace with a large number of records (#9398)
* Reduce record aggregation query memory usage by not grouping all records into a single array * Update CHANGELOG.md --------- Co-authored-by: Riku Rouvila <[email protected]>
1 parent e031ba5 commit 67bd156

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [1.6.4](https://github.com/opencrvs/opencrvs-core/compare/v1.6.1...v1.6.4)
44

5+
- Fix migration issue discovered when restoring an OpenCRVS instance with a large number of records. `$push used too much memory and cannot spill to disk. Memory limit: 104857600 bytes` [#9116](https://github.com/opencrvs/opencrvs-core/issues/9116)
6+
57
## [1.6.3](https://github.com/opencrvs/opencrvs-core/compare/v1.6.1...v1.6.3)
68

79
### Bug fixes

packages/search/src/features/records/service.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,19 +428,8 @@ export const aggregateRecords = ({
428428
}
429429
]
430430
: []),
431-
{
432-
$group: {
433-
_id: null,
434-
composition: { $push: '$$ROOT' }
435-
}
436-
},
437-
{ $project: { _id: 0 } },
438-
{ $unwind: '$composition' },
439-
{
440-
$addFields: {
441-
bundle: ['$composition']
442-
}
443-
},
431+
{ $addFields: { bundle: ['$$ROOT'], composition: '$$ROOT' } },
432+
{ $project: { bundle: 1, composition: 1 } },
444433

445434
...(includeHistoryResources
446435
? [

0 commit comments

Comments
 (0)