Tom Lane wrote:
> I'm getting tired of repeating this, but: the planner doesn't use a
> snapshot.  System catalogs run on SnapshotNow.

I am really sorry if I sound foolish here. I am NOT suggesting
that we use "snapshot" to read system catalogs. I understand
that system catalogs run on SnapshotNow and all transactions,
irrespective of when they started, would see the changes to
system catalogs as soon as the transaction updating the
system catalog commits.

What I am suggesting is to use ActiveSnapshot (actually
Florian's idea) to decide whether the transaction that created
index was still running when we started. Isn't it the case that
some snapshot will be "active" when we plan ? The active
snapshot may change later in the same transaction if we
are running in read-committed mode, and we may need to
invalidate the plan.

Here is what I suggest to do in get_relation_info():

+    if (index->indcreatexid != InvalidTransactionId)
+    {
+        Assert(ActiveSnapshot);
+        if (XidInMVCCSnapshot(index->indcreatexid, ActiveSnapshot))
+        {
+            index_close(indexRelation, NoLock);
+            continue;
+        }
+        /*
+         * Otherwise the index is usable
+         */
+    }

Is there a problem with this ?

I really appreciate all the help I am receiving on this. But
there is hardly anything else that I can do than post my
thoughts and get feedback, until we find a clean solution :-(




---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to