Opened 16 years ago

Closed 16 years ago

#4625 closed patch (fixed)

Verify TV Database Schema Version on startup

Reported by: sphery <mtdean@…> Owned by: cpinkham
Priority: critical Milestone: 0.21
Component: mythtv Version: unknown
Severity: high Keywords:
Cc: Ticket locked: no

Description

The attached patch, mythtv-verify_schema_version.patch , prevents mythfrontend from upgrading the schema version and prevents an "old" mythbackend or mythtv-setup from running against a newer schema version than it understands. With the new autodetection code, allowing mythfrontend to upgrade the schema version could have undesired consequences. Also, allowing mythbackend or mythtv-setup to change data in a database with a different schema than expected could result in corrupted data.

Rather than modify UpgradeTVDatabaseSchema() to accept a bool upgradeAllowed (default true) and call it from mythfrontend as UpgradeTVDatabaseSchema(false), which would only handle preventing mythfrontend from upgrading the schema, I added a new function, CheckTVDatabaseSchema() in libs/libmythtv/dbcheck.cpp. A separate call to this new function before calling UpgradeTVDatabaseSchema() allows preventing old backends and mythtv-setup (which are allowed to upgrade the schema) from running when they don't understand the schema version (i.e. old backend/mythtv-setup shouldn't modify data in the DB if they don't know about future changes to the schema).

To allow frontend-only users (i.e. those using MythVideo/MythMusic?, but not using any TV functionality) to upgrade the schema, there is a new command-line argument for mythfrontend, --upgrade-schema, that allows it to upgrade the schema. Alternatively, those users may simply run mythtv-setup or mythbackend to upgrade the database.

The patch supports MythContext::PromptForSchemaUpgrade?()'s "expertMode" (DBSchemaAutoUpgrade=-1). In this mode, it will allow running an old mythbackend/mythtv-setup/mythfrontend against a newer schema version. Since the patch doesn't prevent mythbackend or mythtv-setup from upgrading the database, it would still be possible to run them against an old schema version with expertMode. However, since it tries to prevent mythfrontend from upgrading the schema version, enabling expertMode explicitly enables mythfrontend to upgrade the schema version (and, therefore, would also allow mythfrontend to run against and old schema version).

Attachments (1)

mythtv-verify_schema_version.patch (6.1 KB) - added by sphery <mtdean@…> 16 years ago.

Download all attachments as: .zip

Change History (4)

Changed 16 years ago by sphery <mtdean@…>

comment:1 Changed 16 years ago by cpinkham

Owner: changed from Isaac Richards to cpinkham
Status: newassigned

comment:2 Changed 16 years ago by cpinkham

Milestone: unknown0.21
Priority: minorcritical
Severity: mediumhigh

comment:3 Changed 16 years ago by cpinkham

Resolution: fixed
Status: assignedclosed

(In [15902]) Add some additional DB Schema version checking.

mythbackend

  • can upgrade schema (as before) if schema is older than expected
  • can not run if schema is newer than expected

mythtv-setup

  • can upgrade schema (as before) if schema is older than expected
  • can not run if schema is newer than expected

mythfrontend

  • can _only_ upgrade schema if '-u' or '--upgrade-schema' given as argument
  • can not run if schema is newer than expected

This means that you now need to startup mythbackend or mythtv-setup first whenever the schema needs to be upgraded, or you can run mythfrontend with the -u command line argument.

Closes #4625 using patch by Michael T. Dean.

Note: See TracTickets for help on using tickets.