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

Extension enters duplicate data into local globalStorage sqlite db #17488

Closed
mattseddon opened this issue Sep 22, 2021 · 10 comments · Fixed by #17598 or #17627
Closed

Extension enters duplicate data into local globalStorage sqlite db #17488

mattseddon opened this issue Sep 22, 2021 · 10 comments · Fixed by #17598 or #17627
Assignees
Labels
area-internal Label for non-user facing issues bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority regression Bug didn't exist in a previous release verified Verification succeeded
Milestone

Comments

@mattseddon
Copy link

mattseddon commented Sep 22, 2021

Environment data

  • VS Code version: 1.60.1
  • Extension version (available under the Extensions sidebar): v2021.9.1246542782
  • OS and version: Darwin x64 20.6.0
  • Python version (& distribution if applicable, e.g. Anaconda): Multiple (pyenv)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Multiple (all three listed)
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: ms-python.python
  • Value of the python.languageServer setting: Pylance

Expected behaviour

Extension does not fill the local globalStorage sqlite db (Memento) with erroneous data and maintains a list of available python interpreters.

When left unchecked this can lead to the extension host behaving in unexpected ways and it was difficult to diagnose without significant effort (see #17432 for original issue).

Actual behaviour

Each reload of a window causes PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS under the ms-python.python key to grow. Under most circumstances the list of environments underneath is not refreshed, i.e environments that are no longer on the machine are still shown.

This is a copy of the ms-python.python key before I managed to clear the cache by deleting the extension and going through the steps listed here:

globalStorage.txt

Note: There are 712 matches to INTERPRETERS_CACHE in that file.

Steps to reproduce:

Unsure how to recreate the stale environments issue (seems cache related) but for the ever growing list of PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS:

  1. Completely remove extension from machine.
  2. delete from ItemTable where key = 'ms-python.python'; in ~/Library/Application\ Support/Code/User/globalStorage/state.vscdb (mac).
  3. Confirm key is empty in db.
  4. Reinstall extension.
  5. Reload window.
  6. Note entry under ms-python.python in the db.
  7. Reload window.
  8. Note entry under ms-python.python in the db (PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS will have grown in size and contain duplicate entries).

Logs

Nothing of note is captured in the logs.

@mattseddon mattseddon added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Sep 22, 2021
@mattseddon mattseddon changed the title Extension enters erroneous data into local globalState sqlite db Extension enters erroneous data into local globalStorage sqlite db Sep 22, 2021
@brettcannon brettcannon added triage and removed triage-needed Needs assignment to the proper sub-team labels Sep 22, 2021
@karrtikr karrtikr added investigating We are looking into the cause of the issue and removed triage labels Sep 22, 2021
@karrtikr
Copy link

Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will triage this as soon as we can.

@karrtikr karrtikr added area-internal Label for non-user facing issues needs PR regression Bug didn't exist in a previous release important Issue identified as high-priority and removed investigating We are looking into the cause of the issue labels Oct 1, 2021
@karrtikr karrtikr added this to the October 2021 milestone Oct 2, 2021
@karrtikr karrtikr added the verification-needed Verification of issue is requested label Oct 2, 2021
@karrtikr
Copy link

karrtikr commented Oct 2, 2021

Thank you @mattseddon for investigating the cause, that must not have been easy so I appreciate it very much! The issue should be fixed once #17598 is merged, you're welcome to have a look.

@karrtikr karrtikr changed the title Extension enters erroneous data into local globalStorage sqlite db Extension enters duplicate data into local globalStorage sqlite db Oct 2, 2021
@karrtikr
Copy link

karrtikr commented Oct 2, 2021

Can you verify if the following VSIX fixes the database issue for you: https://github.com/microsoft/vscode-python/suites/3936300663/artifacts/98621813? Use Extensions: Install from VSIX command to install this VSIX.

@mattseddon
Copy link
Author

@karrtikr I have just tested this and it does appear to have made things better. I can see that PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS has been deprecated:

"PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS": []

I am still seeing duplicates being created in the PYTHON_GLOBAL_STORAGE_KEYS array though:

	"PYTHON_GLOBAL_STORAGE_KEYS": [{
		"key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
		"defaultValue": []
	}, {
		"key": "PYTHON_ENV_INFO_CACHE"
	}, {
		"key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
		"defaultValue": []
	}, {
		"key": "PYTHON_ENV_INFO_CACHE"
	}, {
		"key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
		"defaultValue": []
	}, {
		"key": "PYTHON_ENV_INFO_CACHE"
	}, {
		"key": "SWITCH_LS"
	}, {
		"key": "isGlobalSettingCopiedKey",
		"defaultValue": false
	}, {
		"key": "workspaceFolderKeysForWhichTheCopyIsDone_Key",
		"defaultValue": []
	}, {
		"key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
		"defaultValue": []
	}, {
		"key": "ShowBanner",
		"defaultValue": true
	}, {
		"key": "JoinMailingListPrompt",
		"defaultValue": false
	}, {
		"key": "PythonTensorBoardWebviewPreferredViewGroup",
		"defaultValue": -1
	}, {
		"key": "INSIDERS_PROMPT_STATE_KEY",
		"defaultValue": false
	}, {
		"key": "WORKSPACE_FOLDER_INTERPRETER_PATH_/Users/mattseddon/PP/example-get-started"
	}, {
		"key": "preferredGlobalPyInterpreter"
	}, {
		"key": "PYTHON_ENV_INFO_CACHE"
	}]

I don't think that you can close the ticket using the current fix.

@karrtikr karrtikr reopened this Oct 5, 2021
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 5, 2021
@karrtikr
Copy link

karrtikr commented Oct 5, 2021

Thanks for reporting back. The VSIX I provided initially is actually outdated as PR got updated further, can you try https://github.com/microsoft/vscode-python/suites/3954255787/artifacts/99265047 which appears to be the latest VSIX on the PR. Alternatively, you can try Python: Switch to Insiders command and wait a bit to install the latest insiders version of the extension.

@karrtikr
Copy link

karrtikr commented Oct 5, 2021

FYI I can verify there's still an issue with PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS, however I expect the key PYTHON_ENV_INFO_CACHE to not appear multiple times.

@mattseddon
Copy link
Author

I am also seeing the issue with PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS. Maybe the other issue is coming from the first vsix that I installed. I have 4 entries now but it appears to be stable:

[
  {
    "key": "INSIDERS_PROMPT_STATE_KEY",
    "defaultValue": false
  },
  {
    "key": "JoinMailingListPrompt",
    "defaultValue": false
  },
  {
    "key": "PYTHON_ENV_INFO_CACHE"
  },
  {
    "key": "PYTHON_ENV_INFO_CACHE"
  },
  {
    "key": "PYTHON_ENV_INFO_CACHE"
  },
  {
    "key": "PYTHON_ENV_INFO_CACHE"
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS",
    "defaultValue": []
  },
  {
    "key": "PythonTensorBoardWebviewPreferredViewGroup",
    "defaultValue": -1
  },
  {
    "key": "SWITCH_LS"
  },
  {
    "key": "ShowBanner",
    "defaultValue": true
  },
  {
    "key": "WORKSPACE_FOLDER_INTERPRETER_PATH_/Users/mattseddon/PP/example-get-started"
  },
  {
    "key": "isGlobalSettingCopiedKey",
    "defaultValue": false
  },
  {
    "key": "preferredGlobalPyInterpreter"
  },
  {
    "key": "workspaceFolderKeysForWhichTheCopyIsDone_Key",
    "defaultValue": []
  }
]

The list of PYTHON_EXTENSION_GLOBAL_STORAGE_KEYS seems to be ever growing.

@karrtikr
Copy link

karrtikr commented Oct 5, 2021

I see, thanks for confirming. You can use the command Python: Clear Internal Extension cache to clear this storage anytime as well.

@karrtikr karrtikr removed the triage-needed Needs assignment to the proper sub-team label Oct 5, 2021
@karrtikr
Copy link

karrtikr commented Oct 5, 2021

@mattseddon Can you please try https://github.com/microsoft/vscode-python/suites/3965062360/artifacts/99642505, thanks!

@mattseddon
Copy link
Author

@karrtikr that seems to have fixed the issue.

@karrtikr karrtikr added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Oct 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-internal Label for non-user facing issues bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority regression Bug didn't exist in a previous release verified Verification succeeded
Projects
None yet
3 participants