Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Out of Memory Error when Collating TechDocs for Search #23047

Closed
2 tasks done
awanlin opened this issue Feb 18, 2024 · 25 comments
Closed
2 tasks done

🐛 Bug Report: Out of Memory Error when Collating TechDocs for Search #23047

awanlin opened this issue Feb 18, 2024 · 25 comments
Labels
area:discoverability Related to the Discoverability Project Area area:techdocs Related to the TechDocs Project Area bug Something isn't working

Comments

@awanlin
Copy link
Collaborator

awanlin commented Feb 18, 2024

📜 Description

Currently when we enable TechDocs search in the Backstage Demo site we run into an Out of Memory error which crashes the container. This happens shortly after start up and causes a crashes loop.

Some important details:

  • This seems to only happen with the new backend system (have not had time to test it on the legacy backend to confirm)
  • We deploy to Heroku and only have 1gb of RAM and have this set in our Dockerfile: ENV NODE_OPTIONS "--max-old-space-size=1000" (locally this seems to break between 1250 and 1500)
  • We are hosting the generated TechDocs on a GCS bucket
  • The file it's attempting to read is roughly 20mb: search_index.json
  • As this is a Demo we are using SQLite as our DB which is in-memory and Lunr for search indexing which is also in-memory

👍 Expected behavior

We should not hit an out of memory error when collating TechDocs for Search.

👎 Actual Behavior with Screenshots

First we see "Collating documents for techdocs via DefaultTechDocsCollatorFactory" in the logs, then it tries to get the search_index.json for one of the entities, in this case for: https://demo.backstage.io/catalog/default/component/backstage. There is a short delay and then we get this error and the app crashes:

<--- Last few GCs --->

[1:0x17938870]    16712 ms: Mark-sweep (reduce) 1240.7 (1271.2) -> 1239.8 (1271.5) MB, 432.3 / 0.0 ms  (average mu = 0.145, current mu = 0.010) allocation failure; scavenge might not succeed
[1:0x17938870]    17326 ms: Mark-sweep (reduce) 1240.9 (1271.5) -> 1240.2 (1272.0) MB, 609.2 / 0.0 ms  (average mu = 0.067, current mu = 0.007) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb8097c node::Abort() [node]
 2: 0xa98f08  [node]
 3: 0xd420c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xd42290 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xf20844  [node]
 6: 0xf327dc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xf0e960 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xf0f938 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0xef1aec v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
10: 0xee879c v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawArray(int, v8::internal::AllocationType) [node]
11: 0xee8958 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [node]
12: 0x10c6e58  [node]
13: 0x11416d0  [node]
14: 0x1142c14 v8::internal::KeyAccumulator::GetKeys(v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::KeyCollectionMode, v8::internal::PropertyFilter, v8::internal::GetKeysConversion, bool, bool) [node]
15: 0x12a06cc v8::internal::Runtime_ObjectKeys(int, unsigned long*, v8::internal::Isolate*) [node]
16: 0x167d76c  [node]

👟 Reproduction steps

This is pretty tricky, I have a branch that can be used at a starting point here: https://github.com/awanlin/backstage/tree/debug/techdocs-search

To us this branch to test with do the following:

  1. Configure proper access to a GCC bucket and generate the TechDocs, this is the workflow that does this for the demo site: https://github.com/backstage/demo/blob/master/.github/workflows/techdocs.yml
  2. Run yarn install, yarn tsc and yarn build:backend --config ../../app-config.yaml --config ../../app-config.local.yaml
  3. Run docker image build . -t backstage --progress=plain
  4. Then run docker run -it -p 7007:7007 backstage

Notice: after a minute or so it will crash with the out of memory previously shared

📃 Provide the context for the Bug.

As this causes a crash loop we aren't able to enable TechDocs search in the Demo site. This would be nice to showcase there for those looking at Adopting Backstage!

🖥️ Your Environment

I think the critical environment specific details are: the size of the index file, using GCS bucket, the new backend system, and the limited amount of RAM.

OS:   Darwin 23.3.0 - darwin/arm64
node: v18.18.2
yarn: 3.5.0
cli:  0.25.2-next.3 (installed)
backstage:  1.23.0-next.3

