Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

This reverts commit ae3a7f0.

@vercel
Copy link

vercel bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Building Building Preview Comment Oct 8, 2025 3:35pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 8, 2025 3:35pm

@waleedlatif1 waleedlatif1 merged commit 23ff7fb into staging Oct 8, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/da branch October 8, 2025 15:36
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This pull request reverts a previous commit (ae3a7f0) that apparently caused database connection issues in the socket server components. The changes restore dedicated database connection pools for socket operations with more conservative connection parameters across three key files.

The main change involves adjusting database connection pool configurations throughout the socket server infrastructure. In packages/db/index.ts, the shared database connection pool is expanded from 20 to 30 max connections with a longer connect timeout (30 seconds vs 10 seconds), along with comprehensive logging for connection pool initialization. The socket server operations (apps/sim/socket-server/database/operations.ts) now use a dedicated connection pool with 15 max connections, 10-second idle timeout, and 20-second connect timeout. The room manager (apps/sim/socket-server/rooms/manager.ts) gets its own connection settings with 15-second idle timeout and 20-second connect timeout.

This approach creates a multi-tiered database connection strategy where socket operations use dedicated connection pools separate from the main application's shared pool. The extensive logging added to the main database module suggests this change was driven by production connection issues that were difficult to diagnose. The comment "fallback to shared db for compatibility" indicates this is part of a broader architectural pattern to isolate socket operations while maintaining backward compatibility.

Important Files Changed

Changed Files
Filename Score Overview
packages/db/index.ts 4/5 Enhanced main database connection pool with logging, increased limits, and longer timeouts
apps/sim/socket-server/database/operations.ts 4/5 Reverted to dedicated socket database connection with conservative pool settings
apps/sim/socket-server/rooms/manager.ts 3/5 Updated room manager database connection with moderate timeout adjustments

Confidence score: 3/5

  • This PR addresses connection stability issues but introduces configuration inconsistencies across different database clients
  • Score reflects the revert nature of changes and potential for configuration drift between different connection pools
  • Pay close attention to apps/sim/socket-server/rooms/manager.ts for potential connection parameter mismatches with other socket components

Sequence Diagram

sequenceDiagram
    participant User
    participant SocketServer
    participant Database
    participant ConnectionPool

    User->>SocketServer: "Connect to workflow room"
    
    note over SocketServer: "Socket connection established"
    
    SocketServer->>ConnectionPool: "Get dedicated socket connection"
    ConnectionPool-->>SocketServer: "Return postgres connection"
    
    SocketServer->>Database: "Query workflow state"
    Database-->>SocketServer: "Return workflow data"
    
    User->>SocketServer: "Send workflow operation"
    note right of User: "e.g., add/update block, edge"
    
    SocketServer->>Database: "Begin transaction"
    Database-->>SocketServer: "Transaction started"
    
    SocketServer->>Database: "Update workflow timestamp"
    Database-->>SocketServer: "Timestamp updated"
    
    SocketServer->>Database: "Execute operation (block/edge/subflow/variable)"
    Database-->>SocketServer: "Operation completed"
    
    alt "Auto-connect edge exists"
        SocketServer->>Database: "Insert auto-connect edge"
        Database-->>SocketServer: "Edge inserted"
    end
    
    alt "Subflow block type"
        SocketServer->>Database: "Create subflow entry"
        Database-->>SocketServer: "Subflow created"
    end
    
    alt "Has parent block"
        SocketServer->>Database: "Update parent subflow node list"
        Database-->>SocketServer: "Parent updated"
    end
    
    SocketServer->>Database: "Commit transaction"
    Database-->>SocketServer: "Transaction committed"
    
    SocketServer->>User: "Emit operation success"
    
    note over SocketServer,Database: "Dedicated connection pool for socket operations"
Loading

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

2 participants