Technical notes from Linux and FreeBSD infrastructure work
Practical guides, troubleshooting notes, and operational references from production infrastructure work with Linux, FreeBSD, networking, web servers, databases, backups, monitoring, and security.
Practical notes from A-Team Systems' work with Linux, FreeBSD, networking, web servers, databases, backups, performance, monitoring, and production infrastructure operations.
Latest Technical Articles
SQLSTATE[HY000] [2002] Connection timed out: FreeBSD PF, CARP, and Intermittent MySQL TCP Failures
SQLSTATE[HY000] [2002] Connection timed out
A-Team Systems investigated a production issue where a PHP application intermittently reported this MySQL connection error:
Unfortunately, this error can mean a lot of different things. You can get it when the database engine is down, when a firewall rule is wrong, when routing is broken, when a cable or switch path is having trouble, or when something in the middle simply does not return the TCP handshake.
Most people who land on this article will probably have a simpler cause than the one described here. That is worth saying up front. This case was unusual because almost everything was working, including almost all of the MySQL connections.
The application was making a very large number of database connections, and only about 1 in every 10,000 new TCP connections failed.
Everything else looked healthy; other application traffic was working, most MySQL traffic was working, and the database was not globally unavailable. The database endpoint path was not showing obvious signs of CPU, memory, swap, or listen-backlog exhaustion.
The environment: FreeBSD PF, CARP, and a high-churn MySQL path
The production path looked roughly like this:
In this case, there was a SQL proxy layer in the database path, and we suspected it for a while. That was a reasonable suspicion. Bypassing that layer stopped the visible application errors.
But the proxy software was not the problem. The same kind of issue could have shown up on a direct-to-database path with enough short-lived connections and the same firewall behavior in the middle.
The pieces that mattered were:
That told us the path mattered. It did not prove the service at the end of the path was failing.
Why the error was misleading
The application error was a MySQL connection timeout:
This was not the same as a slow query, an authentication failure, or a connection that was established and then dropped later.
The failing requests were not getting far enough for the MySQL protocol to matter. They were failing at TCP connect time.
In other words, this was a TCP connect timeout, not a MySQL query problem. So the useful question became very basic:
Did the TCP handshake complete?
- FreeBSD
- PF
- CARP
- MySQL
- TCP
- firewall state
- production debugging
Using tcpdump and Wireshark: Linux and FreeBSD Network Capture and Analysis Guide
Capture network traffic on a headless Linux or FreeBSD server with tcpdump, save it as a pcap file, and review the results locally in Wireshark.
- Linux
- FreeBSD
- Networking
- Troubleshooting
- Security
GitLab Project Access Token “You are not allowed to download code from this project.”
We ran into an issue where a GitLab Project Access Token would not work when trying to clone a repository it had permission to access.
- GitLab
- access tokens
- source control
Understanding NginX’s sendfile Parameter and Its Implications with NFS
In the world of web servers, NginX has emerged as a robust, high-performance option, powering some of the most trafficked sites on the internet. It’s...
- FreeBSD
- Linux
- NFS
- NginX
- Performance
- sendfile
- Web Server
ZFS failed to read pad2 area of primary vdev
There are number of issues that can lead to this error when trying to boot a FreeBSD server with ZFS as root / zroot: ZFS failed to read pad2 area of...
- FreeBSD
- partitioning
- systems administration
- ZFS
- ZFS Boot
- zroot
All Tech Blog Articles
Page 1 of 6, ordered newest to oldest.
SQLSTATE[HY000] [2002] Connection timed out: FreeBSD PF, CARP, and Intermittent MySQL TCP Failures
A-Team Systems investigated rare MySQL SQLSTATE[HY000] [2002] connection timeouts where about 1 in 10,000 TCP connections failed while most traffic kept working.
- FreeBSD
- PF
- CARP
- MySQL
- TCP
- firewall state
- production debugging
Using tcpdump and Wireshark: Linux and FreeBSD Network Capture and Analysis Guide
Capture network traffic on a headless Linux or FreeBSD server with tcpdump, save it as a pcap file, and review the results locally in Wireshark.
- Linux
- FreeBSD
- Networking
- Troubleshooting
- Security
GitLab Project Access Token “You are not allowed to download code from this project.”
We ran into an issue where a GitLab Project Access Token would not work when trying to clone a repository it had permission to access.
- GitLab
- access tokens
- source control
Understanding NginX’s sendfile Parameter and Its Implications with NFS
In the world of web servers, NginX has emerged as a robust, high-performance option, powering some of the most trafficked sites on the internet. It’s...
- FreeBSD
- Linux
- NFS
- NginX
- Performance
- sendfile
- Web Server
ZFS failed to read pad2 area of primary vdev
There are number of issues that can lead to this error when trying to boot a FreeBSD server with ZFS as root / zroot: ZFS failed to read pad2 area of...
- FreeBSD
- partitioning
- systems administration
- ZFS
- ZFS Boot
- zroot
FreeBSD OS Update Mirroring (freebsd-update)
Currently there is unfortunately no official way to mirror the OS updates that the freebsd-update downloads, however we have just open sourced our tool...
- FreeBSD
- freebsd-update
- maintenance
- systems administration
Zabbix Ubuntu: zabbix-agent : Depends: libssl1.1 (>= 1.1.1) but 1.1.0g-2ubuntu4 is to be installed
If you have tried to install the Zabbix agent on an Ubuntu server and hit a libssl dependency error, start by checking repository alignment.
- Linux
- monitoring
- Ubuntu
- Zabbix
What is CPU Steal Time Under Linux, How To Measure it, And How To Keep Your Cloud Provider Honest!
What is CPU Steal Time? In Linux, CPU steal time refers to the amount of time a virtual CPU waits for a real CPU while the hypervisor is servicing another...
- Linux
- monitoring
- Performance
SQL Database Usage and Transaction Essentials for Programmers
SQL Database Usage and Transaction Essentials for Programmers This is a quick article designed to be an introduction to some of the basics of using a...
- MySQL
- SQL
- Web Dev
How to Find NginX Version
How to Find NginX Version In 2 Quick Steps Finding your NginX version is a simple process that can be completed in just a couple of steps. We’ve...
- NginX
- UNIX
- Web Server
MariaDB vs MySQL: Which Relational Database Should You Use?
MariaDB vs MySQL: Which Relational Database Should You Use? MariaDB and MySQL are both popular relational databases, and they are both similar in how they...
- MariaDB
- MySQL
- systems administration
- UNIX
What is Redis and Why You Should Use It
What is Redis and Why You Should Use It If you’re new to Redis, you may be wondering what exactly it is and who should use it. So, we spent some time...
- database
- Redis
- systems administration
- UNIX
Need help with production Linux or FreeBSD infrastructure?
A-Team Systems provides engineer-led infrastructure management and support for organizations that rely on stable production systems.
Contact A-Team Systems