Live data from Hacker News

I Accidentally Deleted 7TB of Videos Before Going to Production

blog.thevinter.com

261–270 of 362 posts

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#262
post #244
post #4

> 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…

This is why I like to always write any sort of user-script batch-job tools (backfills, purges, scrapers) with a "porcelain and plumbing" approach: The first step generates a fully declarative manifest of files/uris/commands (usually just json) and the second step actually executes them. I've used a --dry-run flag to just output the manifest, but I just read some folks use a --live-run flag to enable , with dry-run be…

I tend towards a --dry-run flag for creative actions and --confirm for destructive actions. Probably sightly annoying that the commands end up seemingly different, but it sure beats accidentally nuking something important.

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#263

Aaaahhh, the feeling you get when you notice that you fucked up. Everything gets quiet, body motion stops, cheeks get hot, heart starts to beat and sinks really low, "fuck, fuck, fuck, fuck, fuck, fuck, fuck, fuck, fuck, fucking shit". Pause. Wait. Think. "Backups, what do I have, how hard will it be to recover? What is lost?". Later you get up and walk in circles, fingers rolling the beard, building the plan in the…

Pffft, it's not a real panic until you weigh the pros and cons of leaving the country with nothing but the clothes on your back and becoming a illegal immigrant shepherd in a nation with too many consonants in its name.

(Your description is so, so, spot on.)

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#264

This is one of those times that even if you don’t use a fully functional language, trying to make as much of your program logic pure functions would be helpful. It also makes it more testable. Instead of putting the delete call right in the loop, split it into four functions. function getAllVimeoVideos() function getAllDbVideos() function getVideosToDelete(vimeo_videos, db_videos) function deleteVideos(videos_to_dele…

Yes that's fun. a

    List getFoosToUpdate(List foos, List bars) 
function is the first time I thought about time complexity in my job.

Say Foo and Bar have fields in common, such that you can say a Foo object "equals" or "matches to" a Bar object, like if they have name and dateOfBirth fields or something else that are the same (nothing like a common ID between the two). Now say there are some other fields too, like amountSpentThisYearOnDogFood that you know is always accurate for Bars, but might be out of date for Foos. How do you get the list of all the Foos to update?

Initially I did the nested for loop solution that's like

   List getFoosToUpdate(List foos, List bars)
   {
    List returnList = new List();
    foreach (var foo in foos)
    {
     foreach (var bar in bars)
     {
      // check if "equal" or "matching" based on some criteria
      // if equal, update foo dog food expenditure with bar dog food expenditure, add to returnList, and break
     }
    }
    return returnList;
   }
but that's O(n^2) right.

The solution with a Dictionary is obviously better. All you need to ensure is that you have a method for both the Foo and Bar classes that will produce the equivalent hash for both, if they would be considered equal or matching by whatever criteria you are using.

So you could have something like

    int GetHashOfFoo(Foo foo)
    {
     string firstName = foo.FirstName;
     string lastName = foo.LastName;
     DateTime dob = foo.Dob;

     return (firstName, lastName, dob).GetHashCode(); // convenient c# method
    }

    int GetHashOfBar(Bar bar)
    {
     string firstName = bar.FirstName;
     string lastName = bar.LastName;
     DateTime dob = bar.Dob;

     return (firstName, lastName, dob).GetHashCode();
    }
These two functions will return the same value if those fields are the same. So then you can do something like

   List getFoosToUpdate(List foos, List bars)
   {
    List returnList = new List();
    Dictionary barsByHash = new Dictionary(bars.Count);

    foreach (var bar in bars)
    {
     int barHash = GetHashOfBar(bar);
     barsByHash[barHash] = bar;
    }

    foreach (var foo in foos)
    {
     int fooHash = GetHashOfFoo(foo);
     if (barsByHash.ContainsKey(fooHash) 
     {
      returnList.Add(foo.CopyWith(dogFoodExpenditure: barsByHash[fooHash].DogFoodExpenditure))
     }
    }
    
    return returnList;
   }
Which is faster cause you only have to go through the bars list once.

I actually messed up something like OP with this, but with doing undesired additions instead of undesired deletions.

You can think of it as having two endpoints, both expecting a .csv with rows being the things you were updating/changing/deleting.

The problem was, there was a column to indicate (with a character) whether the row was for an edit, or addition, or deletion, but this was only with one of these endpoints. For the other, there was only addition functionality, but I thought changes and deletions were also options for the other kind of .csv due to some unwise assumptions on my part (thinking that the other .csv would have the same options as the other). That's how we accidentally put in over 100 additions that should have been changes that had to be manually deleted. Luckily I had a list of all the mistaken additions.

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#266

"What does this teach us? Well, it teaches me to do more diverse tests when doing destructive operations. It also should probably teach something to Vimeo and to my contractor but I doubt it will (and yes, the upload for some reason is still manual to this day. Go figure!)" So you wrote bad code, didn't test it properly, ran it on production on the Friday before a release and are blaming Vimeo and [name redacted]? An…

(Since the OP redacted the company name from the post, I've done the same in your comment here. I hope that's ok.)

(We do this sort of thing to protect users, usually as the result of an emailed request, and you can tell when we've done it because of the word 'redacted' in square brackets.)

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#267

Earlier quoted context omitted.

Just to be fair also to some commenters, I think that the post had been edited after posting from what I remember ... so maybe the older comments are not very relevant.

To clarify, I only removed the company name and added the top disclaimer

[deleted]

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#268
post #70
post #66

Earlier 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.

That was our SOP for running DELETE SQL commands on production too, a script that generates a .sql that's run manually. It saved out asses a fair amount of times

At a previous job the DB admin mandated that everyone had to write queries that would create a temporary table containing a copy of all the rows that needed to be deleted. This data would be inspected to make sure that it was truly the correct data. Then the data would be deleted from the actual table by doing a delete that joined against the copied table. If for some reason it needed to be restored, the data could be restored from the copy.

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#269
post #189

Earlier quoted context omitted.

It still breaks the NDA: * Firstly, you don't have to name the company to break the NDA anyway (you are still disclosing information you aren't supposed to disclose regardless of if it can be linked back to the company). * Secondly, the client is still named on the front page of the website. * Thirdly, OP posted this with his real name that trivially links back to the dev shop he is working for. The site also has his…

Not all NDAs have the same terms. I could write up and serve an NDA right now that still counts as an NDA yet permits everything in your list.

All contracts vary in terms, but I've never seen an NDA that says "you can talk about the content under NDA as long as you don't mention the businesses name, and just identify who they are in a roundabout way instead".

"Well i'm under an NDA, so I can tell you all the specifics of the project, but I can't tell you the companies name. I can say they own the largest search engine though, and have a market cap of 1.5 trillion, and rhyme with "Roogle", but I really can't say who they are. Anyway, here is some code I wrote for them and a description of how we nearly ruined their project along with me calling them incompetent..."

Re: I Accidentally Deleted 7TB of Videos Before Going to Production

#270

Hey, everyone, ease up. I have: 1) dropped a production database because I thought it was the test database. 2) screwed up a print job costing $100,000 in today’s money and had to do it again 3) crashed all of Facebook with a C++ bug. 4) crashed Facebook photo uploads, with a JavaScript bug, in my first month. 5) literally killed a startup’s cash flow and caused them to lose their merchant account because I over focu…

You worked at Facebook, we get it
Post reply on HN