pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix concurrent indexing operations with temporary tables
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a904abe2e284f570168839e52e18ef0b7f26179d

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 ++
doc/src/sgml/ref/drop_index.sgml           |  5 ++
doc/src/sgml/ref/reindex.sgml              |  5 ++
src/backend/catalog/index.c                |  9 ++++
src/backend/commands/indexcmds.c           | 65 +++++++++++++++++++++-----
src/backend/commands/tablecmds.c           | 18 +++++++-
src/test/regress/expected/create_index.out | 74 ++++++++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 67 +++++++++++++++++++++++++++
8 files changed, 235 insertions(+), 13 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/817a1b88ac669a71b5f0f78cbfe84a73ae8abfd3

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 ++
doc/src/sgml/ref/drop_index.sgml           |  5 ++
doc/src/sgml/ref/reindex.sgml              |  5 ++
src/backend/catalog/index.c                |  9 ++++
src/backend/commands/indexcmds.c           | 65 +++++++++++++++++++++-----
src/backend/commands/tablecmds.c           | 18 +++++++-
src/test/regress/expected/create_index.out | 74 ++++++++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 67 +++++++++++++++++++++++++++
8 files changed, 235 insertions(+), 13 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5b4b07fa9ac34b2567d7e3ef67bfc17ab9aafbc4

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 +++++
doc/src/sgml/ref/drop_index.sgml           |  5 +++++
src/backend/catalog/index.c                |  9 ++++++++
src/backend/commands/indexcmds.c           | 33 +++++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 18 +++++++++++++++-
src/test/regress/expected/create_index.out | 25 ++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 25 ++++++++++++++++++++++
7 files changed, 112 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9055344b495f7015205658741734be9d67cf4f4a

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 +++++
doc/src/sgml/ref/drop_index.sgml           |  5 +++++
src/backend/catalog/index.c                |  9 +++++++++
src/backend/commands/indexcmds.c           | 27 ++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 18 +++++++++++++++++-
src/test/regress/expected/create_index.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 25 +++++++++++++++++++++++++
7 files changed, 106 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ef33edeb58350afde74a9b28e34efce0e3119063

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 +++++
doc/src/sgml/ref/drop_index.sgml           |  5 +++++
src/backend/catalog/index.c                |  9 +++++++++
src/backend/commands/indexcmds.c           | 27 ++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 18 +++++++++++++++++-
src/test/regress/expected/create_index.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 25 +++++++++++++++++++++++++
7 files changed, 106 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c39f455981770aa707f05d8e338b233e96730e47

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 +++++
doc/src/sgml/ref/drop_index.sgml           |  5 +++++
src/backend/catalog/index.c                |  9 +++++++++
src/backend/commands/indexcmds.c           | 27 ++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 18 +++++++++++++++++-
src/backend/utils/cache/lsyscache.c        | 22 ++++++++++++++++++++++
src/include/utils/lsyscache.h              |  1 +
src/test/regress/expected/create_index.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 25 +++++++++++++++++++++++++
9 files changed, 129 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Fix concurrent indexing operations with temporary tables
@ 2020-01-22 00:50 Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 7+ messages in thread

From: Michael Paquier @ 2020-01-22 00:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix concurrent indexing operations with temporary tables

Attempting to use CREATE INDEX, DROP INDEX or REINDEX with CONCURRENTLY
on a temporary relation with ON COMMIT actions triggered unexpected
errors because those operations use multiple transactions internally to
complete their work.  Here is for example one confusing error when using
ON COMMIT DELETE ROWS:
ERROR:  index "foo" already contains data

Issues related to temporary relations and concurrent indexing are fixed
in this commit by enforcing the non-concurrent path to be taken for
temporary relations even if using CONCURRENTLY, transparently to the
user.  Using a non-concurrent path does not matter in practice as locks
cannot be taken on a temporary relation by a session different than the
one owning the relation, and the non-concurrent operation is more
effective.

The problem exists with REINDEX since v12 with the introduction of
CONCURRENTLY, and with CREATE/DROP INDEX since CONCURRENTLY exists for
those commands.  In all supported versions, this caused only confusing
error messages to be generated.  Note that with REINDEX, it was also
possible to issue a REINDEX CONCURRENTLY for a temporary relation owned
by a different session, leading to a server crash.

The idea to enforce transparently the non-concurrent code path for
temporary relations comes originally from Andres Freund.

Reported-by: Manuel Rigger
Author: Michael Paquier, Heikki Linnakangas
Reviewed-by: Andres Freund, Álvaro Herrera, Heikki Linnakangas
Discussion: https://postgr.es/m/CA+u7OA6gP7YAeCguyseusYcc=uR8+ypjCcgDDCTzjQ+k6S9ksQ@mail.gmail.com
Backpatch-through: 9.4

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d76652edc56f7892806fabf08cad23321fe842de

Modified Files
--------------
doc/src/sgml/ref/create_index.sgml         |  5 +++++
doc/src/sgml/ref/drop_index.sgml           |  5 +++++
src/backend/catalog/index.c                |  9 +++++++++
src/backend/commands/indexcmds.c           | 27 ++++++++++++++++++++-------
src/backend/commands/tablecmds.c           | 18 +++++++++++++++++-
src/backend/utils/cache/lsyscache.c        | 22 ++++++++++++++++++++++
src/include/utils/lsyscache.h              |  1 +
src/test/regress/expected/create_index.out | 25 +++++++++++++++++++++++++
src/test/regress/sql/create_index.sql      | 25 +++++++++++++++++++++++++
9 files changed, 129 insertions(+), 8 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2020-01-22 00:50 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>
2020-01-22 00:50 pgsql: Fix concurrent indexing operations with temporary tables Michael Paquier <michael@paquier.xyz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox