Re: MultiXactId error after upgrade to 9.3.4

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: MultiXactId error after upgrade to 9.3.4
Дата
Msg-id 20160622213256.GA165846@alvherre.pgsql
обсуждение исходный текст
Ответ на Re: MultiXactId error after upgrade to 9.3.4  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: MultiXactId error after upgrade to 9.3.4  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Robert Haas wrote:

> I see the patch, but I don't see much explanation of why the patch is
> correct, which I think is pretty scary in view of the number of
> mistakes we've already made in this area.  The comments just say:
>
> + * A tuple that has HEAP_XMAX_IS_MULTI and HEAP_XMAX_LOCK_ONLY but neither of
> + * XMAX_EXCL_LOCK and XMAX_KEYSHR_LOCK must come from a tuple that was
> + * share-locked in 9.2 or earlier and then pg_upgrade'd.
>
> Why must that be true?
>
> + * We must not try to resolve such multixacts locally, because the result would
> + * be bogus, regardless of where they stand with respect to the current valid
> + * range.
>
> What about other pre-upgrade mxacts that don't have this exact bit
> pattern?  Why can't we try to resolve them and end up in trouble just
> as easily?

Attached are two patches, one for 9.3 and 9.4 and the other for 9.5 and
master.  Pretty much the same as before, but with answers to the above
concerns.  In particular,

 /*
+ * A tuple that has HEAP_XMAX_IS_MULTI and HEAP_XMAX_LOCK_ONLY but neither of
+ * XMAX_EXCL_LOCK and XMAX_KEYSHR_LOCK must come from a tuple that was
+ * share-locked in 9.2 or earlier and then pg_upgrade'd.
+ *
+ * In 9.2 and prior, HEAP_XMAX_IS_MULTI was only set when there were multiple
+ * FOR SHARE lockers of that tuple.  That set HEAP_XMAX_LOCK_ONLY (with a
+ * different name back then) but neither of HEAP_XMAX_EXCL_LOCK and
+ * HEAP_XMAX_KEYSHR_LOCK.  That combination is no longer possible in 9.3 and
+ * up, so if we see that combination we know for certain that the tuple was
+ * locked in an earlier release; since all such lockers are gone (they cannot
+ * survive through pg_upgrade), such tuples can safely be considered not
+ * locked.
+ *
+ * We must not resolve such multixacts locally, because the result would be
+ * bogus, regardless of where they stand with respect to the current valid
+ * multixact range.
+ */
+#define HEAP_LOCKED_UPGRADED(infomask) \
+( \
+    ((infomask) & HEAP_XMAX_IS_MULTI) && \
+    ((infomask) & HEAP_XMAX_LOCK_ONLY) && \
+    (((infomask) & (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)) == 0) \
+)


One place that had an XXX comment in the previous patch
(heap_lock_updated_tuple_rec) now contains this:

+               /*
+                * We don't need a test for pg_upgrade'd tuples: this is only
+                * applied to tuples after the first in an update chain.  Said
+                * first tuple in the chain may well be locked-in-9.2-and-
+                * pg_upgraded, but that one was already locked by our caller,
+                * not us; and any subsequent ones cannot be because our
+                * caller must necessarily have obtained a snapshot later than
+                * the pg_upgrade itself.
+                */
+               Assert(!HEAP_LOCKED_UPGRADED(mytup.t_data->t_infomask));


--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Parallelized polymorphic aggs, and aggtype vs aggoutputtype
Следующее
От: David Rowley
Дата:
Сообщение: Re: Parallelized polymorphic aggs, and aggtype vs aggoutputtype