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

Database error checking #610

Merged
merged 6 commits into from Jul 7, 2019

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jul 6, 2019

By submitting this pull request, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your PR:

Please submit all pull requests against the development branch. Failure to do so will delay or deny your request

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

How familiar are you with the codebase?:

10


Improve error checking in the database routines to cover all actions that can fail, e.g., due to readonly database errors.

  • Check if the pihole-FTL.db database is still available at the beginning of all database routines in database/common.c
  • Log if we failed to update the database from version 3 -> 4 and return early if this is the case.
  • Simplify logging in case of an error.
    Previously:
    [2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
    [2019-07-06 17:00:55.526 32339] dbquery(CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)) - SQL error (8): attempt to write a readonly database
    [2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
    [2019-07-06 17:00:55.526 32339] unify_hwaddr(): "CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)" failed!
    
    Now:
    [2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
    [2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
    [2019-07-06 17:00:55.526 32339] ERROR: unify_hwaddr() failed!
    

DL6ER added 3 commits July 6, 2019 17:03
Signed-off-by: DL6ER <dl6er@dl6er.de>
… prefer to handle the logging through the SQLite3 error callback as this ensures it cannot be missed.

Previously:
[2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
[2019-07-06 17:00:55.526 32339] dbquery(CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)) - SQL error (8): attempt to write a readonly database
[2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
[2019-07-06 17:00:55.526 32339] unify_hwaddr(): "CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)" failed!

Now:
[2019-07-06 17:00:55.526 32339] SQLite3 message: statement aborts at 36: [CREATE UNIQUE INDEX network_hwaddr_idx ON network(hwaddr)] attempt to write a readonly database (8)
[2019-07-06 17:00:55.526 32339] check_database(8): Disabling database connection due to error
[2019-07-06 17:00:55.526 32339] ERROR: unify_hwaddr() failed!

Signed-off-by: DL6ER <dl6er@dl6er.de>
… error.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER added this to the v5.0 milestone Jul 6, 2019
Signed-off-by: DL6ER <dl6er@dl6er.de>
src/database/common.c Show resolved Hide resolved
src/database/common.c Show resolved Hide resolved
DL6ER added 2 commits July 7, 2019 09:45
…e we set database to false.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…ld_queries_in_DB(). The function can in any way not be called when database == false as this is an exit criterion for the database thread.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@AzureMarker AzureMarker merged commit ac1018a into new/modularize_headers Jul 7, 2019
@AzureMarker AzureMarker deleted the tweak/database_error_checking branch July 7, 2019 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants