microsoft/semantic-kernel · error · VectorStoreOperationException

Collection has no connection pool.

Error message

Collection has no connection pool.

What it means

Thrown by OracleCollection._check_pool when connection_pool is None - the pool was never created, or was set to None after __aexit__ closed a managed pool. Every DB operation funnels through _check_pool.

Source

Thrown at python/semantic_kernel/connectors/oracle.py:408

    async def __aenter__(self) -> "OracleCollection":
        return self

    @override
    async def __aexit__(self, *args: Any) -> None:
        # Only close the connection pool if it was created by the collection itself.
        if self.managed_client and self.connection_pool:
            try:
                await self.connection_pool.close()
            except Exception as e:
                logger.warning("Error closing Oracle connection pool: %s", e)
            finally:
                self.connection_pool = None
                self.managed_client = False

    def _check_pool(self) -> oracledb.AsyncConnectionPool:
        """Ensure that the connection pool is available, otherwise raise a consistent error."""
        if self.connection_pool is None:
            raise VectorStoreOperationException("Collection has no connection pool.")
        return self.connection_pool

    @override
    def _deserialize_store_models_to_dicts(self, records: Sequence[Any], **kwargs: Any) -> Sequence[dict[str, Any]]:
        """Deserialize the store models to a list of dicts. Pass the records through without modification."""
        return records

    def _full_table_name(self) -> str:
        """Return the fully qualified table name with optional schema prefix, quoted."""
        self._validate_identifiers(self.collection_name)
        if self.db_schema:
            self._validate_identifiers(self.db_schema)
            return f'"{self.db_schema}"."{self.collection_name}"'
        return f'"{self.collection_name}"'

    async def _get_connection(self):
        """Acquire a connection from the pool, ensuring input/output type handlers are always set.

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure a valid connection_pool exists before invoking any collection operation
  2. Use the collection inside an `async with` block, or pass a long-lived externally-managed pool
  3. Do not reuse a collection after its __aexit__ closed the managed pool - construct a new one
  4. If managing the pool externally, pass it via connection_pool= and keep it open for the collection's lifetime

Example fix

# before - collection used after pool closed
async with OracleCollection(record_type=MyModel) as col:
    await col.ensure_collection_exists()
await col._inner_upsert([...])  # pool is now None -> 1512

# after - perform all work inside the context
async with OracleCollection(record_type=MyModel) as col:
    await col.ensure_collection_exists()
    await col._inner_upsert([...])
Defensive patterns

Strategy: validation

Validate before calling

def collection_has_pool(collection) -> bool:
    return getattr(collection, 'connection_pool', None) is not None

if not collection_has_pool(collection):
    raise RuntimeError('Collection has no pool; reconstruct or pass a valid connection_pool')

Try / catch

from semantic_kernel.exceptions import VectorStoreOperationException

try:
    await collection._inner_upsert(records)
except VectorStoreOperationException as e:
    if 'no connection pool' in str(e):
        # reconstruct the collection or pass a fresh connection_pool
        ...

Prevention

When it happens

Trigger: Using the collection after `async with collection:` exited (which sets connection_pool=None for managed clients); constructing without creating a pool; calling operations on a collection whose pool failed to initialize.

Common situations: Forgetting the async context manager boundaries; reusing a collection after its managed pool was closed in __aexit__; passing connection_pool=None with settings that silently produced no pool.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/5f75421f1d6136f5. Report an issue: GitHub.