Re: Using threads in FDW for read-ahead

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Noah Watkins <noahwatkins(at)gmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Using threads in FDW for read-ahead
Date: 2014-06-10 19:21:01
Message-ID: 3383.1402428061@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Noah Watkins <noahwatkins(at)gmail(dot)com> writes:
> I have created a FDW for a storage backend and it is working well, and now
> I would like to overlap processing with I/O by performing read-ahead. I
> started by using a thread to do background I/O and this worked, but
> problems started to arise when I tried to do predicate filtering in the
> thread.

> In particular, it seems as though `check_stack_depth` is built to assume a
> single threaded environment (`stack_base_ptr` is global).

That is not even the tip of the iceberg of what will break if you try
to use multiple threads in a Postgres backend. It's not supported.
You might possibly manage to not break things if you keep the extra
threads sufficiently narrowly scoped --- which for starters would include
no use of palloc nor elog. Executing query predicates is right out.

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Ian Pye 2014-06-10 19:23:10 Re: Using threads in FDW for read-ahead
Previous Message Noah Watkins 2014-06-10 19:10:22 Using threads in FDW for read-ahead