Repository navigation
Conversation
d21c443 to
e93c8b2
Compare
8cd81f7 to
8089545
Compare
80f98ae to
f387227
Compare
f387227 to
aaf6d12
Compare
Connect docs checkThe docs build passed with this PR's generated docs. This PR changes 1 published page (2 generated files: 2 changed, 0 added, 0 removed). Review the rendered pages, not only the Go strings.
Per-file diffs and the rendered-HTML findings are in the job summary. Checked at 6538445. |
…dure All cache tables in a schema shared one stored procedure whose body contained the table name of the first pipeline. A second pipeline with another table in the same schema wrote its checkpoints to the wrong table. A MERGE statement from the connector removes the shared object.
abddbd1 to
b9329a1
Compare
| == Permissions | ||
|
|
||
| When using the default Oracle based cache, the Connect user requires permission to create tables and stored procedures, and the ` + "`rpcn`" + ` schema must already exist. Refer to ` + "`" + ociFieldCheckpointCacheTableName + "`" + ` for more information. | ||
| When using the default Oracle based cache, the Connect user requires permission to create tables, and the ` + "`rpcn`" + ` schema must already exist. Refer to ` + "`" + ociFieldCheckpointCacheTableName + "`" + ` for more information. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
| == Permissions | ||
|
|
||
| When using the default Oracle based cache, the Connect user requires permission to create tables and stored procedures, and the ` + "`rpcn`" + ` schema must already exist. Refer to ` + "`" + ociFieldCheckpointCacheTableName + "`" + ` for more information. | ||
| When using the default Oracle based cache, the Connect user requires permission to create tables, and the ` + "`rpcn`" + ` schema must already exist. Refer to ` + "`" + ociFieldCheckpointCacheTableName + "`" + ` for more information. |
There was a problem hiding this comment.
The MERGE needs a privilege the old procedure call did not: INSERT on the checkpoint table for the connector user. The procedure ran with its owner's rights, so the connector user only needed EXECUTE on it, plus SELECT and UPDATE on the table for Get and migrateCacheTable.
I tried it on Oracle Free with a user that has only SELECT, UPDATE and EXECUTE. The old BEGIN ...CDC_CHECKPOINT_CACHE_UPDATE(:1, :2); END; call works. The new MERGE fails with ORA-41900: missing INSERT privilege, even when the row already exists. Since Set errors are only logged, such a pipeline keeps running after the upgrade and stops saving checkpoints.
Two things would cover it:
- Say here that the user needs
SELECT,INSERTandUPDATEon the checkpoint table, and mention it in the release note as an upgrade step. - Add the start up write probe you describe in the PR body (a
MERGEin a rolled back transaction), so a missing grant failsConnectinstead of being logged at the first checkpoint. Fine as a follow-up if you want to keep this PR small.
There was a problem hiding this comment.
Done in this PR. At start up, the cache runs the MERGE in a transaction and rolls it back. Without INSERT or UPDATE, it logs a warning with the GRANT to run, sets oracledb_cdc_checkpoint_legacy_procedure to 1, and writes with the stored procedure as before. The docs list SELECT, INSERT and UPDATE on the checkpoint table, and the commit message has the upgrade step. A future version removes the fallback, and then a failed probe fails Connect. TestIntegrationCheckpointCacheProcedureFallback reproduces your ORA-41900 case.
…sky-acd5b6 # Conflicts: # internal/impl/oracledb/checkpoint_cache.go
Oracle 23ai returns ORA-41900 for a missing object privilege, and older versions return ORA-01031. The snapshot checked both codes for the FLASHBACK grant. The checkpoint cache needs the same check, so it moves to replication.IsMissingPrivilege.
…SERT The stored procedure runs with the rights of its owner, so a user with only SELECT and UPDATE on the checkpoint table and EXECUTE on the procedure could write checkpoints. The MERGE fails for that user with ORA-41900 (or ORA-01031). At start up, the cache now runs the MERGE in a transaction and rolls it back. If a privilege is missing, it logs a warning with the GRANT to run, sets the gauge oracledb_cdc_checkpoint_legacy_procedure to 1, and writes with the stored procedure as before. Another probe error fails Connect, so that it tries again. Upgrade step: grant SELECT, INSERT and UPDATE on the checkpoint table to the Connect user. A future version removes the stored procedure fallback.
#4880 now probes the MERGE at start up and falls back to the stored procedure when a privilege is missing. This PR keeps only the checkpoint write error counter, which is useful for any checkpoint cache.
… helper TestIntegrationCheckpointCacheTablesInSameSchema now writes through two caches instead of two pipelines. It still fails with the old per-schema procedure, and runs in 0.5 s instead of 13 s. The fallback test creates the procedure with the production createUpsertStoredProc instead of a copy of its SQL. TestDB.CreateUserWithGrants replaces two copies of the same helper, in the checkpoint cache and the flashback snapshot tests. IsMissingPrivilege links the Oracle docs of ORA-01031 and ORA-41900.
…exports selectCheckpointWrite now picks between mergeWrite and procedureWrite. The rolled back probe moves to replication.ProbeStatement, next to IsMissingPrivilege, and TestIntegrationProbeStatement checks both against a real Oracle error. The checkpoint cache tests move to the internal test package, so export_test.go is no longer needed. The Permissions docs are shorter.
mergeWrite returns the raw probe error. selectCheckpointWrite handles success, other errors and a missing privilege one after the other, so the warning starts with its own sentence and not with a wrapped error.
…claude/wizardly-meninsky-acd5b6 # Conflicts: # internal/impl/oracledb/input_oracledb_cdc.go
…ntence CreateUserWithGrants takes t, so a failed grant is reported on the subtest that uses the user, and the user is dropped when that subtest ends.
Summary
The checkpoint cache wrote through a stored procedure,
<schema>.CDC_CHECKPOINT_CACHE_UPDATE. One procedure exists per schema, and its body hard-codes the table of the first pipeline that started. A second pipeline with anothercheckpoint_cache_table_namein the same schema reuses that procedure. It writes its checkpoints to the first pipeline's table and reads them from its own. On restart it finds no checkpoint and starts from scratch.This always happens in multitenant mode. Every pluggable database (PDB) gets its own table under
C##RPCN, so two PDBs on one container database (CDB) share the procedure.The fix writes with a
MERGEon the pipeline's own table. The procedure runs with the rights of its owner, but aMERGEruns with the rights of the Connect user and needsINSERTandUPDATEon the table. A user that a DBA set up with onlySELECT,UPDATEandEXECUTEwould stop saving checkpoints after the upgrade, without an error (a failed write only fails the ack). So the cache probes theMERGEat start up and falls back to the procedure for those users:The fallback is the current code, unchanged. A pipeline on the fallback keeps today's behavior, the bug included. The warning tells it to grant
INSERT, and the grant moves it toMERGE.Upgrade step for the release note: grant
SELECT,INSERTandUPDATEon the checkpoint table to the Connect user. A future version removes the fallback. Then a failed probe failsConnectwith theGRANTtext, so a missed warning gives a startup error, not lost checkpoints.The Permissions docs list the
SELECT,INSERTandUPDATEgrants on the checkpoint table, the fallback, and the gauge.replication.IsMissingPrivilegechecks ORA-01031 and ORA-41900 (Oracle 23ai). The snapshot already checked both codes forFLASHBACK. Now the snapshot and the probe both use it. The probe itself isreplication.ProbeStatement, next to it.Evidence
TestIntegrationCheckpointCacheProcedureFallback(new) connects as a user withSELECT, UPDATEon the table andEXECUTEon the procedure, then writes a checkpoint:TestIntegrationCheckpointCacheTablesInSameSchema(new):TestIntegrationProbeStatement(new, replication package):TestIntegrationMigrateCheckpointCache,TestIntegrationCheckpointCacheNameIsAView,TestIntegrationCheckpointCacheConcurrentCreateandTestIntegrationSnapshotChunkedstill pass.Merge Danger
Door: two-way
A revert brings back the procedure for every pipeline. The
MERGEpath creates nothing new, so a rollback needs no DBA action.Blast Radius: checkpoints
MERGEgrants no longer needsCREATE PROCEDURE. An old procedure stays in the schema, unused. A DBA can drop it.MERGEand rolls it back, with a 10 second timeout. Two pipelines that probe the same table at the same time wait for each other on the probe key until the first one rolls back. LogMiner skips rolled back transactions, and the checkpoint table is not ininclude.Connect, which tries again. Before, start up did not depend on it.