RSSAmplifier

Blog

Home on A blog

Recent content in Home on A blog

achanda.devRSS feed ↗8 posts

Latest posts

Running Postgres on Cloudflare Containers

Disclaimer: I work for Cloudflare. The views and opinions expressed in this post are my own and do not necessarily reflect the official policy or position of Cloudflare. 
 Cloudflare recently launched Cloudflare Containers allowing running containerized
applications with workers. To use this, an user would need to define an application in a dockerfile, define a worker, and bind the…

Postgres Protocol and a Side Quest

I was watching Heikki Linnakangas’s talk on the Postgres protocol. I wanted to
follow along with and see the protocol in action for myself. I ran into a problem here: my ostgres server rejected all non secure
connections. And with TLS enabled, I could not get wireshark to decode postgres protocol messages because of encryption. 
 Now, wireshark supports decoding TLS connections…

TIL: Looking at RocksDB Events

RocksDB has an eventing system that clients can use to listen on
specific events within the DB. These events are written to the log file when RocksDB runs. The name of the log file is LOG 
by default and is located in the database directory. 
 The whole log file is not in json format, so we need to grep to convert the output to json. Here is a bash one-liner that
continuously tails…

pg_power: initialization and basic setup

I have been playing around with the powercap framework . I wrote
a postgres extension that shows the energy usage of a query. Postgres has a hook mechanism that allows an extension
to override the default executor. This implementation is very simple: the extension records the current energy reading when a query starts
and then calls the actual executor that runs the query. When the…

TIL: Read sysfs without root access in Linux

Typically an user needs root access to be able to read sysfs data. But such root access might not be possible
in all case; an example being Postgres which cannot be run as root. I recently learned that it is possible
to set an extra capability to executables
such that it can read sysfs while not being root. 
 I wrote a simple C program to read a specific sysfs entry 
 #include…

Mapping Between Pgbouncer and Postgres Connection States

Pgbouncer is a popular connection pooler for Postgres. Connections from the end user to pgbouncer
are called client connections from it’s point of view. Connections from pgbouncer to Postgres are
called server connections. In a typical deployment, end users
connect to pgbouncer, which maintains a pool of persistent server connections. The pooler assigns
a server connection to…

TIL: Getting the current capacity of a named pipe in Linux

A named pipe (also known as FIFO) is a IPC channel, it allows one process to write and another to read. Like all things
in Linux, it is implemented as a file like entity using either mkfifo or pipe system calls. 
 Pipes on Linux have a limited size, typically set to 65536 bytes on modern systems. I recently came across a situation where I needed to know the current remaining capacity of a…

Measuring energy usage of a function

I recently needed a way to measure how much energy a piece of code consumes. This is easy to do in Linux using the perf utility assuming the underlying kernel has been built with appropriate flags. This looks something like this 
 $ sudo perf stat -a -e power/energy-pkg/ ls -la /usr
 total 116 
 drwxr-xr-x 14 root root 4096 Mar 28 02:08 .
 drwxr-xr-x 19 root root 4096 Apr 16 16:02…