Dependencies:
  @backstage/app-defaults                                          1.5.0-next.3
  @backstage/backend-app-api                                       0.5.10, 0.5.11-next.3
  @backstage/backend-common                                        0.19.9, 0.20.1, 0.21.0-next.3
  @backstage/backend-defaults                                      0.2.10-next.3
  @backstage/backend-dev-utils                                     0.1.3, 0.1.4-next.0
  @backstage/backend-openapi-utils                                 0.1.3-next.3
  @backstage/backend-plugin-api                                    0.6.10-next.3, 0.6.9
  @backstage/backend-tasks                                         0.5.14, 0.5.15-next.3
  @backstage/catalog-client                                        1.5.2, 1.6.0-next.1
  @backstage/catalog-model                                         1.4.3, 1.4.4-next.0
  @backstage/cli-common                                            0.1.13
  @backstage/cli-node                                              0.2.2, 0.2.3-next.0
  @backstage/cli                                                   0.25.2-next.3
  @backstage/config-loader                                         1.6.1, 1.6.2-next.0
  @backstage/config                                                1.1.1
  @backstage/core-app-api                                          1.12.0-next.1
  @backstage/core-compat-api                                       0.2.0-next.3
  @backstage/core-components                                       0.14.0-next.2
  @backstage/core-plugin-api                                       1.9.0-next.1
  @backstage/e2e-test-utils                                        0.1.1-next.0
  @backstage/errors                                                1.2.3
  @backstage/eslint-plugin                                         0.1.5-next.0
  @backstage/frontend-plugin-api                                   0.6.0-next.3
  @backstage/integration-aws-node                                  0.1.8, 0.1.9-next.0
  @backstage/integration-react                                     1.1.24-next.2
  @backstage/integration                                           1.8.0, 1.9.0-next.1
  @backstage/plugin-api-docs                                       0.11.0-next.3
  @backstage/plugin-app-backend                                    0.3.58-next.3
  @backstage/plugin-app-node                                       0.1.10-next.3
  @backstage/plugin-auth-backend-module-atlassian-provider         0.1.2-next.3
  @backstage/plugin-auth-backend-module-aws-alb-provider           0.1.0-next.2
  @backstage/plugin-auth-backend-module-gcp-iap-provider           0.2.4-next.3
  @backstage/plugin-auth-backend-module-github-provider            0.1.7-next.3
  @backstage/plugin-auth-backend-module-gitlab-provider            0.1.7-next.3
  @backstage/plugin-auth-backend-module-google-provider            0.1.7-next.3
  @backstage/plugin-auth-backend-module-microsoft-provider         0.1.5-next.3
  @backstage/plugin-auth-backend-module-oauth2-provider            0.1.7-next.3
  @backstage/plugin-auth-backend-module-oauth2-proxy-provider      0.1.2-next.3
  @backstage/plugin-auth-backend-module-oidc-provider              0.1.0-next.3
  @backstage/plugin-auth-backend-module-okta-provider              0.0.3-next.3
  @backstage/plugin-auth-backend                                   0.21.0-next.3
  @backstage/plugin-auth-node                                      0.4.3, 0.4.4-next.3
  @backstage/plugin-badges-backend                                 0.3.7-next.3
  @backstage/plugin-badges                                         0.2.54-next.3
  @backstage/plugin-catalog-backend-module-scaffolder-entity-model 0.1.7-next.3
  @backstage/plugin-catalog-backend                                1.17.0-next.3
  @backstage/plugin-catalog-common                                 1.0.20, 1.0.21-next.0
  @backstage/plugin-catalog-graph                                  0.4.0-next.3
  @backstage/plugin-catalog-node                                   1.6.1, 1.6.2-next.3
  @backstage/plugin-catalog-react                                  1.10.0-next.3
  @backstage/plugin-catalog                                        1.17.0-next.3
  @backstage/plugin-cost-insights-common                           0.1.2
  @backstage/plugin-cost-insights                                  0.12.19-next.3
  @backstage/plugin-events-node                                    0.2.19-next.3
  @backstage/plugin-explore-backend                                0.0.20-next.3
  @backstage/plugin-explore-common                                 0.0.2
  @backstage/plugin-explore-react                                  0.0.36-next.1
  @backstage/plugin-explore                                        0.4.16-next.3
  @backstage/plugin-github-actions                                 0.6.11-next.3
  @backstage/plugin-graphiql                                       0.3.3-next.3
  @backstage/plugin-home-react                                     0.1.8-next.3
  @backstage/plugin-home                                           0.6.2-next.3
  @backstage/plugin-kubernetes-backend                             0.15.0-next.3
  @backstage/plugin-kubernetes-common                              0.7.4-next.2
  @backstage/plugin-kubernetes-node                                0.1.4-next.3
  @backstage/plugin-kubernetes-react                               0.3.0-next.3
  @backstage/plugin-kubernetes                                     0.11.5-next.3
  @backstage/plugin-org                                            0.6.20-next.3
  @backstage/plugin-permission-common                              0.7.12
  @backstage/plugin-permission-node                                0.7.20, 0.7.21-next.3
  @backstage/plugin-permission-react                               0.4.20-next.1
  @backstage/plugin-proxy-backend                                  0.4.8-next.3
  @backstage/plugin-scaffolder-backend-module-azure                0.1.2-next.3
  @backstage/plugin-scaffolder-backend-module-bitbucket-cloud      0.1.0-next.1
  @backstage/plugin-scaffolder-backend-module-bitbucket-server     0.1.0-next.1
  @backstage/plugin-scaffolder-backend-module-bitbucket            0.2.0-next.3
  @backstage/plugin-scaffolder-backend-module-gerrit               0.1.2-next.3
  @backstage/plugin-scaffolder-backend-module-github               0.2.0-next.3
  @backstage/plugin-scaffolder-backend-module-gitlab               0.2.13-next.3
  @backstage/plugin-scaffolder-backend                             1.21.0-next.3
  @backstage/plugin-scaffolder-common                              1.5.0-next.1
  @backstage/plugin-scaffolder-node                                0.3.0-next.3
  @backstage/plugin-scaffolder-react                               1.8.0-next.3
  @backstage/plugin-scaffolder                                     1.18.0-next.3
  @backstage/plugin-search-backend-module-catalog                  0.1.14-next.3
  @backstage/plugin-search-backend-module-explore                  0.1.14-next.3
  @backstage/plugin-search-backend-module-techdocs                 0.1.14-next.3
  @backstage/plugin-search-backend-node                            1.2.14-next.3
  @backstage/plugin-search-backend                                 1.5.0-next.3
  @backstage/plugin-search-common                                  1.2.10
  @backstage/plugin-search-react                                   1.7.6-next.3
  @backstage/plugin-search                                         1.4.6-next.3
  @backstage/plugin-tech-radar                                     0.6.13-next.3
  @backstage/plugin-techdocs-backend                               1.9.3-next.3
  @backstage/plugin-techdocs-node                                  1.11.2-next.3
  @backstage/plugin-techdocs-react                                 1.1.16-next.2
  @backstage/plugin-techdocs                                       1.10.0-next.3
  @backstage/plugin-todo-backend                                   0.3.8-next.3
  @backstage/plugin-todo                                           0.2.34-next.3
  @backstage/plugin-user-settings                                  0.8.1-next.3
  @backstage/release-manifests                                     0.0.11
  @backstage/repo-tools                                            0.6.0-next.3
  @backstage/theme                                                 0.5.1-next.1
  @backstage/types                                                 1.1.1
  @backstage/version-bridge                                        1.0.7

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

