Notes of a Traveling Cat, Continued

Notes of a Traveling Cat · Habr, Aug 3, 20237 min

Greetings, Habr folks. For a long time I worked in software development for access control systems, harbor protection and hydroacoustics, used at various faraway and not-so-faraway sites across our boundless motherland. Some of these systems had to be brought up in the tundra, the taiga and beyond the Arctic Circle. Over my almost 20-year career, and more than 10 years of "go-progrum-it-already" on such systems, I've lived through all sorts of moments, some of which I'd like to share with you. The traveling cat's previous adventures can be read here. Don't judge too harshly, I write this for the love of it...

traveling cats are a bit much

Note five, or Ghost in the Shell

This one is related to note four, in short, the harbor security system had been running for about half a year and the people with shoulder boards decided to extend it to other sections. Nothing particularly interesting happened, we came, installed, set up and connected it, went home, and then a flood of requests begins, saying everything “doesn't work, it's all gone kaput, doesn't work at all, in a word”. And we had been there only two days earlier and handed everything over under seal so the sailors wouldn't poke around anywhere. Since the system was standalone and you could only connect to it locally, debugging went on over the phone and through photos of the screen, and the gist of the problem was that the equipment (read: small Linux PCs) stopped working properly and shut down 20–30 seconds after you connected to it. The whole complex was a grid of small PCs that received data from the controller, did something with it and sent it back. It was all designed so that the system wouldn't keel over under load when scaled up, and so that processing units could be hot-swapped into the rack, and simply for redundancy too, of course. So with this kind of remote debugging and a 5–10 second lag, we debug the system, and it's all exactly as the operator says, the system is wildly sluggish, one cycle of sweeping the water area and analyzing the data takes 15–20 seconds instead of the required 2, or even more, which naturally doesn't add to our karma, only to our gray hairs. Unable to come up with anything that could even roughly fix the situation, we start connecting the “remote debugger” to various processing units and looking at the logs, we connect, put the log on the screen — and look.

my buddy and I looking at the logs

After 20–30 seconds the unit drops the ssh connection for no apparent reason, we have no ideas, keep staring blankly at the logs and smoking in the smoking room, mentally packing for a business trip. Until at some point one of the colleagues notices that the log from one and the same unit had changed between sessions. Picture this, you open a text file with the word “happiness” in it, you blink and you still see that word, only now it's spelled with the letters “a, s” and “s”. Don't believe it? Neither did I, you can't make happiness out of those letters. Vague suspicions about what's going on begin to stir, we call the IT department and ask them to tell us why they'd been poking around in the system, we just said it at random to put the fear of God into them, and it turned out we'd hit the bull's-eye. The reason turned out to be one of those simple-minded things that, as the saying goes, are worse than theft — there was some money left on the project's budget that couldn't be written off anywhere else. The higher-ups, without thinking twice, ordered the IT department to throw new processing units into the rack, as many as would fit. Roughly half the total number fit in, but they decided not to order them from us and took PCs of similar form factor and power, well, you understand, because they were cheaper and available right now, whereas we'd only deliver in half a year and for money, and the remaining sum was better written off to zero so they'd get more next time. The IT department didn't think either, ran dd on the working units' disks and copied the resulting Frankenstein onto the new units. Whatever the network engineer's dd could reach, it copied, and wherever it would deploy, it deployed. His task was simple after all — get as much equipment up as possible. The result was a configuration with absolute copies of the existing units, which drove the controller crazy, now receiving data, now not, every so often self-diagnostics would kick in and, finding two identical ids on the network, send one of them a power-off request. And that would have been the end of it, but a smart UPS (some super-fancy Dell rackmount for its time), seeing that one of the computers had shut down, would turn it back on. As a result the system kept rebooting half the units, the other half took on the extra load, processing time drifted catastrophically, and “doesn't work, it's all gone kaput, doesn't work at all, in a word”. The most galling part is that we ourselves had actively “sold” this feature to the customer, hoping he'd later order new units for redundancy and we'd get a bonus. Some salesmen we were, dammit.

Note six, or Ivan Ivanych the poltergeist

The early twenty-tens, I'm working on a “smart” CCTV system for project “C”, a rescue vessel for raising sunken submarines and ships from great depths, a project that a big Petersburg navigation systems developer had back then. We're preparing a demonstration for the top brass — the setting, the equipment, power wiring on the mock-up, everything just like on a real ship. The video surveillance cables are run into a vandal-proof box that's impossible to open, except maybe with an axe, but where would programmers get an axe? And the keys to the holy of holies, the camera controller from a well-known American company with an AI function for tracking and recognizing anyone and anything that gets into the cameras' field of view, which cost some insane amount of money, were held only by the lead and the chief project engineer. A week before the show, the whole camera loop fails, not individual cameras or segments, the entire video surveillance simply goes down.

roughly how it all looked

