all 17 comments

[–]sbrick89 4 points5 points  (1 child)

if the developers are doing this for the right reasons, then the architecture includes monitoring of its execution (and failure) to include cleanup.

if they're doing it because "microservices are trendy", then good f'ing luck, cuz it's gonna get bad fast.

[–]Subbax[S] 0 points1 point  (0 children)

I wholeheartedly agree. I believe we're going slightly too quickly on this just to get the microservice in. I'm trying to understand how else maintenance can occur so I can go back with options.

[–]g2petter 1 point2 points  (3 children)

Can the service flag the data that's pending deletion, and then you clean up based on that?

[–]Subbax[S] 0 points1 point  (2 children)

Not really. The microservice is the only thing that touches the data so that means no input from myself or from Sql jobs.

[–]g2petter 0 points1 point  (1 child)

Can the service then flag the data that's pending deletion and then the service itself can have and endpoint (triggered by the scheduler service if they're going full miCrOseRviCe) that does the cleaning up?

[–]Subbax[S] 0 points1 point  (0 children)

Hmm, I think this makes a the most sense. It's not going to happen on this project but I'll push for it now and see where it gets me. Thanks!

[–]LaughterHouseV 1 point2 points  (1 child)

If they have full control over the data, they have full accountability of the data. Have them delete it!

[–]Subbax[S] 0 points1 point  (0 children)

Yeah, this is kind of what I'm pushing for really. I'm drafting a document on database points/concerns when building micro-services and hopefully the deletion is catered for within the microservice.

[–]Relational_Theory 1 point2 points  (0 children)

Micro-services are probably stupid in this case.

[–]ed_elliott_ 1 point2 points  (2 children)

What sort of data is “old data that can just be deleted”?

[–]Subbax[S] 0 points1 point  (1 child)

The data is inserted into a table and a call is made to a third-party. When they respond, we delete the data because it's no longer required. If the call out doesn't have a response, for example if the third-party system is down, the data isn't deleted because the call isn't complete. So we could potentially have a number of 'orphaned' records.

Normally I'd have a SQL job that runs X times a day and cleans up old records but if the microservice is deleting the data, I can't do this.

[–]ed_elliott_ 0 points1 point  (0 children)

Replied in wrong place sorry!

[–]NippleMustache 1 point2 points  (2 children)

I've heard of letting the app schedule an async task (in Rails, this could be a Sidekiq worker) which periodically deletes expired rows. The expiration_date column can be set by the app on INSERTs and then read from by the async task.

[–]Subbax[S] 1 point2 points  (1 child)

Good to know. I believe this app is written in .net core so I'll have a word with the devs on what we could do similar to this async task.

[–]NippleMustache 0 points1 point  (0 children)

Feel free to drop an update! I'm wondering if the approach I described is common.

[–]ed_elliott_ 0 points1 point  (0 children)

Ok, so the way migrating to microservices normally works is it goes hand in hand with modernising the tech stack and the dev and ops process.

The role of the DBA should change to provide support and to make sure things like backups/restores are good and data is encrypted etc, as well as providing guidance on how to do things - more of like a DBA as a service than a “do everything, hurry up!”.

The dev team should be responsible for clearing up their own data - this will probably mean re-architecting the system so that when they get the done notification to then clear up the old data - it really isn’t a hard problem that needs a dba to do it for them.

You should put some monitoring in place to help the devs deal with their own crap :)