I am getting FailedAssertion while executing the attached script.However,I am not able to produce the core dump for the same,the script runs in background and takes around a day time to produce the mentioned error.
"TRAP: FailedAssertion("!(TransactionIdPrecedesOrEquals(oldestXact, ShmemVariableCache->oldestXid))", File: "clog.c", Line: 683) 2017-07-19 01:16:51.973 GMT [27873] LOG: server process (PID 28084) was terminated by signal 6: Aborted 2017-07-19 01:16:51.973 GMT [27873] DETAIL: Failed process was running: autovacuum: VACUUM pg_toast.pg_toast_13029 (to prevent wraparound)"
It's not much of a stretch to assume this was likely introduced by ea42cc18c:
so I'll have a look to see if I can spot how it could happen.
Please show your "SELECT version()" and if using a build from git, the "git rev-parse --short HEAD" for the build you're running.
It's interesting and probably significant that your Pg was nearing wraparound. Just a tip for that - if you want to create a situation where you near wraparound quickly and easily, for testing, you can, on a test instance you don't care about:
That should put you about 1000 txn's from the 1 million xid limit, assuming I got my maths right (don't assume that), and assuming your starting xid is well short of the 2-million mark.