FoundationDB/sql-layer — pull request #911 by MMcM (2013-09-14 20:03:29+00:00)
Title: Give Routine a version field, maintained to increase for every rooutine.

And use that version to validate routine caches so that the persistent AIS is always the authoritative source without relying on DDL execution to clear any caches.

The version is based on the AIS generation, but only as a source of globally increasing numbers. The only requirement is that no two routines ever have the same name and the same version. I could call the field generation, if that would be better. Note that UserTable has a version field, too, but with somewhat different semantics (though I believe switching it to use the *more* unique scheme adopted here would work). I found the comment in the .proto file on that field a little misleading, but did not change it.

There still is a cache clear, but now after the DDL (which supplies the transaction) and for the purpose of reducing memory, not enforcing correctness. There are edge cases where the cache can be left with an invalid entry that no one ever looks at, and where it will thrash as a simultaneous thread with an older AIS version runs. But it did not seem worth the much more complicated data structure to address those.

There are no new tests for the single node case. I believe that existing YAML tests verify that I didn't break redefining a procedure and calling it on the same machine. I manually tested that two SQL servers backed by the same FDB would previously expose stale procedure definitions in the one that didn't last change it and that this branch fixes that.