No, but I'm happy to collaborate on a PR with someone else

@awanlin awanlin added the bug Something isn't working label Feb 18, 2024
@github-actions github-actions bot added area:discoverability Related to the Discoverability Project Area area:techdocs Related to the TechDocs Project Area labels Feb 18, 2024
@freben
Copy link
Member

freben commented Feb 18, 2024

Interesting. Last fix we did for OOM recently was due to insufficiently bounded parallelism. Looking at the code of the collator, it is slightly hard to follow but it does try to leverage a limiter. Might need to dig deeper into that code.

private async *execute(): AsyncGenerator<TechDocsDocument, void, undefined> {

@awanlin
Copy link
Collaborator Author

awanlin commented Feb 19, 2024

Updated the description to include that we are using SQLite for the database which is in-memory and also using Lunr to do the search indexing which is also in-memory. I'm wondering if perhaps these aren't helping either?

@freben
Copy link
Member

freben commented Feb 19, 2024

yeah that's an interesting point - i was hoping to look a bit closer at this today but didn't have the time to - if there's any way thar you can boil this down to really being ONLY about that collator or so, that'd of course be stellar

@vinzscam
Copy link
Member

I think the issue is in the Lunr indexer, which keeps all objects in memory until the collator finishes emitting items.

@freben
Copy link
Member

freben commented Feb 19, 2024

@vinzsvi but for a search_index.json that's just 20 MB? 🤔

@wss-dogara
Copy link
Contributor

This does seem to be an issue with lunr. I made a small sample repo here: https://github.com/wss-dogara/techdocs-oom-bug

It takes a search_index.json generated from the backstage repo docs folder (~20MB in size) and adds it to a builder the same was that LunrSearchEngineIndexer does. From the output it looks like that consumes around 620MB of mem when ran on my machine. Which is probably enough to cause the OOM when running in a container with only 1 GB or so.

@jonesbusy
Copy link

jonesbusy commented Apr 5, 2024

Hi,

I think we are facing the same on our production and pp environment (without any user activity)

  • We are still using the legacy backend system
  • Techdoc is using the recommended approach and hosted on S3 endpoint (minio)
  • Catalog crawling on Bitbucket Server
  • Running 1.23.4 of backstage
  • Postgres 16.2 database

Or monitoring discover OOM after 2-3 days even without any user activity on the portal. We can see the memory is increasing until reaching the limit

pp

We can see on the logs before oom

{"level":"info","message":"::1 - - [01/Apr/2024:22:19:27 +0000] \"GET /api/catalog/entities/by-name/component/default/********** HTTP/1.1\" 200 - \"-\" \"node-fetch/1.0 (+https://github.com/bitinn/node-fetch)\"","service":"backstage","type":"incomingRequest"}
{"level":"info","message":"::1 - - [01/Apr/2024:22:19:27 +0000] \"GET /api/catalog/entities/by-name/component/default/*****-terraforms HTTP/1.1\" 200 - \"-\" \"node-fetch/1.0 (+https://github.com/bitinn/node-fetch)\"","service":"backstage","type":"incomingRequest"}
{"documentType":"software-catalog","level":"info","message":"Collating documents for software-catalog via DefaultCatalogCollatorFactory","plugin":"search","service":"backstage","type":"plugin"}
<--- Last few GCs --->
[1:0x6354370] 323556081 ms: Scavenge 503.3 (520.4) -> 501.7 (520.4) MB, 4.26 / 0.00 ms (average mu = 0.712, current mu = 0.698) allocation failure;
[1:0x6354370] 323556089 ms: Scavenge 503.4 (520.4) -> 501.7 (520.4) MB, 3.36 / 0.00 ms (average mu = 0.712, current mu = 0.698) allocation failure;
[1:0x6354370] 323556168 ms: Scavenge 503.4 (520.4) -> 501.6 (524.4) MB, 76.78 / 0.00 ms (average mu = 0.712, current mu = 0.698) allocation failure;
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 0xca5580 node::Abort() [node]
2: 0xb781f9 [node]
3: 0xeca4d0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
4: 0xeca7b7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
5: 0x10dc505 [node]
6: 0x10f4388 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]

Thanks

@vinzscam
Copy link
Member

vinzscam commented Apr 5, 2024

The recommendation is to switch to another search engine in production, as mentioned here: https://backstage.io/docs/features/search/search-engines#lunr

Note: Lunr is appropriate as a zero-config search engine when developing other parts of Backstage locally, however its use is highly discouraged when running Backstage in production. When deploying Backstage, use one of the other search engines instead.

@jonesbusy
Copy link

Unless a configuration issue we are using the postgres search engine

  const searchEngine = await PgSearchEngine.fromConfig(env.config, { database: env.database });
  const indexBuilder = new IndexBuilder({
    logger: env.logger,
    searchEngine,
  });
  indexBuilder.addCollator({
    schedule,
    factory: DefaultCatalogCollatorFactory.fromConfig(env.config, {
      discovery: env.discovery,
      tokenManager: env.tokenManager,
    }),
  });
  indexBuilder.addCollator({
    schedule,
    factory: DefaultTechDocsCollatorFactory.fromConfig(env.config, {
      discovery: env.discovery,
      logger: env.logger,
      tokenManager: env.tokenManager,
    }),
  });

  indexBuilder.addCollator({
    schedule: schedule,
    factory: AnnouncementCollatorFactory.fromConfig({
      logger: env.logger,
      discoveryApi: env.discovery,
    }),
  });

@vinzscam
Copy link
Member

vinzscam commented Apr 5, 2024

Unless a configuration issue we are using the postgres search engine

  const searchEngine = await PgSearchEngine.fromConfig(env.config, { database: env.database });
  const indexBuilder = new IndexBuilder({
    logger: env.logger,
    searchEngine,
  });
  indexBuilder.addCollator({
    schedule,
    factory: DefaultCatalogCollatorFactory.fromConfig(env.config, {
      discovery: env.discovery,
      tokenManager: env.tokenManager,
    }),
  });
  indexBuilder.addCollator({
    schedule,
    factory: DefaultTechDocsCollatorFactory.fromConfig(env.config, {
      discovery: env.discovery,
      logger: env.logger,
      tokenManager: env.tokenManager,
    }),
  });

  indexBuilder.addCollator({
    schedule: schedule,
    factory: AnnouncementCollatorFactory.fromConfig({
      logger: env.logger,
      discoveryApi: env.discovery,
    }),
  });

Interesting thank you for the debugging info 🙏. Definitely something to look into it

@awanlin
Copy link
Collaborator Author

awanlin commented Apr 5, 2024

Hi @jonesbusy, your logs says DefaultCatalogCollatorFactory which is not the one for TechDocs but for the Catalog itself. This seems to be a similar but different issue then the one I logged. Can you review your logs to confirm that it's consistently the DefaultCatalogCollatorFactory?

When I was having issues with some bad content causing our indexing to fail completely I added an indexerBatchSize, the default is 1000. You could try adjusting that to see how it goes?

Also, just a more general comment that search runs on a schedule to keep it's indexes up to date so it's not necessarily surprised that it could use memory even when users are not actively using it.

@jonesbusy
Copy link

I can see both task running more less at the same time

{"documentType":"software-catalog","level":"info","message":"Collating documents for software-catalog via DefaultCatalogCollatorFactory","plugin":"search","service":"backstage","type":"plugin"}
....
{"documentType":"software-catalog","level":"info","message":"Collating documents for software-catalog succeeded","plugin":"search","service":"backstage","type":"plugin"}
...
{"documentType":"techdocs","level":"info","message":"Collating documents for techdocs via DefaultTechDocsCollatorFactory","plugin":"search","service":"backstage","type":"plugin"}
...
{"documentType":"techdocs","level":"info","message":"Collating documents for techdocs succeeded","plugin":"search","service":"backstage","type":"plugin"}

probably due to the

  const schedule = env.scheduler.createScheduledTaskRunner({
    frequency: { minutes: 10 },
    timeout: { minutes: 15 },
    initialDelay: { seconds: 15 },
  });

The oom always follow the execution of those tasks

@awanlin
Copy link
Collaborator Author

awanlin commented Apr 5, 2024

Thanks! What's the size of your catalog and how many entities have TechDocs? Can you try running with debug on for the logs? It will print out the entities in each batch that way. I might pair that with a smaller default batch size as well. Would help tell if this is related to a large search_index.json file like I ran into or if it's a slight different issue.

@jonesbusy
Copy link

I will answer with more details early next week but in our preproduction environment we have perhaps 50 techdocs entity.

For the catalog it's similar but if we consider user and groups it's more than 2000 thousand (not sure if relevant for the search indexer).

That's why it confuse me because our catalog and techdoc are very small dor the moment.

Thanks for the helps ans tips to debug this issue.

@awanlin
Copy link
Collaborator Author

awanlin commented Apr 6, 2024

Thanks for the follow up. Yeah, it's all very odd to me. My experience with PR and search was very solid, memory usage was pretty minimal, never had OOM. The Catalog had about 750+ entities with about 80% having TechDocs. We had about 500+ Users and Groups.

@jonesbusy
Copy link

From what I understood this as also been disabled on the demo backstage : https://github.com/backstage/demo/blob/b4d9b44c8cfb8ee5b517a23b91d0de7db12a1b3f/packages/backend/src/index.ts#L31

On our side we still have high memory usage and trigger OOM after some point

We are not on Backstage 1.27.5 and all plugin migrated to new backend system

backstage

What I'm not really sure is the engine used for each Lunr or postgres (not sure were to look the config)

@awanlin
Copy link
Collaborator Author

awanlin commented Jun 3, 2024

@jonesbusy, yes, this issue was logged specifically for the issue we ran into on the Demo site. The Demo site is an outlier though as it doesn't follow the recommended patterns for a "production" deployment - it runs on SQLite and uses Lunr for search. It's also resource constrained, adding more RAM would also solve the problem, the Demo site was not seeing the same increasing memory but a one time OOM error that would crash it entirely in a loop.

@awanlin
Copy link
Collaborator Author

awanlin commented Jun 3, 2024

@jonesbusy can you please log a new issue for your OOM error, please? I think that makes more sense as again this issue is pretty unique to the Demo site.

@sebalaini
Copy link
Contributor

sebalaini commented Jul 3, 2024

interesting, I didn't realize this was due to the new BE and the tech docs search, it started when I upgraded Backstage and switched 90% of the plugins to the new BE + updated to the latest Docker image in the doc.

