Earlier quoted context omitted.
Don't use a shell script.
Do you mean, always pass the list directly to the next script via function calls, without writing it to an intermediate file / pipeline?
I Accidentally Deleted 7TB of Videos Before Going to Production
291–300 of 362 posts
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#292I like these stories. I think they resonate well for 'the rest of us'. I've made plenty of mistakes like this - you learn and grow, right? One of the best things about HN is that so many incredible, talented people post. It's incredibly inspiring to raise your own game, to see what the best are doing. But sometimes it's equally important to realise we all fuck up, and for every unicorn dev there's another thousand of…
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#293Earlier quoted context omitted.
Another technique that I've used with good success is to write a script that dumps out bash commands to delete files individually. I can visually inspect the file, analyze it with other tools, etc and then when I'm happy it's correct just "bash file_full_of_rms.sh" and be confident that it did the right thing.
At the point you're doing this, you should be using a proper programming language with better defined string handling semantics though. In every place it comes up you'll have access to Python and can call the unlink command directly and much more safely - plus a debugging environment which you can actually step through if you're unsure.
You could always generate an intermediary set, inspect/test/etc, and then apply it with Python. I've done that too, works just as well. The important thing is to separate the planning step from the apply step.
* where "complicated" means more complicated than, for ex, `rm some_path.txt` or `DELETE FROM table WHERE id = 123`.
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#294We can all poke at this person for doing things incorrectly, but one has to wonder what mindset could lead to any programmer ever thinking that: 1) parsing a web page shouldn't be considered incredibly fraught with problems 2) that reloading web pages should be part of (1) 3) that this should ever possibly be run without validating the list of files that would be deleted So forget the specifics. Where are people lear…
You will do it at least once in your career. If you're old enough you will do it twice. If you're really old, you get the joy of doing it a third time.
The subtlety increases each time because you do learn.
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#295We can all poke at this person for doing things incorrectly, but one has to wonder what mindset could lead to any programmer ever thinking that: 1) parsing a web page shouldn't be considered incredibly fraught with problems 2) that reloading web pages should be part of (1) 3) that this should ever possibly be run without validating the list of files that would be deleted So forget the specifics. Where are people lear…
College? Parents? In my experience it runs pretty deep so not sure it can be easily trained out. This mindset is probably quite useful in evolutionary terms: rush at the attacking bear without thinking, for example.
Would that work? I don’t see a bear backing down and I don’t see the human winning either.
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#296Earlier quoted context omitted.
Once we get used to doing same thing multiple times a day, it doesn't matter if the log shows that we're about to take a destructive action, we'll still do it. Only thing that is foolproof is to not take the destructive action because people make mistake, it's human nature. I don't know how this can be implemented, may be encrypt the files, take a backup in some other location (which may not be allowed). Multiple rev…
While this is a huge issue, a solution (well, a partial mitigation) I've seen and used is the "Pointing and Calling" technique. The basic idea is that you incorporate more actions beyond reading and typing or pressing a button—generally by having people point at something and say aloud what it is they're doing and what they expect to happen. It's used rather extensively in safety-critical public transportation in Jap…
Also, I now realized that aviation checklists seem to tend to be done similarly with gestures - at least from what I saw on YouTube, not sure if that's representative or only used during education (?)
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#297Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#298Still things happen. Hopefully you have a large enough client base where some bad experience doesn't define the whole thing.
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#299Earlier quoted context omitted.
mv then rm is another idiom. So long as you have the space. For database entries, flag for deletion, then delete. In the files case, the move or rename also accomplishes the result of breaking any functionality which still relies on those file ... whilst you can still recover. Way back in the day I was doing filesystem surgery on a Linux system, shuffling partitions around. I meant to issue the 'rf -rm .' in a specif…
You mean cp then rm? And yes, copy, verify, delete. And make sure by the code structure that you either do the three on the same files, or their fail. Also, do it slowly, with just a bit of data on each iteration. That will make the verification step more reliable. Anyway, for a huge majority of cases, only having backups is enough already. Just make sure to test them.
Re: I Accidentally Deleted 7TB of Videos Before Going to Production
#300> but at the time the code seemed completely correct to me It always does. > Well, it teaches me to do more diverse tests when doing destructive operations. Or add some logging and do a dry run and check the results, literally simple prints statements: print("-----") print("Downloading videos ids from url: {url}") print(list of ids) ... ... ... # delete() dangerous action commented out until I'm sure it's right print…
Decide, then act.
There's a whole menagerie of failure modes that come from trying to make decisions and actions at the same time. This is but one of them.Another of my favorites is egregious use of caching, because traversing a DAG can result in the same decision being made four or five times, and the 'obvious' solution is to just add caches and/or promises to fix the problem.
As near as I can tell, this dates back to a time when accumulating two copies of data into memory was considered a faux pas, and so we try to stream the data and work with it at the same time. We don't live there anymore, and because we don't live there anymore we are expected to handle bigger problems, like DAGs instead of lists or trees. These incremental solutions only work with streams and sometimes trees. They don't work with graphs.
Critically, if the reason you're creating duplicate work is because you're subconsciously trying to conserve memory by acting while traversing, then adding caches completely sabotages that goal (and a number of others). If you build the plan first, then executing it is effectively dynamic programming. Or as you've pointed out, you can just not execute it at all.
Plus the testing burden is so drastically reduced that I get super-frustrated having to have this conversation with people over and over again.