Having crawled through all the known nooks where something could have failed, we come to our vandal-proof box, which is intact, with no visible damage on the outside. But the picture that opens up inside is, to put it mildly, depressing. The power cables to the super-duper black box are gone, and the connectors themselves look like they'd been “gnawed with teeth”. Quietly and peacefully we replace everything without raising the alarm, the handover's in a week, they simply won't understand us otherwise. Who would need cheap-as-dirt wires when there were much pricier devices in the box? A rhetorical question. We started it up, checked it, and wait for the trials to begin. Think that was the end of it? Ha.. two days later the system is dead again, and the lead and I race each other on the wings of terror to our vandal-proof box. Here we go again — the cables ripped out, the power connectors gnawed even worse. Miracles, “in a word”, only for some reason the lead isn't laughing. Two days before the handover, a tent is literally pitched next to the box, supposedly for debugging, with a laptop and a programmer inside and orders to launch doom every half hour to scare off demons and assorted poltergeists with the sound of railgun fire. And you know... it helped. Meanwhile we begged for a separate camera to watch the box around the clock, and started thinking about duplicating the box itself, hardware and all. Just in case, you know. We passed the trials successfully, and the glare of gold shoulder boards and stars on admirals' caps was so bright you could have worn sunglasses indoors. Three days after the handover and the removal of the watch post, the cables in the box were gone again. And a week later I moved on to another project, with more perks and more interesting tasks.

more perks, fewer tasks

Note seven, or the singing tug

Another business trip beyond the Arctic Circle, we're installing hydroacoustics to catch everything sneaky underwater, somewhere near the glorious town of “V‑--vo”. To help with the deployment and with hauling reflectors, divers and an endless stream of sea yarns, we were assigned a tug with a crew, let's call it the “Singing”. The crew was known for liking to “sing” at sea. And they liked doing it fairly often, for which the tug was known behind its back by a less melodious name, the “Swigging”, which took swapping only a couple of letters. But there weren't many tugs, one or another was always laid up for repairs, so the brass turned a blind eye to the crew's singing. Besides, the crew certainly did its job no worse than their colleagues on tugs who had no habit of brazen singing. The equipment deployment went off successfully, the commissioning team goes ashore, and the tug waits for the command to start moving around for the tuning. We're already getting ready to ask for the divers to go in, when the base orders the tug to come back on urgent business. The tug, which had been standing idle in one spot for a while, does a U-turn on afterburner and flies off toward the base.

Turns out tugs have afterburners too

And on shore, in the little hut that was later supposed to become the observation post, something subtly changes. The hut starts to tremble slightly, and then the table with the workstation accelerates into the wall, and the acceleration fell just a little short of sending that very wall on a voyage after the ship. The whole team stares in bewilderment at the suddenly animated table, and only the sad eyes of the chief engineer, glued to the window, follow the armored cable running from the antenna to the equipment. Merrily glinting with its wet armor in the autumn sun, it snakes into the sea and disappears into the depths. Some kind soul on the tug had forgotten to cast off the ends of the line used to lower the antenna and sent it on its final journey, i.e., dragged it off toward the base. What's half a ton of iron to that tug, when it tows nuclear subs into base. We did find the antenna later, of course, and washed it off, but it was never quite the same again. The station was handed over half a year later with a new cable, and two kilometers of the old one still rest somewhere on the bottom, having become a home for a great many crustaceans and mollusks.

Note eight, or a horsey name

The capital's “Nail”, quantity one

We're putting an access control system into trial operation at the capital's “Nail”, and after it's connected to the citywide database of civil servants, various small errors start flying in, which get promptly fixed, mostly with scripts. Everything seems fine, and then, like a bolt from the blue, the system takes a dislike to one minister, now it locks him out of his office, now it won't let him into the restroom, now it wipes the points off his meal card, and this happens exclusively after the sync with the city database and the late-evening change of passwords and secret rendezvous points, so the minister has new adventures every morning. A rare day went by without an email to support from this user and a call-out for a fix, we even wanted to give him an all-access card, only the security policy didn't allow it. Of course the minister doesn't like this, it causes frustration and lowers his productivity, which makes things bad not only for him but also for the company director, who had already gotten a couple of calls on his cell from stern people asking him to fix it. We try to sort out the problem on site, but as soon as any action is taken with this character's data, we merely open the page with his data, the error disappears. A heisenbug, elusive and stern. After that the minister walks around happy, until the next morning. Having spent a couple of days debugging, during which we had to bring in the neighboring contractors and beg them for temporary access to the city DB, we find out the following, after the shared DB version was updated, a checksum field of type int64 appeared at the end of every record, the contractors had happily forgotten to tell us about this little update, and specifically for this character the checksum of his first name and surname data added up to a special character (a non-printable utf-8 one), which our system took as the control character marking the start of bytecode for the internal scripting virtual machine. And so the sync, besides updating the data, rewrote the bytecode of that particular person's scripts, which somehow got executed here and there, causing strange behavior in random places. Opening the minister's page in our system, on the other hand, launched checks that saw the checksum mismatch and rolled back the bytecode. The problem was compounded by the fact that the system had been handed over turnkey, on a disc, there were no over-the-air updates, and in general updates back then happened once a month at best, under the strict supervision of the entire IT department and a couple of guys with assault rifles. So every morning for a month we had to open the page in the management system and... close it.

Have a great weekend, everyone, and fewer bugs.

All notes