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

Ensure dbclose() is not called multiple times #1244

Merged
merged 1 commit into from Nov 19, 2021
Merged

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Nov 14, 2021

By submitting this pull request, I confirm the following:

  • 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


Reduce code duplication by using labels + ensure we do not run dbclose() multiple times on database issues (e.g., when database is locked). The double-closing can cause some warnings in the FTL log even when this is harmless, for instance,

[2021-11-13 09:52:03.250 875/T879] ERROR: SQL query "END TRANSACTION" failed: database is locked
[2021-11-13 09:52:03.251 875/T879] WARNING: Storing devices in network table failed: database is locked
[2021-11-13 09:52:03.251 875/T879] SQLite3 message: API call with invalid database connection pointer (21)
[2021-11-13 09:52:03.251 875/T879] SQLite3 message: misuse at line 166280 of [5c9a6c0687] (21)
[2021-11-13 09:52:03.251 875/T879] Error while trying to close database: bad parameter or other API misuse

with this PR, a locked database will instead log only the following lines:

[2021-11-13 09:52:03.250 875/T879] ERROR: SQL query "END TRANSACTION" failed: database is locked
[2021-11-13 09:52:03.251 875/T879] WARNING: Storing devices in network table failed: database is locked

…e() multiple times on database issues (e.g., when database is locked)

Signed-off-by: DL6ER <dl6er@dl6er.de>
@yubiuser
Copy link
Member

Why is the goto XXXX only used on the message and query table, but not on the network table?

@DL6ER
Copy link
Member Author

DL6ER commented Nov 18, 2021

Why is the goto XXXX only used on the message and query table, but not on the network table?

Because it is used to avoid code duplication (always the same error handling) in the former two cases. However, for the network table, the error handling is a bit more complex and is not always the same, i.e., there is no common target we could goto.

@DL6ER DL6ER merged commit 0d44449 into development Nov 19, 2021
@DL6ER DL6ER deleted the tweak/dbclose branch November 19, 2021 12:22
@DL6ER DL6ER mentioned this pull request Dec 20, 2021
5 tasks
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-12-web-v5-9-and-core-v5-7-released/51795/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants