salesforcedx-vscode: Apex Language Server - Error during startup

Summary

Consistently getting failures to start the apex language server. Logs suggest corrupted database. Processes are also being orphaned.

This is happening during the following:

  1. Closing VScode and reopening.
  2. Uninstalling the extension, reloading vscode and reinstalling.
  3. After VSCode update restarts
  4. Rolling back to previous versions of the apex extension.

Steps To Reproduce:

  1. Start vscode. Fails during startup and plugin is completely unusable.

Expected result

Language server should start without issue.

Actual result

Language server fails.

Additional information

Log output:

11:37:05.242 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types.
11:37:05.251 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning built-in Apex types.
11:37:05.252 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Collecting built-in standard types from jar
11:37:05.402 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Done collecting built-in standard types from jar
11:37:05.402 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning Apex Standard Library.
11:37:05.494 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Done scanning Apex Standard Library.
11:37:05.495 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Starting ApexIndexer.
11:37:05.495 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Start indexer.
11:37:05.497 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types.
11:37:05.498 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning workspace source.
11:37:05.574 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Loading existing resource files from apex.db.
11:37:05.648 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Building change list.
11:37:05.769 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Applying found changes
11:37:05.769 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Updating 1132 Apex artifacts in Apex DB
11:37:05.774 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Error during startup
org.eclipse.jdt.internal.core.nd.db.IndexException: Corrupted database: apex.db
	at org.eclipse.jdt.internal.core.nd.db.Database.databaseCorruptionDetected(Database.java:435)
	at org.eclipse.jdt.internal.core.nd.db.Database.getChunk(Database.java:410)
	at org.eclipse.jdt.internal.core.nd.db.Database.getInt(Database.java:1108)
	at org.eclipse.jdt.internal.core.nd.db.Database.getString(Database.java:1226)
	at org.eclipse.jdt.internal.core.nd.field.FieldSearchKey.get(FieldSearchKey.java:76)
	at org.eclipse.jdt.internal.core.nd.field.FieldSearchIndex$2.compare(FieldSearchIndex.java:170)
	at org.eclipse.jdt.internal.core.nd.db.BTree.deleteImp(BTree.java:421)
	at org.eclipse.jdt.internal.core.nd.db.BTree.deleteImp(BTree.java:437)
	at org.eclipse.jdt.internal.core.nd.db.BTree.delete(BTree.java:299)
	at org.eclipse.jdt.internal.core.nd.field.FieldSearchKey.cleanup(FieldSearchKey.java:89)
	at org.eclipse.jdt.internal.core.nd.field.FieldSearchKey.destruct(FieldSearchKey.java:81)
	at org.eclipse.jdt.internal.core.nd.field.StructDef.destructFields(StructDef.java:389)
	at org.eclipse.jdt.internal.core.nd.field.StructDef$1.destructFields(StructDef.java:139)
	at org.eclipse.jdt.internal.core.nd.field.StructDef$1.destruct(StructDef.java:134)
	at org.eclipse.jdt.internal.core.nd.Nd.deleteIfUnreferenced(Nd.java:636)
	at org.eclipse.jdt.internal.core.nd.Nd.processDeletions(Nd.java:164)
	at org.eclipse.jdt.internal.core.nd.Nd.releaseWriteLock(Nd.java:357)
	at org.eclipse.jdt.internal.core.nd.Nd.releaseWriteLock(Nd.java:342)
	at apex.jorje.lsp.impl.index.ApexIndexer.deleteTypeInfo(ApexIndexer.java:1024)
	at apex.jorje.lsp.impl.index.ApexIndexer.buildCache(ApexIndexer.java:246)
	at apex.jorje.lsp.impl.index.ApexIndexer.lambda$startUp$1(ApexIndexer.java:803)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at apex.jorje.lsp.impl.index.ApexIndexer.startUp(ApexIndexer.java:801)
	at com.google.common.util.concurrent.AbstractScheduledService$ServiceDelegate$2.run(AbstractScheduledService.java:230)
	at com.google.common.util.concurrent.Callables$4.run(Callables.java:119)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

I get these notifications as well. Screenshot 2023-12-08 at 11 46 40 AM

Salesforce Extension Version in VS Code: 59.8.0

SFDX CLI Version: @salesforce/cli/2.20.6 darwin-arm64 node-v20.5.0

OS and version: Sonoma 14.0 (23A344)

VS Code version:

Version: 1.85.0 (Universal) Commit: af28b32d7e553898b2a91af498b1fb666fdebe0c Date: 2023-12-06T18:18:04.614Z (1 day ago) Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

@brandbarr Try these steps:

  • exit vscode
  • In a terminal navigate to the project’s root dir
  • run rm -fr .sfdx/tools/246
  • start vsocde

Just ran into this as well… took about a whole hour to find this random issue from a year back, and my logs when failing said nothing of a corrupted db, but deleting that folder fixed it anyways. Is there any info on why this keeps happening, or can we at least get helpful log messages on failure?

Updating here, as I hit this page on encountering the same issue again - that is, the need to rebuild the database.

The number at the end of the command (I.E. the last folder name) changes - presumably as the extension is upgraded.

E.g. At time of writing, the correct command was:

  • rm -fr .sfdx/tools/252