There are quite a few ways you could drive yourself crazy as a software engineer, but one of them is something I’ve been battling with for over a week. I finally found the root cause today (fingers crossed anyway).
Remember the concurrency stuff I posted about before? I kept getting reports that it was not helping things and that duplicate data was getting stored in the database because several threads were going into transactions at once. It was puzzling to me. I tried way after way to imitate the scenario based on the feedback I got but no matter what I did my end behaved normally while the report logs showed clear violations of the protections I put into place. But then I noticed something!
There was a log output statement that I couldn’t account for. I remember it, but it wasn’t in the codebase at the commit that the log claimed to have been made from. That’s really odd because that commit hash is embedded into the library with every build. Luckily I remembered where the statement used to be, and I went to check. As it turns out not only did I recently remove that log statement, but it was part of the commit which fixed the problem that the report was about. How could it be that the logs reported a commit after the fix, but still contained statements from before the fix?
The logs originated in the SQLCipher plugin assembly, that is how! The Couchbase Lite main DLL was built at the correct version, but the plugin was stale. The thing is, this problem has happened to me more times than I can count, yet it still sneaks up on me. I filed this issue to attempt to crack down on this kind of problem though!