<div><div>Hello guys.</div><div>I'm facing the following problem which seems to me a bug. Postgres version used - 13.7</div><div> </div><div>1) Connection1:</div><div>create or replace function test_fn() returns text as $$</div><div>begin</div><div> return 'version1';</div><div>end;</div><div>$$ language plpgsql;</div><div> </div><div>2) Connection2:</div><div>begin;</div><div>select test_fn();</div><div> test_fn</div><div>---------</div><div> version1</div><div>(1 row)</div><div> </div><div>3) Connection1:</div><div>create or replace function test_fn() returns text as $$</div><div>begin</div><div> return 'version2';</div><div>end;</div><div>$$ language plpgsql;</div><div> </div><div>4) Connection2:</div><div>select test_fn();</div><div> test_fn</div><div>---------</div><div> version1</div><div>(1 row)</div><div> </div><div>So the question is why Connection2 does not see updated version of test_fn? I've looked at source code and found that system cache invalidations (PROCOID cache in this case) occurs in AcceptInvalidationMessages() call chain. This function is called in a plenty of places but not when we call function in a running transaction as in the example. My thought is that AcceptInvalidationMessages() should be called in xact.c --> StartTransactionCommand() for TBLOCK_INPROGRESS, TBLOCK_IMPLICIT_INPROGRESS, TBLOCK_SUBINPROGRESS cases. Am I right or is it not even a bug?</div></div>