SShortSingh.
Back to feed

Rails dependent: :destroy Can Silently Cause Timeouts at Scale

0
·1 views

In Ruby on Rails, using dependent: :destroy on a parent model triggers individual destroy callbacks for every associated child record, which can cause severe performance issues when data grows large. For example, deleting an Author with 1,000 books fires after_destroy callbacks — such as Elasticsearch reindexing and touch updates — 1,000 times in series. This pattern often goes unnoticed in development but causes production timeouts once real data volumes accumulate. A safer approach is to first use delete_all on child records within a transaction, which bypasses callbacks entirely via a single SQL statement, then destroy the parent. Any expensive operations like search reindexing should be offloaded to an asynchronous background job run once after the transaction completes.

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 ·

Browser-Based PCB Tools Are the Only Viable Option for Mobile and Chromebook Users

Traditional desktop EDA software like KiCad, Altium, and Eagle cannot run natively on Android, iPadOS, or Chromebooks, leaving mobile users with viewer-only apps that do not support editing. The one common capability across all these devices is a modern web browser, making browser-based tools such as EasyEDA and Flux the practical path to mobile PCB design. Chromebook users face the sharpest constraint, as they cannot install desktop EDA at all, making a browser-based editor their only functional option. Touchscreen limitations make manual component placement difficult on small screens, but AI-assisted tools can help by letting users describe a board in plain language and auto-generating placement and routing. Experts caution that reliable tools should separate AI-driven design decisions from deterministic geometry engines to ensure outputs meet fabrication standards.

0
ProgrammingDEV Community ·

IBM Study: AI Agents Passing 77% of Tests May Succeed Only 53% in Real Use

IBM Research has identified a 'consistency gap' in AI agent performance, revealing that a ReAct agent using GPT-4.1 achieved a 77% per-run pass rate on the AppWorld benchmark but completed the same task successfully across all five repeated runs only 53% of the time. The 24-point gap arises because small variations in early steps of an agent's reasoning loop compound across subsequent steps, producing different outcomes for identical inputs — even without any code, prompt, or model changes. To address this, the researchers built a Consistency Analyzer that identifies the exact step where agent trajectories diverge, then generates targeted guidelines stored as episodic memory for future similar tasks. This approach raised the all-five pass rate by 16 points on known tasks and by 13 points on unseen but similar tasks. The findings challenge standard AI testing practices, where each test case is typically run only once, potentially masking significant real-world unreliability.

0
ProgrammingDEV Community ·

Why Security Teams Must Add Context to Internet Exposure Data

Internet exposure counts are commonly used by security teams to assess attack surfaces, but raw numbers can be misleading without proper context. A single machine may expose multiple services, meaning service counts and device counts are not interchangeable and should not be treated as equivalent. Identifying a product on the internet does not confirm it is vulnerable, as affected versions and specific configurations must also be considered. Exposure data should always include the collection timestamp and clear criteria used to identify the product, enabling more accurate comparisons over time. Analysts are advised to clarify the counting unit, the data source, and whether results indicate exposure or confirmed vulnerability before presenting findings.

0
ProgrammingDEV Community ·

Developer Bypasses Datacenter IP Blocks Using AWS EC2, V2Ray, and Cloudflare WARP

A developer used AWS Free Tier credits to set up a personal proxy server on an EC2 instance over a weekend project. The goal was to route traffic through a residential-like IP to avoid datacenter IP blocks imposed by services such as ChatGPT and Netflix. The setup involved launching a t3.micro Ubuntu instance on AWS, configuring security group firewall rules, and connecting via SSH from a CachyOS client machine. The 3X-UI panel, a web-based manager for V2Ray and Xray proxies, was then installed on the server using a one-line script, with SQLite chosen as the database backend. The article documents each step with real terminal output, including errors encountered and how they were resolved.