14.03.2016 19:29, Dimitry Sibiryakov wrote:
> 14.03.2016 18:12, Alex Peshkoff wrote:
>> But use of by name search if ID is unusable due to file not
>> exists appears unavoidable.
>
>     Not true. Thread that is going to create file must do it while keeps db 
> list mutex. In
> this case it can be sure that no other thread can try to create the file in 
> parallel.
>     I.e. sequence like this:
>
> 1) create dbb with flag "creating"
> 2) get list mutex
> 3) create the file and get its id
> 4) add the id to the list
> 5) release list mutex
> 6) acquire dbb init mutex
> 7) make sure that "create" flag is still here
> 8) continue db initialization
>
>     Thread that do attach to database should do it in this sequence
>
> 1) create dbb with "init" flag
> 2) open the file and get id

   These two steps adds additional run-time overhead not needed for most 
attachments.

> 3) get list mutex
> 4) if the file is already in the list, drop new dbb and use old one
> 5) release list mutext
> 6) get dbb init mutex
> 7) check that dbb has no "create" flag and throw "file not exist" (yes!) 
> otherwise.
> 8) if dbb has "init" flag - init it, otherwise just use it.
>
>     In this case there will be no thread races and clash.

   You must consider detach, drop and database shutdown to get full picture.

Vlad


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to