Ericsson / codechecker

CodeChecker is an analyzer tooling, defect database and viewer extension for static and dynamic analyzer tools.
https://codechecker.readthedocs.io
Apache License 2.0
2.27k stars 383 forks source link

Removal of Default.sqlite causes exception on start if config database has rows #1386

Open whisperity opened 6 years ago

whisperity commented 6 years ago

If I start a server and configure a postgresql-backed product, then delete the default product, stop the server, and also remove the Default.sqlite file, and then start the server again, the following happens:

  1. The server recreates the Default.sqlite file, even though it's not needed.
  2. Due to the server knowing it's not needed, it tries to call create_initial_run_database which throws an exception.
[INFO 2018-02-20 09:47] - Checking configuration database ...
[INFO 2018-02-20 09:47] - Database is up to date.
[ERROR 2018-02-20 09:47] - Database is up to date.
Traceback (most recent call last):
  File "/ssd/whisperity/CodeChecker/cc_bin/CodeChecker.py", line 93, in main
    args.func(args)
  File "/ssd/whisperity/CodeChecker/lib/python2.7/libcodechecker/libhandlers/server.py", line 388, in __handle
    main(args)
  File "/ssd/whisperity/CodeChecker/lib/python2.7/libcodechecker/libhandlers/server.py", line 864, in main
    server_init_start(args)
  File "/ssd/whisperity/CodeChecker/lib/python2.7/libcodechecker/libhandlers/server.py", line 785, in server_init_start
    cfg_sql_server, product_conn_string)
  File "/ssd/whisperity/CodeChecker/lib/python2.7/libcodechecker/server/server.py", line 958, in add_initial_run_database
    raise ValueError("Called create_initial_run_database on non-empty "
ValueError: Called create_initial_run_database on non-empty config database -- you shouldn't have done this!

After this, if the server is attempted to be started again, it will start, and the Default product will NOT be in the configuration – even though the file for exists.

My first hunch is that this was messed up when the new schema migration logic was implemented. The exception is rightful, the server should not add back a Default product if it was explicitly removed.

The control flow should be changed so this function is not called if not needed.

whisperity commented 4 years ago

Bump: This issue is still here with 6.11 release version, even if the server is not using Postgres.

My current scenario:

Neither of the two products I actively use is the Default one.

There is no reference to Default in the config.sqlite file.