In our case, we solved it with the old way of setting node memory node-options=--max-old-space-size=XXXX and increasing a bit the container available RAM, since then we saw very few restarts but I'm following this issue as I'm using this plugin. We had the PG plugin in the old BE but I think we lost it during the migration, is there any doc about setting up PG search in the new BE?

Our prod/staging uses the Postgres DB, and we have like 20 tech docs and 900 locations (which I guess translates to 900 entries in the catalog, between AWS resources, users, components & API)

I CC @LegendSebastianoL that's my work account.

@awanlin
Copy link
Collaborator Author

awanlin commented Jul 3, 2024

Hi @sebalaini (@LegendSebastianoL), this issue is really specific to the unusual AND not recommended setup we have for the Demo site.

If you are using both SQLite as your Database and the Lunr search engine this is not the recommended setup for any non-local environment. I recommend using Postgres as your database and at minimum Postgres as your search engine, Elasticsearch would be a more advanced option. If you have already done that and are still having OOM issue then I would log an issue for that as it's likely not to be the same issue identified here.

@LegendSebastianoL
Copy link

our setup uses PG both locally and in prod but I think we aren't using the PG search engine anymore since we switched to the new BE, this is our current BE

backend.add(import('@backstage/plugin-app-backend/alpha'));
backend.add(import('@backstage/plugin-proxy-backend/alpha'));

/**
 * auth plugin
 */
backend.add(import('@backstage/plugin-auth-backend'));
backend.add(import('@backstage/plugin-auth-backend-module-github-provider'));
backend.add(import('@backstage/plugin-auth-backend-module-okta-provider'));

/**
 * catalog plugin + OKTA users + GH discovery + AWS discovery + open API
 */
backend.add(import('@backstage/plugin-catalog-backend/alpha'));
backend.add(OktaUserProvider);
backend.add(import('@backstage/plugin-catalog-backend-module-github/alpha'));
backend.add(import('@backstage/plugin-catalog-backend-module-aws/alpha'));
backend.add(import('@backstage/plugin-catalog-backend-module-openapi'));

/**
 * scaffolder + catalog plugin
 */
backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
backend.add(
  import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'),
);

/**
 * permission plugin
 */
backend.add(import('@backstage/plugin-permission-backend/alpha'));
backend.add(
  import('@backstage/plugin-permission-backend-module-allow-all-policy'),
);

/**
 * search plugin
 */
backend.add(import('@backstage/plugin-search-backend/alpha'));
backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha'));

/**
 * techdocs + search plugin
 */
backend.add(import('@backstage/plugin-techdocs-backend/alpha'));
backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha'));

/**
 * explore + search plugin
 */
backend.add(import('@backstage-community/plugin-explore-backend'));
backend.add(import('@backstage/plugin-search-backend-module-explore/alpha'));

/**
 * all the others externals plugins
 */
backend.add(import('@backstage-community/plugin-sonarqube-backend'));
backend.add(import('@backstage/plugin-kubernetes-backend/alpha'));

/**
 * internal plugins
 */
...

/**
 * TODO legacy plugins to migrate
 */
backend.add(legacyPlugin('healthcheck', import('./plugins/healthcheck')));
backend.add(legacyPlugin('tech-insights', import('./plugins/techinsights')));

I remember this config in the old BE but can't see anything in the new, is there some doc about how to setup the search in the new BE with PG?

@LegendSebastianoL
Copy link

OK I think this should add the PG search engine right? backend.add(import('@backstage/plugin-search-backend-module-pg/alpha'));

after adding the plugin I added this config:

search:
  pg:
    highlightOptions:
      useHighlight: false

and the highlight disappeared, so I guess now we are using the postgres search engine

@camilaibs
Copy link
Contributor

camilaibs commented Jul 8, 2024

As the Lunr search engine is not recommended for non-local environments, we are closing this issue. If you are still experiencing a similar problem with other search engines, please open a new issue 🙌🏻

@jonesbusy
Copy link

Thanks @LegendSebastianoL it's exaclty what I needed and was missing import and config (I didn't find anywhere this documentation).

@camilaibs I confirm now that the search is done on Postgres. I will reopen an other issue if I still experience OOM in the next few days.

@LegendSebastianoL
Copy link

LegendSebastianoL commented Jul 8, 2024

hey @jonesbusy the doc TBH is missing, I just tried to use the new standard to import plugins in the new BE and checked that the plugin in the upstream had the new BE config :)

the whole search doc is for the old BE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:discoverability Related to the Discoverability Project Area area:techdocs Related to the TechDocs Project Area bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants