Error in Jenkins Job while executing postgreSQL query [on hold]

I’m running a postgreSQL query via Python via Jenkins,But certain times my job is getting failed with the below error, Does anyone have any idea on how to rectify this?

psycopg2.errors.InternalError_: could not find key 6 in shm TOC  at 0x7fecd49a8000 CONTEXT:  parallel worker Build step 'Execute shell' marked build as failure Finished: FAILURE