-2

Dilemma: I am working in microservices (MS) architecture for a product with shared (PostgreSQL) DB between MSes and DB Views exposed as Data Access API between SW Components, written and maintained by different teams in different languages (Java+Hibernate, C#, Python).

I have tables/views like root with columns id, name, type, is_deleted (a parent table for almost all entities in a System) and tables like child1 with columns id, ssn, birthday, child2 with columns id, mac, ip, system_uuid, child3 with columns id, sw_type, sw_version, system_uuid.

Column "system_uuid" is present almost for all children entities and is meaningful for all entities in the system (where not present - some default value is used) and I need to copy it to root table for displaying in events log.

After I added system_uuid column to root table as well, a lot of SQL queries from other SW Components were failing, because existing queries didn't qualify system_uuid properly, e.g.

SELECT R.id, R.name, system_uuid, C.ssn 
FROM root R JOIN child1 C ON C.id = R.id

The issue could have been prevented by writing C.system_uuid.

Now we are negotiating between teams: who should fix issue? Maintainers of those SW Components with those "bad" SQLs, or me (by fixing the component which added the new column creating the ambiguity)?

What are best practices for such cases?

8
  • 5
    Software development is a team effort. Work it out between you. Commented Mar 9, 2023 at 6:59
  • 1
    Software development is indeed a team effort, and I agree the best would be for you all to work together. However a strong case can also be made for: you break it, you fix it. Of course that would require the setup to enable you to build the other components. Commented Mar 9, 2023 at 7:27
  • Whatever you work out with the other teams, make sure that the architect(s) who decided on using a microservice architecture with a shard database know about this problem as well. It is a prime example why that setup is a bad idea. Commented Mar 9, 2023 at 8:11
  • Are those queries generated dynamically from the schema? Normally, adding a new column to a table does not break an existing SELECT statement.
    – Doc Brown
    Commented Mar 9, 2023 at 11:44
  • 1
    @ALZ: ok, thank you, now I got it. Let me fix the wording of your question a little bit.
    – Doc Brown
    Commented Mar 9, 2023 at 12:31

1 Answer 1

2

This is of-course subjective, and opinions may differ. There is no one size fits all, and what is a good practice for some might not be so for you. But I have attempted to give my input.

It appears that you introduced a breaking change, that caused code to break in other parts of the system. Firstly this raises some interesting issues, did you not notice the breaking change when introducing the change, from failing tests and builds? If not, then that might indicate that your pipeline needs some attention.

You call the SQL queries "bad", and that might be true for some, but remember that those queries were functioning before the change, so while they were clearly vulnerable to the change introduced, "bad" might be a bit harsh. The most important thing code can do is ship, and after that it is work as intended.

Breaking changes, should ideally not be something that you deal with too often, and when it is it should bear the cost of fixing the breaking code. Basically you should consider obeying by the "You break it, you fix it" mantra. Software development is a team effort and as such you might be lucky enough to get help from the implicated module developers. But as a general rule you should fix the cause of the breaking change, when introducing the change.

This also has the added benefit of understanding the implications that the change will have, and might make you reconsider the change - simply because the cons can outweigh the pros.

A lot has to do with the setup, as I mentioned in the beginning. Do your setup allow you to make changes and rebuild the code, also that of others to see the effect that it might have on them? Is your testing coverage and strategy good enough to catch these cases, and are you confident enough in them, that you trust them? This change might not be the most obvious case for a breaking change, but most often these changes are not deliberate.

Breaking changes not being deliberate is also something to keep in mind, when trying to place blame, or move responsibility around trying to figure out who to fix the problem. You introduced the problem, that might have only been a problem due to the way code was written elsewhere, so work on fixing the problem, and hopefully your organization has a mature mindset and helps you out, because at the end of the day, fixing the change is for the benefit of you all.

So in the end software development is a team effort, but start fixing the breaking changes yourself.

9
  • 2
    This answer is not bad. However, in reality, "you break it, you fix it" is only applicable directly when the fix is in part of the code base the OP is allowed to change - and since OP mentioned Microservices and "mitigating between teams" would be necessary, I think they are not. They can try to solve the issue with a local fix in their "own" components, but by doing this regularly, it might lead to a code base full of unsolved design flaws and local fixes.
    – Doc Brown
    Commented Mar 9, 2023 at 11:45
  • 1
    ... I think a better recommendation here would be to make a cost/benefit/risk analysis of the different solutions and then decide based on that analysis.
    – Doc Brown
    Commented Mar 9, 2023 at 11:48
  • 1
    Maybe I misunderstood something, but I think the OP meant "who should fix the issue - the maintainers of other Software components containing bad SQLs, or me - in the Software components I wrote".
    – Doc Brown
    Commented Mar 9, 2023 at 12:13
  • 1
    I have no access to sources of other MSes which uses my Views
    – ALZ
    Commented Mar 9, 2023 at 12:32
  • 1
    @PhilipKendall: you are right, but whatever one calls the architecture, the issue stays the same.
    – Doc Brown
    Commented Mar 10, 2023 at 9:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.