Skip to content

fix: prevent Oracle view crash and connection hang#569

Merged
datlechin merged 1 commit intomainfrom
fix/oracle-view-crash-v2
Apr 3, 2026
Merged

fix: prevent Oracle view crash and connection hang#569
datlechin merged 1 commit intomainfrom
fix/oracle-view-crash-v2

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #568. Fixes the remaining crash/hang issues from #564 — opening Oracle views caused crashes and subsequent connection hangs.

Three root causes:

  1. Query serialization — OracleNIO doesn't support concurrent queries on a single connection. fetchColumns + fetchForeignKeys + main query all ran in parallel, corrupting the state machine. Added QueryGate actor to serialize all executeQuery calls.

  2. Remove DBMS_METADATA.GET_DDL — calling it with wrong object type (e.g. 'TABLE' for a materialized view) triggers ORA-31603, which corrupts OracleNIO's channel handler. Build DDL manually from column info instead.

  3. Avoid LONG columnsDATA_DEFAULT in ALL_TAB_COLUMNS and TEXT in ALL_VIEWS are LONG type. OracleNIO crashes decoding non-NULL LONG values. Removed DATA_DEFAULT from queries; use TEXT_VC (VARCHAR2) for view definitions.

Note: OracleNIO 1.0.0-rc.4 has a force-unwrap bug (self.rowStream!) that requires a library-level patch — tracked separately.

Test plan

  • Connect to Oracle (gvenzl/oracle-free, user=system)
  • Click views in sidebar — should load without crash
  • Switch between view tabs and table tabs — no hang
  • Refresh view tab — completes normally
  • Open Structure tab for views — shows column info

Three root causes fixed:

1. Query serialization (OracleConnection.swift)
   OracleNIO doesn't support concurrent queries on a single connection.
   Add QueryGate actor to serialize all executeQuery calls, preventing
   state-machine corruption when fetchColumns/fetchForeignKeys run in
   parallel with the main query.

2. Remove DBMS_METADATA.GET_DDL (OraclePlugin.swift)
   GET_DDL with wrong object type (e.g. 'TABLE' for a materialized view)
   triggers ORA-31603, which corrupts OracleNIO's channel handler state.
   Build DDL manually from column info instead.

3. Remove DATA_DEFAULT from column queries (OraclePlugin.swift)
   DATA_DEFAULT in ALL_TAB_COLUMNS is LONG type. OracleNIO crashes when
   decoding non-NULL LONG values. Also use DBMS_METADATA.GET_DDL('VIEW')
   for fetchViewDefinition, and add view fallback in fetchTableMetadata.

Note: OracleNIO 1.0.0-rc.4 has a force-unwrap bug at
OracleChannelHandler.swift:441 (self.rowStream!) that requires a
library-level patch — tracked separately for upstream fix.
@datlechin datlechin force-pushed the fix/oracle-view-crash-v2 branch from d3122f1 to 04862f6 Compare April 3, 2026 13:46
@datlechin datlechin merged commit a542476 into main Apr 3, 2026
2 checks passed
@datlechin datlechin deleted the fix/oracle-view-crash-v2 branch April 3, 2026 13:47
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.

1 participant