Greetings, * Corey Huinker (corey.huin...@gmail.com) wrote: > > No, we should be keeping the lock until the end of the transaction > > (which in this case would be just the one statement, but it would be the > > whole statement and all of the calls in it). See analyze.c:268 or > > so, where we call relation_close(onerel, NoLock); meaning we're closing > > the relation but we're *not* releasing the lock on it- it'll get > > released at the end of the transaction. > > If that's the case, then changing the two table_close() statements to > NoLock should resolve any remaining concern.
Note that there's two different things we're talking about here- the lock on the relation that we're analyzing and then the lock on the pg_statistic (or pg_class) catalog itself. Currently, at least, it looks like in the three places in the backend that we open StatisticRelationId, we release the lock when we close it rather than waiting for transaction end. I'd be inclined to keep it that way in these functions also. I doubt that one lock will end up causing much in the way of issues to acquire/release it multiple times and it would keep the code consistent with the way ANALYZE works. If it can be shown to be an issue then we could certainly revisit this. Thanks, Stephen
signature.asc
Description: PGP signature