#5629 closed defect (fixed)

MySQL should test and error on connect if the schema version is wrong

Reported by: tmark Owned by: tmark
Priority: medium Milestone: Kea1.4-final
Component: database-mysql Version: git
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DHCP Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

For some reason our MySQL database code doesn't verify the schema version number when it opens the database, while our PostgreSQL code does. This means that users get errors in statement preparation for missing tables or columns, rather than a more helpful message that declares the version mismatch.

Subtickets

Change History (8)

comment:1 Changed 13 months ago by tomek

  • Milestone changed from Kea-proposed to Kea1.4-final

comment:2 Changed 13 months ago by tmark

  • Owner set to tmark
  • Status changed from new to assigned

comment:3 Changed 13 months ago by tmark

  • Owner changed from tmark to UnAssigned
  • Status changed from assigned to reviewing

This problem was farther reaching than I initially thought. PostgreSQL version test was being done after attempting to prepare SQL statements which is too late to catch it. CQL lease manager didn't check it all, and none of the host data sources were checking it.

I reworked the getVersion() functions for MySQL and PostgreSQL to not rely on prepared statements so it can be used on a freshly opened connection. I added schema validation checks all around, CQL included.

ChangeLog?:

14xx.   [bug]       tmark
    kea-dhcp4 and kea-dhcp6 now validate the schema version
    of lease and host back ends after establishing a connection.
    If a schema version does not match the version the server
    expects, the server will emit an error log and close the
    connection. This applies to MySQL, PostgreSQL, and Cassandra.
    (Trac #5629, git TBD)

In testing this, I also discovered that doing a dynamic reconfigure to use a flawed back end (bad schema, wrong user name, etc), lease the server in a dysfunctional state where it ignores incoming
client packets. I created #5637 to cover that issue.

Ticket is ready for review.

comment:4 Changed 13 months ago by fdupont

  • Owner changed from UnAssigned to fdupont

comment:5 Changed 13 months ago by fdupont

It is a minor concern but IMHO the same work should be done for forensic_log. Note as there is only one version it can be postponed...

Still reading the code (with a make check in parallel)...

comment:6 follow-up: Changed 13 months ago by fdupont

  • Owner changed from fdupont to tmark

Why db_version.second is not displayed in Cassandra error messages?

There is no unit test. I can see some reasons:

  • simply forgotten
  • very hard to do (i.e. bad cost / benefit ratio)
  • postponed to the other ticket ($5637)

Anyway in some hours when my make check will finish it will be ready to be merged (with the first point addressed and a decision made for the premium hook). PS: make check successful!

comment:7 in reply to: ↑ 6 Changed 13 months ago by tmark

Replying to fdupont:

Why db_version.second is not displayed in Cassandra error messages?

Copy and paste error, nice catch, I have fixed it.

There is no unit test. I can see some reasons:

  • simply forgotten
  • very hard to do (i.e. bad cost / benefit ratio)

Unit testing this is fairly difficult, system testing it slightly less so. There are unit tests for getVersion() which verify the ability to fetch the schema version and I think that should be sufficient.


  • postponed to the other ticket ($5637)

Anyway in some hours when my make check will finish it will be ready to be merged (with the first point addressed and a decision made for the premium hook). PS: make check successful!

comment:8 Changed 13 months ago by tmark

  • Resolution set to fixed
  • Status changed from reviewing to closed

Changes merged with git# 15c34afdba45be609e35284a209ad18ed66605f8
Added ChangeLog? entry 1415.

ticket is closed.

Note: See TracTickets for help on using tickets.