UBERF-8620: Fix OOM in fulltext service (#7263)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-12-05 16:05:14 +07:00 committed by GitHub
parent 8ba52a99eb
commit 27b54e5821
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 17 deletions

View File

@ -423,20 +423,6 @@ export const coreOperation: MigrateOperation = {
await client.update(DOMAIN_SPACE, { '%hash%': { $exists: true } }, { $set: { '%hash%': null } })
}
},
{
state: 'remove-github-patches',
func: async (client) => {
await client.update(
DOMAIN_TX,
{
objectClass: 'tracker:class:Issue',
collection: 'pullRequests',
'tx.attributes.patch': { $exists: true }
},
{ $unset: { 'tx.attributes.patch': 1 } }
)
}
},
{
state: 'remove-collection-txes',
func: async (client) => {

View File

@ -237,6 +237,13 @@ abstract class MongoAdapterBase implements DbAdapter {
cursor = cursor.sort(sort)
}
}
if (options?.projection !== undefined) {
const projection: Projection<T> = {}
for (const key in options.projection ?? []) {
projection[key] = options.projection[key]
}
cursor = cursor.project(projection)
}
return await cursor.toArray()
}

View File

@ -393,7 +393,7 @@ abstract class PostgresAdapterBase implements DbAdapter {
async rawFindAll<T extends Doc>(_domain: Domain, query: DocumentQuery<T>, options?: FindOptions<T>): Promise<T[]> {
const domain = translateDomain(_domain)
const select = `SELECT * FROM ${domain}`
const select = `SELECT ${this.getProjection(domain, options?.projection, [])} FROM ${domain}`
const sqlChunks: string[] = []
sqlChunks.push(`WHERE ${this.buildRawQuery(domain, query, options)}`)
if (options?.sort !== undefined) {
@ -564,7 +564,7 @@ abstract class PostgresAdapterBase implements DbAdapter {
toClass: undefined
})
}
const select = `SELECT ${this.getProjection(_class, domain, options?.projection, joins)} FROM ${domain}`
const select = `SELECT ${this.getProjection(domain, options?.projection, joins)} FROM ${domain}`
const secJoin = this.addSecurity(query, domain, ctx.contextData)
if (secJoin !== undefined) {
sqlChunks.push(secJoin)
@ -1232,7 +1232,6 @@ abstract class PostgresAdapterBase implements DbAdapter {
}
private getProjection<T extends Doc>(
_class: Ref<Class<T>>,
baseDomain: string,
projection: Projection<T> | undefined,
joins: JoinProps[]