Skip to content

oracledb: various test fixes#4307

Open
mmatczuk wants to merge 9 commits intomainfrom
mmt/oracledb-fixes-v2
Open

oracledb: various test fixes#4307
mmatczuk wants to merge 9 commits intomainfrom
mmt/oracledb-fixes-v2

Conversation

@mmatczuk
Copy link
Copy Markdown
Contributor

Commits

  • increase integration test timeout from 10m to 30m
  • handle LOB_TRIM events to establish LOB locator state
  • use background context for deferred EndSession cleanup
  • tolerate missing checkpoint cache table in CDC LOB toggle test
  • guard nil stream in CDC LOB toggle test cleanup
  • avoid data race in snapshot transaction rollback
  • do not hardcode IDENTITY column values in streaming tests
  • infer LOB locator for BASICFILE out-of-line LOBs
  • infer LOB locator for BASICFILE out-of-line LOB INSERTs

Jira

  • CON-388
  • CON-405
  • CON-408
  • CON-421
  • CON-423
  • CON-424
  • CON-436
  • CON-441

The 14 integration tests each start a fresh Oracle Free container (~40s
startup each). With shuffled test ordering, earlier tests consumed ~9.9
of the 10-minute budget, leaving only ~6 seconds for
TestIntegrationOracleDBCDCSnapshotSchema which was killed immediately.

Bump to 30m to provide sufficient headroom for the full test suite.

Fixes CON-405
Oracle emits LOB_TRIM (op 11) before LOB_WRITE for certain LOB column
types (e.g. out-of-line VARCHAR MAX). Without processing LOB_TRIM, the
LOB locator state is never established and subsequent LOB_WRITE events
are dropped, causing the column to be silently absent from streaming
records.

Add OpLobTrim to the query filter and handle it alongside
OpSelectLobLocator since both share the same SQL structure.

Fixes CON-408
The deferred EndSession call in ReadChanges used the parent context
which is already cancelled during shutdown. The go-ora driver's
ExecContext races internally when given a cancelled context:
StartContext spawns a goroutine that writes the session break flag
while the main goroutine reads it.

Fixes CON-421
The TRUNCATE TABLE RPCN.CDC_CHECKPOINT_CACHE between the lob_enabled=false
and lob_enabled=true subtests fails with ORA-00942 if the first subtest
exits early (before stream.Run creates the table lazily via Connect()).
Replace MustExec with a plain Exec that ignores the error since there is
nothing to clean up if the table was never created.

Fixes CON-423
The outer test declares a shared *service.Stream that both subtests
assign to. If the lob_enabled=true subtest fails during Build(), the
shared variable is nil and the outer StopWithin panics. Add a nil
guard before calling StopWithin.

Fixes CON-424
Use context.Background() for BeginTx to prevent database/sql from
spawning an awaitDone goroutine that calls Rollback on context
cancellation. The go-ora v2 driver has an unsynchronized field in
Session.BreakConnection/IsBreak that causes a data race when two
concurrent Rollback calls occur. Transaction lifetime is already
managed manually via defer and explicit Rollback.

Fixes CON-388
The Oracle GENERATED ALWAYS AS IDENTITY sequence persists across test
runs because CreateTableWithSupplementalLoggingIfNotExists skips table
recreation when the table already exists. Assert message structure and
VAL value without assuming ID=1.

Fixes CON-436
Oracle does not emit SELECT_LOB_LOCATOR events for BASICFILE
out-of-line LOBs (DISABLE STORAGE IN ROW). LOB_WRITE fragments
arrived without a preceding locator and were silently discarded,
causing the assembled CDC record to be missing those columns.

When LOB_WRITE arrives without an active locator, search the
transaction's buffered DML events for a LOB-init UPDATE with
EMPTY_CLOB()/EMPTY_BLOB() placeholders. Use the UPDATE's column
name and WHERE-clause PK values to create a synthetic locator so
subsequent LOB_WRITE fragments are accumulated and merged into
the correct DML event at commit time.

Fixes CON-408
BASICFILE LOB columns with DISABLE STORAGE IN ROW emit NULL in the
INSERT SQL_REDO instead of EMPTY_CLOB()/EMPTY_BLOB(), so the LOB
column is absent from the parsed INSERT event's Data map. The
existing inference logic only searched LOB-init UPDATEs for empty
placeholders, so LOB_WRITE fragments for these INSERTs arrived
without an active locator and were dropped — leaving the column
missing from the streamed CDC record.

Extend inferLOBLocator to also walk INSERT events in the transaction
buffer. For INSERTs, iterate the table's known LOB columns and treat
any column that is either absent from Data or present with an empty
[]byte{} placeholder as a candidate. The INSERT's non-LOB columns
are used as the PK so the accumulated LOB data is merged into the
correct row even after earlier LOB columns have been overwritten.

Fixes CON-441
@claude
Copy link
Copy Markdown

claude Bot commented Apr 20, 2026

Commits
LGTM

Review
Series of oracledb CDC/test fixes: LOB locator inference for BASICFILE out-of-line LOBs, LOB_TRIM handling, snapshot transaction data-race fix, and assorted integration-test hardening. Each commit is scoped to one logical change and explains the underlying Oracle/go-ora behavior in the message body. The context.Background() uses in snapshot.go and logminer.go would normally violate the project's context-propagation rule, but both sites are deferred/cleanup paths carrying inline comments explaining the go-ora race they work around — justified exceptions.

LGTM

This was referenced Apr 20, 2026
@josephwoodward
Copy link
Copy Markdown
Contributor

Will review these shortly

@josephwoodward josephwoodward self-assigned this Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants