I had no luck over at general slack channel. So I'm beginning to treat this as a bug. Here's a test case that unexpectedly fails at last insert. I expect it not to fail because the rows that the two transactions act on are unrelated to one another.
CREATE TABLE t1 ( class integer NOT NULL
);
CREATE INDEX ON t1 (class);
CREATE TABLE t2 ( class integer NOT NULL
);
CREATE INDEX ON t2 (class);
ALTER SYSTEM SET enable_seqscan TO off;
-- Session 1
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT * FROM t2 WHERE class=1;
-- Session 2
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SELECT * FROM t1 WHERE class=2;
INSERT INTO t2 VALUES(2);
COMMIT;
-- Session 1
INSERT INTO t1 VALUES(1);
COMMIT;
Postgres version is PostgreSQL 12.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.3.0) 9.3.0, 64-bit.