Skip to content

Instantly share code, notes, and snippets.

View cphillips83's full-sized avatar

Chris Phillips cphillips83

View GitHub Profile
-- Fix: add missing index on orders.status for active order queries
-- Author: DBA Team
-- Date: 2026-03-16
BEGIN;
CREATE INDEX CONCURRENTLY idx_orders_status
ON orders(status)
WHERE status != 'completed';
@cphillips83
cphillips83 / debugging-requestcontext-leak.md
Created February 6, 2026 05:55
Debugging a RequestContext Memory Leak with AI Assistance - A case study in human-AI collaboration

Debugging a RequestContext Memory Leak with AI Assistance

TL;DR

A senior developer and Claude AI collaborated to diagnose and fix a memory leak in an ASP.NET application where RequestContext objects were being created but not torn down. The fix took ~2 hours of iterative debugging, not "ask AI and done." This document shows how AI assistance requires domain expertise to be effective.

The Problem

ActiveContextCount kept climbing from 1 to 139+ without returning to baseline. Requests were being set up but not torn down, causing a memory/connection leak.

function k { kubectl @args }
function kl { kubectl logs @args }
function kg { kubectl get @args }
function kd { kubectl describe @args }
function ke { kubectl exec -it @args -- sh }
function kaf { kubectl apply -f @args }
function kdf { kubectl delete -f @args }
DECLARE @CurrentDataType VARCHAR(max)
DECLARE @DataTypeToChange VARCHAR(max)
DECLARE @SQLQUERY nvarchar(max)
SET @CurrentDataType = 'text' ---CHANGE HERE !!
SET @DataTypeToChange = 'nvarchar(max)' ---CHANGE HERE !!
DECLARE MY_CURSOR CURSOR
LOCAL STATIC READ_ONLY FORWARD_ONLY
FOR

Keybase proof

I hereby claim:

  • I am cphillips83 on github.
  • I am cphillips83 (https://keybase.io/cphillips83) on keybase.
  • I have a public key ASDqejrSmBkEJzargId4fRVaIFwIg4xbF0HaWKP-DvYRogo

To claim this, I am signing this object:

@cphillips83
cphillips83 / nginx.md
Last active March 7, 2020 03:09 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

https://www.blackmoreops.com/2014/09/25/find-number-of-unique-ips-active-connections-to-web-server/

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depend
//https://github.com/marcel-dempers/docker-development-youtube-series
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace dockergraveful
{
class Program
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
{
var q0 = dc.Contacts
.Where(x => x.ID > 1 && x.Status == EntityStatus.Active)
.OrderByDescending(x => x.ID)
.Select(x => new { x.ID, x.Status });
var c0 = q0.FirstOrDefault();
Console.WriteLine(c0);
}