SShortSingh.
Back to feed

Bug in postgres-js driver causes queries to return corrupt results after timeout

0
·1 views

A recurring crash in a backend service was traced to a bug in the postgres-js database driver, where a query result cursor was not reset after a connection error. When a query is cancelled mid-execution — typically due to a statement timeout — the row counter retains its previous value, causing the next query on that pooled connection to write results into a sparse array with empty leading slots. This produces arrays whose length exceeds the actual row count, explaining why a LIMIT 500 query appeared to return over 800 rows. The failure mode is particularly dangerous because sparse arrays do not throw errors, silently producing nulls in logs, incorrect API responses, or false 'not found' outcomes on valid records. The bug has been present in the upstream postgres-js repository for approximately a year and is difficult to reproduce locally since it requires a slow query to trigger a mid-scan timeout.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Hybrid Search RAG Cuts Missed Retrievals by 30–40% in Internal Doc Systems

A production guide published on DEV Community details how combining vector and keyword search in a Retrieval-Augmented Generation (RAG) pipeline significantly improves retrieval accuracy over internal documents. The approach runs dense vector search (embeddings) and sparse keyword search (BM25 via Elasticsearch) in parallel, then fuses their normalized scores to surface the most relevant results. One team at LogicLoop reported a 22% improvement in MRR@10 after switching from vector-only to hybrid search on their engineering wiki, with benchmark tests across 500,000 Confluence pages and Jira tickets showing hybrid search achieving an MRR@10 of 0.50 versus 0.41 for vector-only. The tradeoff includes roughly 30ms of additional latency and doubled storage overhead from maintaining two indexes simultaneously. A notable edge case was identified for very short queries of one to two words, where keyword search tends to dominate, prompting the team to route such queries to keyword-only search via a simple length check.

0
ProgrammingDEV Community ·

Top LLM Observability Platforms for Enterprises Compared Ahead of 2026

As enterprises scale AI agents from prototypes to production, standard monitoring tools have proven inadequate for tracking the unique challenges of large language model applications. A new category of specialized LLM observability platforms has emerged to provide visibility into prompts, responses, latency, cost, and output quality. Key evaluation criteria for these platforms include end-to-end tracing, root cause analysis, data curation, and enterprise-grade security and scalability. Leading options in 2026 include Maxim AI, LangSmith, Langfuse, and Arize, each offering distinct strengths suited to different team needs and existing toolchains. The right platform choice ultimately depends on an organization's scale, technical ecosystem, and the complexity of the AI agents it deploys.

0
ProgrammingDEV Community ·

How to Connect Power BI to Local and Cloud PostgreSQL Databases via Aiven

Power BI can be connected to PostgreSQL databases both locally and via cloud-hosted services like Aiven, following a structured setup process. For local connections, users configure DBeaver with localhost credentials before linking Power BI Desktop through the Get Data option using the default port 5432. Cloud connections through Aiven require an additional SSL step, where a CA certificate downloaded from the Aiven dashboard must be imported into Windows' Trusted Root Certification Authorities. Once the certificate is successfully imported, the Aiven cloud database behaves similarly to a local connection within Power BI. After either setup, users can model data, write DAX formulas, and build live dashboards reflecting the latest database content.

0
ProgrammingDEV Community ·

How to Build Production-Ready AI Agents with FastAPI and OpenAI SDK

A developer with over a year of running AI agents in production has shared a practical guide to building them using FastAPI and the OpenAI Python SDK. The tutorial covers a minimal FastAPI setup that accepts prompts and returns OpenAI responses, handling common errors like rate limits and timeouts. It then demonstrates how to enable tool use, allowing the agent to call external functions such as internal APIs, with the OpenAI SDK managing the function-calling loop. The guide also addresses stateful agents, recommending Redis for persisting chat history and user preferences across sessions using Pydantic models. The author emphasizes avoiding manual state machine implementations in favor of letting the SDK handle the tool call and response cycle for reliability.