Re: [firebird-support] Service restore from stdin

2017-10-05 Thread Pavel Cisar pci...@ibphoenix.cz [firebird-support]
Hi,

Dne 4.10.2017 v 19:17 Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] napsal(a):
> 
> Another question: is there a way to abort restore process which would 
> cause server to
> drop half-restored database? For example, if I have a problem of reading 
> backup file.
> Or in this case I must connect to the database and drop it myself?

 From my experience it appears that gbak service process is terminated 
when you close the service, but I don't know if it always works this way 
and any circumstances and if it's applicable to other services. But it 
would have some logic that process will be terminated by engine when 
service connection is closed. Core devs or sources could confirm that 
information. However, this termination will/may leave some artifacts 
behind (like half-restored database, but I would expect cleanup of 
temporary files).

best regards
Pavel Cisar
IBPhoenix







++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.10.2017 18:28, Pavel Cisar pci...@ibphoenix.cz [firebird-support] wrote:
> 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.

   Fine.

   Another question: is there a way to abort restore process which would cause 
server to 
drop half-restored database? For example, if I have a problem of reading backup 
file.
   Or in this case I must connect to the database and drop it myself?

-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Pavel Cisar pci...@ibphoenix.cz [firebird-support]


Dne 4.10.2017 v 16:24 Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] napsal(a):
> 04.10.2017 11:42, Pavel Cisar pci...@ibphoenix.cz [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  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






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.10.2017 16:24, Dimitry Sibiryakov wrote:
>    I.e. server just wasting network throughput requesting no data from client 
> as if 
> request timeout is by default set to zero instead of infinity.

   Oops, I was wrong: even explicitly set timeout don't make service to wait 
before 
sending input data request.

-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.10.2017 11:42, Pavel Cisar pci...@ibphoenix.cz [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

   Notice that it always gets isc_info_data_not_ready.
   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

   I.e. server just wasting network throughput requesting no data from client 
as if 
request timeout is by default set to zero instead of infinity.
   Is it intended behavior?

   Besides, my whole test backup size is 512 bytes, but server asks for more 
data even 
when got it all.
   What else must I send to it?
   Now I forcefully disconnect after sending of whole backup and it seems to 
work. But is 
it right way?

-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
04.10.2017 11:42, Pavel Cisar pci...@ibphoenix.cz [firebird-support] wrote:
> You can't use isc_info_svc_line for sending backup file to the service.

   But that's what fbsvcmgr does.

> The right token is isc_info_svc_stdin.

   No, it is only for getting buffer size from server. I have no idea why 
application must 
care about server buffer, but that how current implementation works.

> isc_info_svc_to_eof *may* work once whole backup stream is sent to the 
> service,

   I tried. My backup file was 512 bytes long, but it didn't work. That's why I 
started 
this thread.

-- 
   WBR, SD.






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



Re: [firebird-support] Service restore from stdin

2017-10-04 Thread Pavel Cisar pci...@ibphoenix.cz [firebird-support]
Hi,

You can't use isc_info_svc_line for sending backup file to the service. 
The right token is isc_info_svc_stdin. However, you have to send 
isc_info_svc_line request along with it to get output from service to 
detect that restore finished (value zero for reply to isc_info_svc_stdin 
is just a signal that no stdin input is needed right now).

The reason why isc_info_svc_to_eof doesn't works here is IMHO because 
this token returns after output buffer is full, not when any further 
output is available like isc_info_svc_line (because output is always 
produced in form of lines).

Restore via service using stdin is kind of a hack implementation that 
require client to mix up two parallel "conversations" in single message 
exchange loop: a) handling service request for stdin input b) service 
stdout output because it's the only way how client can detect that the 
restore finished (hence the need for isc_spb_verbose in restore 
request). 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).

isc_info_svc_to_eof *may* work once whole backup stream is sent to the 
service, so only stdout output is is service's reply (stdin reply is 
zero), but there is no need to complicate the implementation at client 
side to handle both output methods.

You may take a look at local_restore() implementation in FDB driver v1.8.

best regards
Pavel Cisar
IBPhoenix

Dne 3.10.2017 v 16:30 Dimitry Sibiryakov s...@ibphoenix.com 
[firebird-support] napsal(a):
> Hello.
> 
> When I use isc_info_svc_line for sending a piece of backup to server, 
> everything works
> well. But when I use just replace isc_info_svc_line with isc_info_svc_to_eof, 
> no errors is
> produced, but database is not restored.
> Do I something wrong or it is a bug (incomplete implementation)?
> 






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/