Subject Re: [firebird-support] Service restore from stdin
Author Pavel Cisar
Dne 4.10.2017 v 16:24 Dimitry Sibiryakov sd@...
[firebird-support] napsal(a):
> 04.10.2017 11:42, Pavel Cisar pcisar@... [firebird-support] wrote:
>> Until stdin is fully transmited service may need another
>> chunk, but reply to application is blocked until stdout buffer (eof
>> request) is full, so everything gets stuck (service will not ask for
>> further input because there is not enough output to send the request).
>
> Actually I see the contrary: output buffer is empty, but no request for input is sent.
> Output from my test program which send { isc_info_svc_stdin, isc_info_svc_line } looks
> like that:
>
>> query piece 0
>> isc_info_svc_stdin 262144
>> isc_info_svc_line 0:
>> isc_info_data_not_ready
>> query piece 512
>> isc_info_svc_stdin 262144
>> isc_info_svc_line 0:
>> isc_info_data_not_ready

Actually it sent request for stdin data. When isc_info_svc_stdin returns
0 then no data are needed. When it returns non-zero values then it means
that service is ready to accept up to <value> bytes in next request
(marked as isc_info_svc_stdin). isc_info_svc_line is non-zero only when
service sends back some textual output.

> Notice that it always gets isc_info_data_not_ready.

Because there is no output - yet. Output may happen only in response to
input.

> But if I change request to {isc_info_svc_stdin } (because I know that no data is ever
> returned), I get this:
>
>> query piece 0
>> isc_info_svc_stdin 0
>> isc_info_end
> ........ about 40 times the same ..........
>> query piece 0
>> isc_info_svc_stdin 0
>> isc_info_end
>> query piece 0
>> isc_info_svc_stdin 262144
>> isc_info_end
>> query piece 512
>> isc_info_svc_stdin 262144
>> isc_info_end

First several rounds could return zero values for isc_info_svc_stdin
because service is warming up. But once it returns non-zero value it
always wants more until whole backup stream is sent. Then it returns
zero for isc_info_svc_stdin and only isc_info_svc_line output (until
finish).

> Now I forcefully disconnect after sending of whole backup and it seems to work. But is
> it right way?

Nope, without requesting isc_info_svc_line output you can't know when
service actually finished, so you may close the service at will. If you
close it *after* its finished then everything is ok, but if not, you
will get broken database (unfinished restore). Note that after whole
backup file is processed (and thus no more data are requested), then
service recreates the index trees which may take a lot of time (depends
on data size and number of indices) when you would get only text output.

And yes, it's all convoluted and inconvenient.

best regards
Pavel Cisar
IBPhoenix