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

internal/lsp: improve error handling while parsing #110

Closed
wants to merge 1 commit into from

Conversation

muirdm
Copy link
Contributor

@muirdm muirdm commented Jun 7, 2019

If the context is canceled (or times out) during parsing, we were
previously caching the package with no *ast.Files. Any further LSP
queries against that package would fail because the package is already
loaded, but none of the files are mapped to the package. Fix by
propagating non-parse errors as "fatal" errors in
parseFiles. typeCheck will propagate these errors and not cache the
package.

I also fixed the package cache to not cache errors loading
packages. If you get an error like "context canceled" then none of the
package's files are mapped to the package. This prevents the package
from ever getting unmapped when its files are updated. I also added a
retry mechanism where if the current request is not canceled but the
package failed to load due to a previous request being canceled, this
request can try loading the package again.

Updates golang/go#32354, golang/go#32360

@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from 839fe65 to 5cb21f3 Compare June 7, 2019 19:33
@gopherbot
Copy link
Contributor

This PR (HEAD: 5cb21f3) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 1:

I think this might fix most of the "no package for file" issues. Note that the package test variant bug can still cause test files to be broken.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 1:

(1 comment)

Thanks for catching these!


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from 5cb21f3 to 382d6bc Compare June 7, 2019 21:18
@gopherbot
Copy link
Contributor

This PR (HEAD: 382d6bc) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from 382d6bc to 5b76a5a Compare June 7, 2019 21:24
@gopherbot
Copy link
Contributor

This PR (HEAD: 5b76a5a) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 3:

(1 comment)

Patch Set 1:

(1 comment)

Thanks for catching these!

My repro apparently wasn't 100% because I've now realized getPkg was still leaving broken entries in the view.pcache by caching the error. No files actually map to the error'd pcache entry, so the view.invalidateContent logic will never invalidate that cache entry.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 4:

(6 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from 5b76a5a to e72c574 Compare June 8, 2019 02:08
@gopherbot
Copy link
Contributor

This PR (HEAD: e72c574) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 7: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 7:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 9: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 10: Run-TryBot+1 Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 10:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=b7c4541e


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 10:

Build is still in progress...
This change failed on freebsd-amd64-12_0:
See https://storage.googleapis.com/go-build-log/8f296f59/freebsd-amd64-12_0_bc10c1bf.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 10: TryBot-Result-1

8 of 10 TryBots failed:
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/8f296f59/freebsd-amd64-12_0_bc10c1bf.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/8f296f59/linux-amd64_9db7a890.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/8f296f59/linux-386_0e86c309.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/8f296f59/windows-amd64-2016_2cc2ca0c.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/8f296f59/windows-386-2008_5c72bcb3.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/8f296f59/openbsd-amd64-64_83233b9e.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/8f296f59/linux-amd64-race_c7f3e7c2.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/8f296f59/android-amd64-emu_57d0037b.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from e72c574 to ad0d595 Compare June 10, 2019 17:12
@gopherbot
Copy link
Contributor

This PR (HEAD: ad0d595) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Muir Manders:

Patch Set 12: Commit message was updated.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 10:

Build is still in progress...
This change failed on freebsd-amd64-12_0:
See https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_a5e5f9a0.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 13: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=c3aec4d2


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 10: TryBot-Result-1

8 of 10 TryBots failed:
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_a5e5f9a0.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64_4ff3d24d.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/350f71f4/linux-386_f155170f.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/350f71f4/openbsd-amd64-64_b3d1b49a.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/350f71f4/windows-amd64-2016_a5cff913.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/350f71f4/windows-386-2008_b98b2c61.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64-race_e0b9c83a.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/350f71f4/android-amd64-emu_7f32b2d8.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13:

Build is still in progress...
This change failed on freebsd-amd64-12_0:
See https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_b97f8a8a.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13: TryBot-Result-1

8 of 10 TryBots failed:
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_b97f8a8a.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64_1df32d4e.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/350f71f4/linux-386_bb86f463.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/350f71f4/windows-amd64-2016_75b16f7c.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64-race_55ece65e.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/350f71f4/openbsd-amd64-64_050b40b7.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/350f71f4/windows-386-2008_307f2ce4.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/350f71f4/android-amd64-emu_aac9844b.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 13: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13:

Build is still in progress...
This change failed on freebsd-amd64-12_0:
See https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_d9e146a4.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13:

Build is still in progress...
This change failed on freebsd-amd64-12_0:
See https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_152d9619.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13: TryBot-Result-1

8 of 10 TryBots failed:
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_d9e146a4.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/350f71f4/linux-386_da2c61cb.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64_0faa2f54.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/350f71f4/openbsd-amd64-64_98579525.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/350f71f4/windows-amd64-2016_3bd47241.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64-race_6b54dc84.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/350f71f4/windows-386-2008_296a19e2.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/350f71f4/android-amd64-emu_7559745d.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 13:

8 of 10 TryBots failed:
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/350f71f4/freebsd-amd64-12_0_152d9619.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64_a4cc6961.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/350f71f4/linux-386_bd57f5d6.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/350f71f4/windows-amd64-2016_1c6e1885.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/350f71f4/openbsd-amd64-64_f0b23e3a.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/350f71f4/linux-amd64-race_9905415b.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/350f71f4/windows-386-2008_e52b0593.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/350f71f4/android-amd64-emu_4873bc91.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

If the context is canceled (or times out) during parsing, we were
previously caching the package with no *ast.Files. Any further LSP
queries against that package would fail because the package is already
loaded, but none of the files are mapped to the package. Fix by
propagating non-parse errors as "fatal" errors in
parseFiles. typeCheck will propagate these errors and not cache the
package.

I also fixed the package cache to not cache errors loading
packages. If you get an error like "context canceled" then none of the
package's files are mapped to the package. This prevents the package
from ever getting unmapped when its files are updated. I also added a
retry mechanism where if the current request is not canceled but the
package failed to load due to a previous request being canceled, this
request can try loading the package again.
@muirdm muirdm force-pushed the lsp-handle-cancel-during-parse branch from ad0d595 to 5f1e7ef Compare June 11, 2019 15:28
@gopherbot
Copy link
Contributor

This PR (HEAD: 5f1e7ef) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/181317 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 15: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 15:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=6b1241ec


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 15: TryBot-Result+1

TryBots are happy.


Please don’t reply on this GitHub thread. Visit golang.org/cl/181317.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Jun 11, 2019
If the context is canceled (or times out) during parsing, we were
previously caching the package with no *ast.Files. Any further LSP
queries against that package would fail because the package is already
loaded, but none of the files are mapped to the package. Fix by
propagating non-parse errors as "fatal" errors in
parseFiles. typeCheck will propagate these errors and not cache the
package.

I also fixed the package cache to not cache errors loading
packages. If you get an error like "context canceled" then none of the
package's files are mapped to the package. This prevents the package
from ever getting unmapped when its files are updated. I also added a
retry mechanism where if the current request is not canceled but the
package failed to load due to a previous request being canceled, this
request can try loading the package again.

Updates golang/go#32354, golang/go#32360

Change-Id: I466ddb8d336aeecf6e50f9f6d040787a86a60ca0
GitHub-Last-Rev: 5f1e7ef
GitHub-Pull-Request: #110
Reviewed-on: https://go-review.googlesource.com/c/tools/+/181317
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/181317 has been merged.

@gopherbot gopherbot closed this Jun 11, 2019
@muirdm muirdm deleted the lsp-handle-cancel-during-parse branch June 11, 2019 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants