PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Airtable

Implement a Connection Pool

Last updated: Apr 6, 2026

Quick Overview

This question evaluates a candidate's competence in resource management, object ownership and lifecycle handling, and safe reuse of pooled database connections.

  • medium
  • Airtable
  • Software Engineering Fundamentals
  • Software Engineer

Implement a Connection Pool

Company: Airtable

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

You are given an existing `DBConnection` class that simulates a physical database connection. It exposes the following methods and must not be modified: - `initialize()` - `query(sql: str)` - `close()` Implement the missing behavior for `ConnectionPool` and `PoolConnection`. Skeleton: `class DBConnection:` - `__init__(self)` - `initialize(self)` - `query(self, sql: str) -> str` - `close(self)` Destroys the physical connection. `class ConnectionPool:` - `__init__(self, max_conn: int)` - `get_connection(self) -> PoolConnection | None` `class PoolConnection:` - `__init__(self, parent: ConnectionPool, db_conn: DBConnection)` - `query(self, sql: str)` - `close(self)` Requirements: 1. `ConnectionPool(max_conn)` - Throw an error if `max_conn <= 0`. - Track how many connections are currently checked out. - Track previously used `DBConnection` instances that have been returned to the pool. 2. `ConnectionPool.get_connection()` - If the number of active checked-out connections has reached `max_conn`, return `None`. - If an idle `DBConnection` is available in the pool, reuse it. - Otherwise create a new `DBConnection`, initialize it, and return it wrapped in a `PoolConnection`. 3. `PoolConnection.query(sql)` - Forward the call to the underlying `DBConnection.query(sql)`. - If this `PoolConnection` has already been closed, throw an error. 4. `PoolConnection.close()` - Return the underlying `DBConnection` to the parent `ConnectionPool` so it can be reused later. - Do not destroy the underlying `DBConnection` when a `PoolConnection` is closed. - Prevent a closed `PoolConnection` from being queried again. - Prevent double-closing, or treat it as an error. The goal is to implement a simple reusable connection pool with correct ownership and lifecycle handling.

Quick Answer: This question evaluates a candidate's competence in resource management, object ownership and lifecycle handling, and safe reuse of pooled database connections.

Related Interview Questions

  • Optimize a dispatcher’s scheduling data structures - Airtable (easy)
  • Explain how to make robust HTTP API calls - Airtable (medium)
|Home/Software Engineering Fundamentals/Airtable

Implement a Connection Pool

Airtable logo
Airtable
Jan 25, 2026, 12:00 AM
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
14
0

You are given an existing DBConnection class that simulates a physical database connection. It exposes the following methods and must not be modified:

  • initialize()
  • query(sql: str)
  • close()

Implement the missing behavior for ConnectionPool and PoolConnection.

Skeleton:

class DBConnection:

  • __init__(self)
  • initialize(self)
  • query(self, sql: str) -> str
  • close(self)
    Destroys the physical connection.

class ConnectionPool:

  • __init__(self, max_conn: int)
  • get_connection(self) -> PoolConnection | None

class PoolConnection:

  • __init__(self, parent: ConnectionPool, db_conn: DBConnection)
  • query(self, sql: str)
  • close(self)

Requirements:

  1. ConnectionPool(max_conn)
  • Throw an error if max_conn <= 0 .
  • Track how many connections are currently checked out.
  • Track previously used DBConnection instances that have been returned to the pool.
  1. ConnectionPool.get_connection()
  • If the number of active checked-out connections has reached max_conn , return None .
  • If an idle DBConnection is available in the pool, reuse it.
  • Otherwise create a new DBConnection , initialize it, and return it wrapped in a PoolConnection .
  1. PoolConnection.query(sql)
  • Forward the call to the underlying DBConnection.query(sql) .
  • If this PoolConnection has already been closed, throw an error.
  1. PoolConnection.close()
  • Return the underlying DBConnection to the parent ConnectionPool so it can be reused later.
  • Do not destroy the underlying DBConnection when a PoolConnection is closed.
  • Prevent a closed PoolConnection from being queried again.
  • Prevent double-closing, or treat it as an error.

The goal is to implement a simple reusable connection pool with correct ownership and lifecycle handling.

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Airtable•More Software Engineer•Airtable Software Engineer•Airtable Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.