Skip to content

Instantly share code, notes, and snippets.

View msdousti's full-sized avatar

Sadeq Dousti msdousti

View GitHub Profile
@msdousti
msdousti / cec.md
Last active November 12, 2026 21:18

Adding a CiliumEnvoyConfig (CEC) next to an L7 CiliumNetworkPolicy

Audience: an LLM or engineer applying this to a real cluster. Follow "Procedure" in order. Everything under "Verified" was observed in a test cluster. Everything under "Not verified" was not tested; treat it as a risk.

1. Problem this solves

Setup: a Service is protected by a CiliumNetworkPolicy (CNP) that allow-lists client pods and has an L7 rules.http section that stamps a client header (headerMatches with mismatch: ADD).

@msdousti
msdousti / plpgsql-cross-partition-update.sh
Created August 16, 2026 19:37
Script to measure the time of N concurrent jobs updating a partitioned postgres table, using PL/pgSQL and sharding
#!/usr/bin/env bash
#
# Usage:
# ./plpgsql-cross-partition-update.sh <num_jobs>
#
# Connection info comes from the standard libpq environment variables,
# which psql picks up automatically (no flags needed):
# PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD (also PGSSLMODE etc.)
#
# Example:
@msdousti
msdousti / postgres-cross-partition-update.sh
Last active August 16, 2026 18:40
Script to measure the time and serialization failures of N concurrent jobs updating a partitioned postgres table
#!/usr/bin/env bash
#
# Usage:
# ./postgres-cross-partition-update.sh <num_jobs>
#
# Connection info comes from the standard libpq environment variables,
# which psql picks up automatically (no flags needed):
# PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD (also PGSSLMODE etc.)
#
# Example:
SELECT
c.relname,
a.grantor::regrole,
a.grantee::regrole,
c.relowner::regrole,
array_agg(a.privilege_type ORDER BY a.privilege_type) AS privileges
FROM
pg_class c
JOIN pg_namespace n ON c.relnamespace = n.oid
LEFT JOIN aclexplode(c.relacl) AS a ON TRUE
package main
import (
"fmt"
"math/rand"
"net/http"
"time"
)
func hello(w http.ResponseWriter, req *http.Request) {
import http from 'k6/http';
export const options = {
vus: 100,
// iterations: 1000,
duration: '30s',
thresholds: {
http_req_failed: [{
threshold: 'rate<0.2',
import matplotlib.pyplot as plt
import numpy as np
# Provided data
data = [
5, 18, 32, 40, 54, 68, 80, 100, 110, 119, 125, 136, 144, 149, 154, 160, 165,
171, 178, 182, 189, 195, 202, 211, 216, 222, 227, 234, 239, 245, 250, 256,
261, 268, 273, 278, 283, 289, 295, 301, 307, 314, 320, 325, 332, 339, 346,
352, 358, 364, 370, 376, 383, 389, 396, 402, 409, 415, 422, 429, 436, 443,
450, 458, 466, 473, 481, 489, 496, 503, 511, 519, 527, 536, 545, 555, 564,
* explain.h all over the place
* saving query plan before executing it (execMain.c)
* performance?
* GUC to enable?
* TAP tests
* pg_stat_session --> "One row per client backend"
--> should the name indicate this, e.g. pg_stat_client_backend
* Information is scattered between pg_stat_activity and this view, requiring join
* Example: client_addr, application_name, usename
* Can we define this outside the function pg_stat_get_session?
#define PG_STAT_GET_SESSION_COLS 9
create table t (
id bigint generated always as identity not null,
created_at timestamptz not null)
partition by range (created_at);
create index t__id__created_at__idx
on t(id, created_at);
-- partition for next month