Could not write to hash join temporary file : operation not permitted

I am facing this error in postgres:

could not write to hash-join temporary file : operation not permitted

I face this error while trying to update a table named “inventory_history”, for this query :

update inventory_history t1

set asset_status=’REMOVED’,


from remove_main_keys t

where t1.main_key=t.main_key

and t1.asset_status<>’REMOVED’;

It seems it is not able to write to some postgres temporary files of hash-joins.

We had restarted the db on because this table had got locked. I had tried "vacuum full","update" and then a partial truncate on this table. It had got locked after vacuum full itself so I stopped it. Tried other 2 operations but stopped those operations halfway as well. I was not able to apply select query on it so I had restarted the db. Then, i created its .bak file and i have tried to restore it again. Now i am able to apply select queries on it, i granted permissions but when i run a pentaho job on it, i get the above error. Is this table still in locked state? Can we unlock this table?

I checked other similar questions on this but all temporary hash join file problems are related to space issues in other stackoverflow problems. I am not able to find any particular solution for my problem.

Please help.