32 ms·
The day I locked everyone out of the company intranet
- l0ngyap 3y ago[dead]
- freetanga 3y agoAlways do a select with your criteria before doing a Delete or update. Don’t ask me how I learned this.
- tgv 3y agoThen start a transaction, and only commit when the row numbers match.
- mjcohen 3y agoSame thing on a Unix/Linux level: When using find, I always do it first with -print until I see the files I want. Only then do I add the actual action I want.
- lemper 3y agohow did you learn it?
- gumballindie 3y agoCame here to say exactly that! I do a select count and then a limit against the returned count. At least it may reduce the blast radius.
- menacingly 3y agoIn most of my scenarios, I'd actually rather cause a catastrophic global change than a silent subtle corruption of a handful of rows
- gumballindie 3y agoThat may be fun in a trivial setup such as op’s but when millions of customers or billions of transactions are affected it’s a nightmare. A competent engineer runs queries against a local and then a uat db, verifies results and then on prod. But if you must do it in prod then it must be limited in scope.
- menacingly 3y agoWe're on the same page with the best approach, I just don't consider corrupting an unpredictable subset of my database much of an improvement. It's not closer to correct, it's just still incorrect.
- sgarland 3y agoThis can also bite you if your dataset is larger than the buffer pool (or whatever other RDBMS calls it), and the particular table you’re querying isn’t commonly accessed. Turns out when you start loading millions of rows of useless data into memory, the useful data has to get kicked out, and that makes query latency skyrocket.
- jojobas 3y ago>Don’t ask me how I learned this. Joke's on you, we all learned it this exact way.
- seanthemon 3y agoThis gives my heart pains I can't explain to my therapist..
- maccard 3y agoLuckily I learned from someone else. I did figure out start with a transaction the hard way though
- fernandotakai 3y agoi can still feel the pain in the pit of my stomach when i saw the amount of rows affected. thankfully my boss at the time was a amazing db admin and he helped me fixing my mistake.
- chrisandchris 3y agoThat, and some DB tools (line JetBrains DataGrip) block UPDATEs and DELETEs without a WHERE condition.
- _nalply 3y agoOnce I wanted to do `rm -fr *~` to delete backup files, but the `~` key didn't register... Now I have learnt to instinctively stop before doing anything destructive and double-check and double-check again! This also applies to SQL `DELETE` and `UPDATE`! I know that `-r` was not neccessary but hey that was a biiiig mistake of mine!
- laurensr 3y agoYou remind me of that time I wanted to `rm -rf ./*` but the dot hadn't registered... I now avoid that statement.
- _shantaram 3y agoOne time I was debugging the path resolver in a static site generator I was writing. I generated a site ~/foo, thinking it would do /home/shantaram/foo, but instead it made a dir '~' in the current directory. I did `rm -rf ~` without thinking. Command took super long, wondered what was going on, ctrl-c'd in horror... that was fun.
- xp84 3y agoI’m really curious: without cheating by using the GUI, what would be the proper way to delete such an obnoxiously-named directory? Would “$PWD/~” work?
- r3jjs 3y agoA few ways. rm ./~ is likely the easiest. Another option, shell dependent, would be to turn off shell globbing. The `GNU` version of `find` has a `-maxdepth` option so find . -iname '~' -maxdepth 1 -exec rm {} \; would work, but I don't like relying on `GNU` extensions.
- hddqsb 3y agoOr just: rm "~"
- 3y ago
- iJesus 3y agoGone are the days of hard deletes in my approach; it's exclusively soft deletes now!
- justinclift 3y agoAt a previous place I worked, if they were working on the cli (eg in psql or similar) they'd always use these two steps, either of which would provide adequate protection: 1. Start a transaction before even thinking of writing the delete/update/etc (BEGIN; ...) 2. Always write the WHERE query out first, THEN go back to the start of the line and fill out the DELETE/UPDATE/etc. It worked well, and it's a habit I've since tried to keep on doing myself as well.
- drsim 3y agoI wrap all of my production manipulations in a transaction, and commit only if the results are expected. Yes, it may take locks that block customer-facing transactions, so I have selects ready to go in the transaction to minimise this. 15 years and counting since wiping out a large production table and taking a day to restore from backup.
- quijoteuniv 3y agoUse chatGPT to double check too.
- throwbadubadu 3y ago"Yes, you can delete those items via that query." "But now all has been deleted??!?! WTF HEEELP" "I apologize for my previous answer, you are correct, you now deleted everything!"
- archerx 3y agoThank you for the laugh, I can imagine someone running untested chatGPT code on prod and this actually happening.
- quijoteuniv 3y agoMmm… you can ask to explain what the query will do… yes you can mess thing up if you do not understand, therefore you try to understand. There is a lot to learn, i did not recommend running code in production frOm chatGPT, funny with downvoting
- Nextgrid 3y agoIn the top bar of the site: > Sorry! Subscriptions were broken last week, but are now working. If you tried to subscribe and ran into issues, please try again! I wonder if a similar incident involving a “UPDATE subscriptions” query happened recently.
- dfcowell 3y agoHa, no, that was a far more mundane issue. The CMS I'm using requires double opt-in to subscribe, meaning you need to enter your email address and click the confirmation link. It also apparently requires double email configuration, meaning it has two places where you can configure your mailer. I had only set it up in one place, meaning the confirmations never got sent. Bit of a facepalm moment.
- headline 3y agoI've just started my career - I wonder what my first fuck-up will be :)
- jdsalaro 3y agoDon't wonder! Plan it and execute it so you can be more chill !! /s
- james-skemp 3y agoOwn up to it when it happens. Can only get worse if you don't. Hopefully you work with people that follow that as well. I can still remember a more senior coworker copying a directory from a network share (Ctrl + C), deleting the directory, and then trying to paste it somewhere else. I didn't speak up (he also rarely touched the mouse so flew through it), so we both got a chuckle when he realized his mistake and pinged network folks for a backup from tape. It happens. The real world is messy. Can always learn something new. Can always do something you know not to do.
- fukawi2 3y agoI was working on an old old old "ERP" system written in D3 PICK. It's a database, programming language and OS all in one with roots in tracking military helicopter parts in the 1960's. I was working on it in the mid-2000s. It had SQL like syntax for manipulating data, but it was interactive. So you would SELECT the rows from the table that you wanted, then those rows would be part of your state. You would then do UPDATE or DELETE without any kind of WHERE, because the state had your filter from the previous SELECT. It has a fun quirk though - if your SELECT matched no rows, the state would be empty. So SELECT foo WHERE 1=2 would select nothing. UPDATE and DELETE are perfectly valid actions even without a state... Working late one night, I ran a SELECT STKM WHERE something that matched nothing, then before I realised I realised my state had no rows matched, I followed up with DELETE STKM. Yep, the entire Stock Movements table four the last 20+ years of business were gone. The nightly backup had not run, and I didn't want to lose an entire day of processing to roll back to the previous night. I spent the entire night writing a program to recreate that data based on invoices, purchase orders, stocktake data, etc. I was able to recreate every record and got home about 9am. Lots of lessons learnt that night.
- albert_e 3y agoYou recreated a production database of 20 years data by hand overnight? You deserve an award !!!
- testemailfordg2 3y agoOnly that day's data was added on top of backup from last night...
- unnouinceput 3y agohe only recreated the ones not saved by the nightly backup, meaning he used the previous nightly backup and recreated from invoices the last ~23 hours.
- fukawi2 3y agoNo, I did the entire table. That helped me find corner cases and errors in my logic having such a bigger range of source data.
- stuaxo 3y agoMy manager had got me to look at backups.. but for cheap. I decided on bacula - I had the clients installed on all the computers in the office, and it worked for some small tests. My manager decided we would try this with a USB drive attached to one of the servers (somehow this didn't seem like a bad idea). In the morning, very uncaffinated he sent me to the other site - an unmanned basement office with the servers. Being uncaffinated I forgot the door password and set off the alarm. I had to go into the office and phone him with the alarm going to get the code to turn the alarm off. OK, that was stressful but sorted out at least. I plugged in the hard drive to the selected server and headed back. Once I got back it turned out all the websites on that server had gone down - trying to send all the backups to this poor USB harddrive had overwhelmed the IO on that-era Linux server and the poor thing just froze. Fairly soon after I was let go, and joined my friends at a much more fun company making mobile games.
- sacnoradhq 3y agoIt's the responsibility of the technical person to uphold engineering ethics, especially in the face of potentially inadequate recovery and security solutions. I was once let go from a big name university for refusing to weaken and rush changes to a payment processing network (PCI-DSS) when there was "no time" to review them in detail. That's a future FBI press conference sort of thing when it all comes crashing down. Not long after, all SS#s, DOBs, and deets for every employee was stolen from a "rogue" laptop taken by a consultant, likely to be sold on carder and identity theft forums because of an utter failure at data protection processes. That place was a shitshow because they didn't have the professional ethics or leadership backbone to do what was prudent and necessary.
- kubanczyk 3y agoYeah, for a surprisingly long time, linux had a big write cache problem. You were okay if you used all fast-writing devices. You were okay if you used all slow-writing devices. But if you mixed them, the slow writes could totally fill the write cache and starve everything else. Not only an USB (1?) could cause it but also a cifs transfer over a 100 Mbps link.
- matsemann 3y agoI wish a DELETE or UPDATE only affected a single row by default (and perhaps even wouldn't commit if it would hit multiple rows), unless a keyword for MANY or something similar was added. Aka DELETE ALL where x == y or DELETE MANY where x == y or perhaps you need an explicit limit for it to not be 1, so DELETE where x == y LIMIT ALL
- sangriafria 3y agoThere are some SQL GUIs that require confirmation before running an update/delete query without a where clause
- sgarland 3y agoFor the MySQL CLI, you can start it with —-i-am-a-dummy to get this behavior. Or —-safe-updates if you’d rather, but the former is more fun.
- somat 3y agoThe way a DELETE without a WHERE clause gets the whole table makes sense conceptually but it always gives me the creepy crawlies when typing the statement. While I normally dislike superfluous syntax I would welcome changing the sql grammar to enforce a where clause on delete, that is, to delete all rows in a table would require "delete from table where true;"
- nonameiguess 3y agoEarly on when I'd first started making the transition from pure developer role working only on product to a platform role running the development environment, I was encountering problems with build scripts on CI servers leaving behind a bunch of dead symlinks. Tired of tracking them down manually, I wrote a nice script that automatically found all dead symlinks and deleted them. It turned out, for some arcane reason I still don't understand, our production instance of Artifactory was running on top of Docker Compose with host path volume mounts, and somehow, symlinks that were not valid from the perspective of the host actually were valid from inside the container, and doing this on all of our servers broke Artifactory. For some even stupider reason, we weren't doing full filesystem-level snapshots at any regular interval (which we started doing after this), so instead I needed to enlist the help of the classic wizard ninja guy who had been acting as a mostly unsupervised one-man team for the past six years who had hacked all of this mess together, documented none of it, and was the only person on the planet who knew how to reconstruct everything. This was probably still only the second-stupidest full on-prem lab outage I remember, behind the time the whole network stopped working and the only person who had been around long enough remembered they had trialed a temporary demo hardware firewall years earlier, management abandoned the evaluation effort, and it somehow remained there as the production firewall for years without ever being updated before finally breaking.
- cesaref 3y agoBack in the 90s I remember a work colleague asking 'can you rollback a drop table?', to which I replied 'no', and all the blood drained from his face in seconds. It's one of those things you've heard happens to people, but until you see it, you can't quite believe it.
- jdsalaro 3y ago> can you rollback a drop table >_< , something similar happened to me when I did an rm -Rf * in the old pictures directory on my system ... Well ... It wasn't the old pictures directory, it was the backup directory with all pictures from my older phone !! To say that blood drained from my face would be an understatement, thankfully I was able to recover most of it. The first thing I did after the recovery marathon was to alias rm so that it instead works by moving stuff to /tmp
- eCa 3y agoIn the late 90’s I wanted to try this Linux thing, so I followed a tutorial. First step: fdisk Yes, that was my Windows partition going bye-bye.
- CoastalCoder 3y agoSo... success? ;)
- deleted 3y ago[deleted]
- 3y ago
- alexmolas 3y agoThe other learning I get from this story is "never hide your errors" or "own your errors as you own your victories". If the author had decided to say nothing the problem would have been bigger - an unhappy boss and probably fired.
- user6723 3y agoThese kinds of scenarios happen when money is "cheap", and highlight why the current recession, and coming 2nd great depression aren't really a bad thing.
- CoastalCoder 3y agoI think you'll need to flesh out your logic if you want to convince people that a depression is somehow a net positive.
- dfcowell 3y agoThis was 13 years ago in a small business with no significant investment. No “cheap money” was involved, just the realities of a small business with chronic NIH syndrome.
- rsynnott 3y ago... Okay, I've seen people blame monetary policy for a lot of things, but I'm really struggling to see how this one works.
- TheGigaChad 3y ago[dead]
- FreshStart 3y ago5. Deadlines do more damage than good, but the costs they produce get swiped under the rug by company internal accounting.
- nytesky 3y agoFor some reason your title made me think of this classic IT Crowd https://youtu.be/Vywf48Dhyns https://youtu.be/Vywf48Dhyns
- makach 3y agoA charming story which almost everyone can relate to! Only one of your rules will ever save you. “Don't run updates directly in the database console”. Whole methodologies are crafted around this rule/principle to not do development in production environment.
- lormayna 3y agoI did something worst many years ago: I was working for a regional ISP and during a major incident, I had to reroute traffic through a different path. Under big pressure, I did the infamous Cisco mistake "switchport trunk allowed vlan 50" instead that "switchport trunk allowed add vlan 50" and I locked out myself and all the customer from our broadband customers. We had to call a DC technician and ask him to share a console through a local console server. Lesson learned: even if you are under big pressure take your time to plan and review the modification 15 minutes can save hours.
- _cenw 3y agoI did worse. We had a redis with sessions. Early on, someone decided every write to redis should also cause a write to S3 as backup. My first task was to get rid of this 4-digits a month extra cost in PUT requests. I decided to instead write all changed session objects into a set keyed by half-hour timestamps and then write only those sessions every 30 minutes. Unfortunately initially I used a KEYS to find the set corresponding to my half-hour stamp, not having read up exactly on what it does. It's not exactly advisable to do on a redis with a million or so objects. A later version of the archiver wrote the last emptied set to a stable key instead and then checked the set keys between then and now instead...
- mootzville 3y agoI was taught to: 1. Write your WHERE clause first 2. Return to the beginning of the line to finish writing the statement 3. Check your statement 4. If it looks good, then -- and only then -- add your closing semicolon Having said that, once during my second week at a new company, I plugged in an ethernet cable to an APC UPS, so I could set up networking on it. It shut down production. Why? APC makes (for that model at least) proprietary ethernet cables for networking, and if you plug in a regular cable it does an autoshutdown...an engineers attempt at marketing perhaps!? I did RTFM before, and after out of confusion, and there was no mention of this.
- sokoloff 3y agoI will typically do something like this when writing SQL in an interactive tool: SELECT * from table WHERE id = 12345 and once that's giving me the selection I want, insert the update statement into the middle: SELECT * from table -- UPDATE table set c1 = v1, c2 = v2 WHERE id = 12345 Then, accidentally running the entire buffer doesn't do anything destructive, but selecting the query from update to the end of the statement lets me do the update. (It's still imperfect, because selecting only the update line will still be destructive.) (Most of the RDBMS tools that I've used would happily ignore the lack of a closing semi-colon and that will not save you for a single-statement case.)
- mootzville 3y agoTrue, thought I didn't include the lookup first, it is how it happens in practice. Also, we use the mysql client, so semicolon is a must, and I would avoid anything that let you submit the statement without it...that's your safety net.
- Gordonjcp 3y agoI had a thing recently where someone was updating some entries on a system I look after, decided the changes hadn't applied properly, and clicked "Roll back" to put it back to its original state. Whatever had gotten into it, it rolled back to 2009. It rolled everything back, including user accounts. No-one who worked there in 2009 still worked there, so no-one had a valid password any more. Fortunately it was easy enough to copy the last-but-one backup over the top and lose the day before's config updates, and cure its Flowers for Algernon state, but it was a pretty hairy afternoon.
- croo 3y agoMy chooosen database explorer is Dbeaver. Horrible name but great app. You can set colours for local/test/prod servers and a red colored tab will scream at you to be cautious. And with red color every edit will pop up an "are you sure?" question. And autocommit is off. I sorta stopped making unrecoverable mistakes.
- acomjean 3y agoDBeaver is great. I came from a different tool, and had to get used to persisting the changes. I’m totally use to it. I run a local copy of the database I connect to remotely and I have to be careful about which database/table I’m connected too.
- reaperducer 3y agoMy chooosen database explorer is Dbeaver I just checked it out, and it looks promising. Con: There are too many licensing options. I'm not even sure which one I would need. Pro: They'll send out an invoice, like a real company. I work for a billion-dollar healthcare company, and if your company only takes PayPal, or Venmo, or something else that makes it look like two guys in a basement, it'll never get through our purchase approval process. Big companies do business with other big companies. Startups have to learn to interface with businesses on a business level if they ever want to grow out of being a startup.
- fbdab103 3y agoStart with the Community Edition and see where it takes you.
- loa_in_ 3y agoAs if two guys in a basement couldn't send out an invoice
- Lvl999Noob 3y agoThe parent isn't saying that they couldn't. They are saying that they shouldn't advertise their two-guy-ness in the financial parts of their company.
- justsomehnguy 3y agopfft rmdir . /s /q only to notice what I am in the wrong folder, way up in the hierarchy. And repeat the same error years later when the batch file failed to cd to the destination folder. Added if %CD% == %DESTDIR% to avoid that problem.
- theduder99 3y agolol thanks.
- philderbeast 3y ago"All of your colleagues have done something dumb. Don't be afraid to tell us when you make a mistake. We all remember our first screw up and will be happy to help." Never have truer words been spoken. As I tell all the new juniors at work doing sysadmin type tasks, everyone has deleted the production database at least once. Mistakes will always happen, it's how you deal with them that defines how good you are at the end of the day.
- russfink 3y agoIt’s also a measure of how well management does in response. We were transferring a software production repository from one machine to another, Lord knows why, when a junior admin I was supposed to supervise had arrived a half hour early and started the operation without me. He got the source and destination arguments reversed in the file transfer; we were using DD for this one part of it. Management reacted pretty well. They assured both of us that while we made the mistake, it was not our fault that data was lost: the problem was that backups were not being checked, which caused us to lose the resulting three days (120 developer days) of work. The manager in charge of the folks doing the backup got taken to task - but nobody else did.
- I_am_uncreative 3y agoI did something like this once my senior year of high school. I was using XCOPY to copy a copy of Counter Strike: Source that someone had placed on the U:/ drive, but reversed the order of arguments so that instead of copying it to my desktop, I copied everything on my desktop to the directory. For whatever reason, we had write access to that directory, but not deletion. I had to get the teacher to delete it for me.
- KronisLV 3y ago> Don't be afraid to tell us when you make a mistake. We all remember our first screw up and will be happy to help. This is very much dependent on the circumstances - sometimes people won't be supportive or encouraging, but cold at best and toxic (rude, making fun of mistakes, letting their egos run wild) at worst. This is more likely to happen in some work cultures/companies than others, and there can also be individuals that are allowed to persist with their problematic conduct in otherwise okay environments. If you are ever in such environments, acknowledge the fact, possibly push back against stuff like that and definitely be on the lookout for alternatives, where you'd be able to prosper. Thankfully, my personal experiences have mostly been okay, but I've definitely seen both attitudes and choices that can make everyone's lives worse, to the point where I wrote the satirical article "The Unethical Developer's Guide to Personal Success": https://blog.kronis.dev/articles/the-unethical-developers-guide-to-personal-success https://blog.kronis.dev/articles/the-unethical-developers-gu...
- IronWolve 3y agoMy first sysadmin job at a call center, the call center reps use the same directory for all the users. And, I'm working tickets to delete old users accounts... The old grey haired sysadmin backs up the directory so he can instantly restore it. Seems this happens all the time. Whew.
- limaoscarjuliet 3y agoWhen you really mess up a call center, it is called a gopher event - entire floor having lost their audio suddenly stands up in their cubicles and looks around. Been there, caused that.
- liampulles 3y agoI switched companies, and moving from a MySQL cli to pgadmin is a godsend. Would still like a confirmation dialogue, but having to click a button seems less error prone than pressing enter too quickly.
- rrrrrrrrrrrryan 3y agoA few months into my first job out of college, I brought down the main production server in the middle of the workday. It took us about an hour to recover. Afterward, I was very embarrassed and apologetic, but my boss just shrugged and said: "You're not a real technology worker until you've brought the company down. Welcome." Might not be the best words to live by, but it was exactly what I needed to hear at that time early in my career.
- ahazred8ta 3y agoFrequently heard in batcaves: "Hey, the FNG børked Prod." "One of us!! One of us!!" :-)
- m348e912 3y agoWe had this saying: "If you fix it before anyone realized it was broken, you didn't break it."
- throwaway3618 3y agoDepending on the situation it can be risky to start thinking like this, trying to fix stuff with lots of stress, in secret, maybe working around access restrictions, it's easy to make further mistakes
- Animats 3y agoIf you locked out everyone today, many would assume they had been laid off. Some of them would have other jobs before the login problem was fixed.
- simonblack 3y agoAh yes, the old lack of 'where' clause. Did much the same, but only on my own system (thankfully!) and yes, I had an up-to-date backup MySQL dump on hand.
- thombat 3y agoOne day my colleague was wondering whether RegEdit used some private API for renaming keys or just copied + deleted them. "Try a rename with a big tree, see if it's still instantaneous" I helpfully proposed. But what's a really big tree? How about System\Windows? The rename completed instantaneously - "told you it's a private API" I said happily, just as the machine crashed in twenty ways at once.
- alarge 3y agoRoughly 10 years ago, I was working for a startup that offered a live conversational video service where you could also have hundreds (or eventually, thousands) of near-live watchers - with recording and later playback. The founder pitched the service to news orgs and celebrities. Anderson Cooper had a regular "show" there for a while, and we had a number of interviews with mostly 2nd-tier celebrities. When the service started, they made the decision to not actually delete any content (delete just set a flag which disabled the content but didn't actually remove it). Fast forward a year or so, and it became clear that a real delete was needed. So they had a junior engineer write up a sort of delayed sweep - delete all the videos with the delete flag set. But then, for some reason, they decided put the implementation behind a delay. Something like "actually delete all soft-deleted videos, but don't start doing it until 30 days from now". However, unbeknownst to the team, there was a bug in the implementation that deleted everything, regardless of whether the 'delete' flag was set. So one night, roughly a month later, all the content started disappearing from the site. One guy heroically tried to stop the process, but I think he was too late. The engineering director happened to be on a vacation down in South America somewhere and I think the founder fired him in a fit of pique. I managed to reclaim a small bit of content (basically the videos that were cached on the actual recording servers before they were uploaded to S3). You can imagine the technical over-reaction: * Delete switched back to a soft delete * Turned on S3 object versioning * Started redundantly copying content onto a totally different hosting service This was fine (hah!) until we had to start taking down the inevitable child porn that always shows up on services like this - I got stuck with writing the takedown code and it took me forever to track down all the various tendrils of stuff. As you might expect, we lost a ton of users over mass content deletion and the service never really rebounded. The company held on for a couple more years, pivoting a couple of times, but eventually folded.
- iJohnDoe 3y agoFTA - Make friends with your sysadmin, and stay in their good books at all costs. I think this goes against every principle most on HN have.
- hahamaster 3y agoDecades ago my ex colleague was supposed to enter a command handwritten on a piece of paper saying "rm -rf /var/log/blah/" which she typed in as "rm -rf /var / log/blah / ". Everyone knows it's awesome to insert white space to increase legibility. It was a production database server.
- jorgesborges 3y agoThat’s an insane command to pass to an untrained person on a piece of paper to type into the terminal of a production server.
- hahamaster 3y agoAgreed. It was "only" supposed to truncate the log folder. ;-)