Repository navigation
Conversation
mgaffigan
left a comment
There was a problem hiding this comment.
Please add missing DCO.
Also: if this is a mysql specific thing, it should live in the MySQL DAO - not in JdbcDao.
…egrationEngine#489) DatabaseUtil.tableExists and JdbcDao.checkAndCreateChannelTables/tableExists called DatabaseMetaData.getTables with a null catalog, so on MySQL a login with access to other databases matched their tables and a second OIE database was never migrated and missing message tables were not recreated. Pass connection.getCatalog() so each engine only sees its own database; null-catalog behaviour is unchanged on databases where getCatalog() returns null. Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
dc2c0a6 to
06407c5
Compare
Move the catalog scoping behind a JdbcDao flag that MysqlDaoFactory enables, and limit DatabaseUtil.tableExists scoping to MySQL/MariaDB, so other databases keep the existing null-catalog lookup. Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
|
Thanks @mgaffigan, good call. Moved it so only MySQL changes behaviour (DCO is fixed too). There isn't a MySQL-specific DAO class today, so I followed the existing
Tests: |
|
@mgaffigan the changes you requested are in: the table scoping is now MySQL-only (set by |
pacmano1
left a comment
There was a problem hiding this comment.
Tested on MySQL 8.4 with the bundled Connector/J 8.4.0, the PR head against its base, following the steps in #489.
Both effects are fixed. On the base, engine B still fails to start with Table '…SCHEMA_INFO' doesn't exist, and if B's D_MC1 is dropped while B is stopped, B doesn't recreate it on restart, so the next message gets a 500. With the PR, B starts and builds its schema, recreates D_MC1 and takes the message. Engine D with ?nullDatabaseMeansCurrent=true still works with the PR, and engine C on its own login behaves the same on both builds.
DatabaseUtil.indexExists has the same bug. It still calls getIndexInfo(null, null, …). With the PR, after dropping B's own D_MM1_INDEX3, B isn't offered the "Add Metadata Index" database task, because it finds A's index. Drop A's too, with B still running, and the task shows up. Can you scope it the same way?
The description still describes the first version (every database, the old test name, "1 test").
Co-authored with Claude Code.
DatabaseUtil.indexExists still called getIndexInfo with a null catalog, so on MySQL an engine that had lost one of its own indexes found another database's index of the same name and was never offered the task that recreates it. Move the catalog choice into lookupCatalog and use it in both tableExists and indexExists. Adds two DatabaseUtilTest cases; the MySQL one fails without this change. Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
|
Thanks @pacmano1, that's a thorough test, and good catch on
|
Scope table and index lookups to the connection catalog on MySQL (fixes #489)
Problem
The engine's "does this table exist?" and "does this index exist?" checks call
DatabaseMetaDatawith a null catalog. On MySQL, Connector/J then searches every database the login can see, not just the one in the URL. When one login has rights on more than one OIE database on the same server, an engine finds another database's tables or indexes and skips creating or repairing its own:ServerMigrator.initDatabasecallsDatabaseUtil.tableExists(conn, "CONFIGURATION"), finds the other database'sCONFIGURATION, skipsmysql-database.sql, andgetCurrentVersionthen fails on the missingSCHEMA_INFO.JdbcDao.checkAndCreateChannelTableslists tables across all visible databases, so a missingD_MC<n>looks present when another database has a table of that name. Messages then fail withTable 'oie_b.D_MC1' doesn't exist.DatabaseUtil.indexExistsfinds another database's index of the same name (for exampleD_MM1_INDEX3), so the "Add Metadata Index" database task never appears.Fix
Only MySQL (and MariaDB) changes behaviour. Every other database keeps the existing null-catalog lookup.
DatabaseUtil). A newlookupCatalogreturnsconnection.getCatalog()when the database product is MySQL or MariaDB, andnullotherwise.tableExistsandindexExistsboth use it, for their upper- and lower-case lookups.JdbcDao). There is no MySQL-specific DAO class, so this follows the existingsetQuoteCharpattern.JdbcDaogetssetScopeTablesToCatalog(boolean), off by default, whichMysqlDaoFactoryturns on.checkAndCreateChannelTablesandtableExistspass the catalog only when it is enabled.This has the same effect as the reporter's
?nullDatabaseMeansCurrent=trueURL workaround, applied in code.Tests
DatabaseUtilTest(4 tests):tableExistsandindexExistspass the connection's catalog ("oie_b").nullcatalog and never callgetCatalog().indexExiststest fails without the latest commit.JdbcDaoTest:testTableLookupUnscopedByDefaulttestTableLookupScopedToCatalogWhenEnabledgradle :server:test --tests "*DatabaseUtilTest*": 4 tests, 0 failures.End-to-end on MySQL 8.4 with Connector/J 8.4.0, two engines on one login: @pacmano1 confirmed in review that the startup and message-table cases are fixed and that engine D with
?nullDatabaseMeansCurrent=truestill works.