#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    4
    Rep Power
    0

    FB embedded and multihreading


    Is it possible to use FB embedded on Win32 platform in a multithreaded application? Currently our server that relies on FB embedded keeps crashing in the FBCLIENT.DLL if the calls are made from different threads simultaneously. Serializing the requests hurts performance noticeably especially if there are any active update operations that take long time. Hence my questions:
    • is it possible to call FB embedded engine from multiple threads at all?
    • if not, is it possible to at least perform simultaneous queries (read-only)?
    • and is there any way how to open a separate connection for SELECT and for UPDATE?

    Thanks for any replies

    Best regards

    Karel Obluk
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Hi,

    Firebird isn't thread safe if you let multiple threads use the same connection. With Fb Embedded, you can have only a single connection to a database, therefor: not threadsafe.

    --
    Martijn Tonies
    Database Workbench: works with Firebird, MySQL, InterBase and MSSQL Server
    Upscene Productions
    http://www.upscene.com
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    4
    Rep Power
    0
    OK, thanx for explanation.
    Now, from your answer I assume that if using the standalone version, it should be possible to create multiple connections and use them from more than one thread. Is that so? Also, is it possible to pass the connection in between threads (i.e. re-using a connection)? In my app I have a huge number of short-live threads and I would like to use some kind of "connection pool". Is that possible?
    Thank you very much for your help!
    Karel
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Hi,

    I'm unsure if you can have multiple connections with Embedded to the same database. Give it a try, I would say, but I don't think so.

    Yes, you can pass connections between threads -- but only ONE thread should be using the connection at any time.

    Anyway, threads are easier with the full server and a remote connection.


    --
    Martijn Tonies
    Database Workbench: works with Firebird, MySQL, InterBase and MSSQL Server
    Upscene Productions
    http://www.upscene.com
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    4
    Rep Power
    0
    I understand that it is not possible to use multiple connections with the embedded version. What I was asking now was if multiple connections from multiple threads can be used with the standalone version (remote connection). If yes, this would solve my problem.
    Thank you
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    249
    Rep Power
    14
    Hi,

    As I said, that's possible. But only 1 thread should use 1 connection at any time.

    And you have to use a "remote" connection (if it's on the same machine, use "localhost" as the server name).

    --
    Martijn Tonies
    Database Workbench: works with Firebird, MySQL, InterBase and MSSQL Server
    Upscene Productions
    http://www.upscene.com
    Martijn Tonies
    Database Workbench: developer IDE for Firebird, MySQL, InterBase, MSSQL Server and Oracle
    Upscene Productions
    http://www.upscene.com

IMN logo majestic logo threadwatch logo seochat tools logo