I picked the wrong end of the pipeline (twice)
I gave a talk at Brighton Data Forum about moving our IoT data off InfluxDB, applying corrections in the wrong place, getting caught out by it twice and eventually taking the advice I'd been given years before. This is the written version, mistakes included.
- Data engineering
- BigQuery
- dbt
- Talks
- Incident review
Last week I gave a talk at Brighton Data Forum called I Picked the Wrong End of the Pipeline (Twice). It's pretty much what it says on the tin: a design decision on a data migration came back to bite us, and a few days later it bit us again.
I was more open about the mistakes than I'd planned to be. Talks about things going wrong are rarer than they should be, partly because it's uncomfortable having your mistakes on the record, and I felt that afterwards. But it went down better than I expected. Someone told me it was good that it wasn't smooth like a TED talk, and someone else said it had given them a lot to think about for a migration they're doing at work. So I've written it up properly, with more of the reasoning that didn't come across on stage.
Some context#
I'm the Software Manager at Naked Energy, where we make solar thermal collectors. They produce heat from sunlight rather than electricity like PV does. Compared to PV they produce more energy, save more money and avoid more carbon emissions, but the upfront cost is higher, the installation is more complicated and the technology is less mature.
Clarity247 is our monitoring platform for operations and maintenance, and it's what our customers use to see how their systems are performing. It was the reason I joined Naked Energy in the first place.
Data has been a big part of my role at different times. When we first took on Clarity247 it was almost my entire job. These days the pipelines are stable and the workflows are well established, so it takes up much less of my week, and the rest is split across web development, management, AI apps, CI/CD, cybersecurity, UX and business logic. When we made this decision I was in the middle of other urgent project work and managing the team, so an important architecture call got less time than it deserved. That's the honest background to what happened next.
The stack we inherited#
We didn't choose the original stack. Clarity247 started as a fork of another company's tool, and it came with InfluxDB for storing the raw sensor readings. Influx is a fast time series database and it does that job well, but for us it came with versioning issues, commercial pricing and some pretty weird query languages.
Raw data came in and was saved straight to Influx untouched. When you loaded a chart, the query applied calibration values stored in Django. Correcting on read meant that if we changed a calibration, every chart was instantly right, which is really nice. The downside was that the data was tightly coupled to our Django server, so you couldn't make sense of it without going through the app.
For production we'd been using the previous company's Influx instance, and they were very kind to let us carry on using it for years. Eventually we got a nudge to move off it so they could get some space back, which was completely reasonable. We needed a new home for our data.
The advice I didn't take#
One of the first Brighton Data Forum talks I went to was David Kane talking about how they used dbt. A couple years later at EVOLVE [25] he told me I could really benefit from using it at work. I didn't think we needed it. We already had a way to create views with Terraform, and keeping both raw and corrected copies of every reading looked like a bigger risk to me than having to fix the odd bad reading by hand. Two copies of the data meant two things that could drift apart, and corrections seemed rare enough to deal with when they came up.
Moving to BigQuery#
We saw the migration as an opportunity rather than a chore. We didn't just want charts that someone had to explain to people. We wanted data that was actually useful, that people could read in new ways, and that wasn't tied to our server.
We went with BigQuery. The Django data was replicated into a BigQuery table, and incoming readings were corrected and stored in their final format, so queries could read the data directly without Django. That was the whole point: decoupling the data from the app.
I knew there was a trade-off. Corrections would now need to be applied historically, and I'd even put that on a slide at the time. What I didn't do was come up with a real plan for how we'd handle it. That was a genuine oversight.
The migration itself was done carefully. We created the new BigQuery table, wrote data to both Influx and BigQuery in parallel, built a query engine for BigQuery and validated that the two matched before switching over. Only then did we turn off the Influx writes. In the talk I claimed I got a standing ovation from the board, a generous retirement package and a statue in the office. None of these happened.
And then it happened (twice)#
Not long after, we found that a sensor had been misconfigured. It was reporting in tens of units instead of ones, so all of its readings were out by a factor of ten. With the old setup this would have been a quick fix: update the mapping and every chart is right again.
With the new setup, updating the mapping only fixed future readings. Because the corrections had been applied when the data was written, all of the historical readings for that sensor were now wrong. We didn't have a proper procedure for it because it happens so rarely, so we put a workaround in place and fixed the data. We caught it internally and there was no impact on customers.
Then, only a few days later, it happened again on the same sensor, before I'd had a chance to look for a proper solution. Two incidents in a week made it clear that correcting on write wasn't the way to go, at least not on its own. Editing raw data by hand is scary, and our corrections weren't replayable or logged anywhere.
I had the risks the wrong way round. Corrections were rarer than ordinary writes, but each one was far more painful than I expected, and keeping the raw data turned out to be the thing that made them safe.
Listening to David (eventually)#
The fix came from a bit of a strange place. I'd signed up to help out at a dbt workshop with the Brighton Data Forum, and going through the material it all finally clicked.
The workshop covered medallion architecture. Your raw data lands in a bronze layer, cleaned data goes into silver and the business-ready models sit in gold, with dbt building the connections between each layer. If you need a new insight you write a new query and get a new table. You build views on top of views so each query stays simple. That was basically the advice David had given me years earlier, and it solved exactly the problem I'd created.
Now every incoming reading is written to both a bronze table, with the raw data exactly as it arrived, and a silver table with the corrections applied. If a correction is needed, we update the calibration and overwrite the silver data for that reading from bronze. We never touch the raw data, and corrections can be replayed whenever we need them.
My role on the data side has changed too. Rather than designing every model myself, I see my job as making the platform safe for our data analyst to build on: raw data that's never touched, corrections that can be replayed, separate staging and production, and CI/CD for the dbt models. He builds the marts, models and dimensions the business needs, and I make sure the foundations underneath are solid enough that he can.
We migrated the same way as the first time: set up dbt, write to both the old and new setups, build a query engine for the medallion architecture, validate parity, switch over, then turn off the old writes. The migration process held up both times. It was the design that let us down the first time.
What I learned#
- Keep your raw data
- Make your corrections replayable
- Name your trade-offs, and actually come up with a plan for how you're going to deal with them
- Give big architecture decisions proper time and attention, especially when you're stretched. If you can't, slow the decision down or bring someone else in
- Listen to David!
Why I told it this way#
I could have given a much tidier version of this talk where medallion architecture was the plan all along. I'd have looked better, but it would have been a lot less useful for anyone in the room. Someone about to start their own migration doesn't need to hear that I got it right first time. They need to know that correcting on write feels fine until a sensor is wrong, and that keeping your raw data is cheap insurance.
I still feel a bit uncomfortable knowing this is out there. But the record says I made a trade-off that looked reasonable at the time and didn't plan for it properly, then fixed it properly and shared what I learned so other people don't have to make the same mistake. I'm alright with that.

Written by
Ash Oldershaw, software manager at Naked Energy. About me