Recent

Author Topic: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned  (Read 3721 times)

incendio

  • Full Member
  • ***
  • Posts: 157
[SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« on: January 25, 2022, 08:10:38 am »
Hi guys,

I use IBX 2.4.3 and have this code :
Code: Pascal  [Select][+][-]
  1. procedure TInpUsrFrm.FormCreate(Sender: TObject);
  2. begin
  3.   Trs.Active:= true;
  4.   Dt.Open;
  5.   Dt.Append; // This code raised error
  6. end;
  7.  

That form was called from a main menu with this code
Code: Pascal  [Select][+][-]
  1. procedure TMainFrm.AddUserClick(Sender: TObject);
  2. begin
  3.    InpUsrFrm := TInpUsrFrm.Create(Nil);
  4.    InpUsrFrm.ShowModal;
  5.    FreeAndNil(InpUsrFrm);
  6. end;

First time clicked on that menu, application runs OK, but after the form closed and clicked the menu again, got this error :

EIBClientError with message :
Transaction not assigned


Trs is a TIBTransaction.
Dt is a TIBDataset, CachedUpdates set to true, and Transaction set to Trs.

Anyone know how to fix this error?
Thanks in advance.
« Last Edit: January 26, 2022, 03:21:06 am by incendio »

incendio

  • Full Member
  • ***
  • Posts: 157
Re: IBX 2.4.3 : Error, Transaction not assigned
« Reply #1 on: January 26, 2022, 03:20:22 am »
Found the problem !

On previous codes, I have a database on datamodule, without a transaction.

Add a transaction to datamodule and set default database to database in that datamodule seem solved the problem.

tonyw

  • Sr. Member
  • ****
  • Posts: 257
    • MWA Software
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #2 on: January 27, 2022, 05:01:36 pm »
As they say, the clue was in the Error Message  :)

A quick heads up: the next version of IBX is in beta and will feature support for Firebird server side User Defined Routines (UDRs). This will allow the implementation of Firebird Functions, Procedures and Triggers in a library (dll or .so) written entirely in Pascal.

incendio

  • Full Member
  • ***
  • Posts: 157
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #3 on: January 28, 2022, 12:18:32 am »
As they say, the clue was in the Error Message  :)

A quick heads up: the next version of IBX is in beta and will feature support for Firebird server side User Defined Routines (UDRs). This will allow the implementation of Firebird Functions, Procedures and Triggers in a library (dll or .so) written entirely in Pascal.
Good to hear it, thanks.

datiscum

  • New member
  • *
  • Posts: 5
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #4 on: January 31, 2022, 08:36:15 am »
A Linux UDR library for Firebird should be forgotten very quickly. When you have read this, you see the pitfalls of the whole thing.

https://gitlab.com/freepascal.org/fpc/source/-/issues/39531


tonyw

  • Sr. Member
  • ****
  • Posts: 257
    • MWA Software
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #5 on: February 01, 2022, 12:31:15 pm »
A Linux UDR library for Firebird should be forgotten very quickly. When you have read this, you see the pitfalls of the whole thing.

https://gitlab.com/freepascal.org/fpc/source/-/issues/39531

Your post is interesting. I have yet to see the problem with Pascal UDRs that you are reporting. Perhaps you would like to try out the current beta version that is available at

https://svn.mwasoftware.co.uk/viewvc/public/ibx/branches/udr/

There is a UDR user guide in the doc folder.

In the udr/testsuite/udrlib folder you will find a ready made example UDR complete with SQL scripts to add the test functions, procedures and triggers to a DB and to then to exercise their use. Some of the examples assume the Firebrd example employee database. There is also a runtest.sh script to automate the whole compile - install - test cycle. But that does assume a specific firebird installation in /opt (on Linux of course).
It would be interesting to know if you can duplicate your problem.

SIGSEGV signals are a general problem, as you observe. In testing they have occurred whenever you get a bad memory reference and can crash the process. Firebird SuperClassic seems to be best here. When writing a UDR, you do have to be extra careful to avoid these by being paranoid when it comes to checking pointers and object references.

Exception handling in the UDR is something that I have paid considerable attention to. All calls the UDR library are protected within try..except blocks so that Pascal Exceptions can be translated into Firebird status vectors and thus returned to the client.

You are having a specific problem on UDR unload. I am wondering if your problem is with the very Firebird specific unload mechanism. You need to emulate the C++ static class "UnloadDetector". This does sound like where your problem may be. In my UDR implementation, the TFBUDRController class includes this functionality and seems to work well.

datiscum

  • New member
  • *
  • Posts: 5
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #6 on: February 02, 2022, 10:08:00 am »
A Linux UDR library for Firebird should be forgotten very quickly. When you have read this, you see the pitfalls of the whole thing.

https://gitlab.com/freepascal.org/fpc/source/-/issues/39531

Your post is interesting. I have yet to see the problem with Pascal UDRs that you are reporting. Perhaps you would like to try out the current beta version that is available at

https://svn.mwasoftware.co.uk/viewvc/public/ibx/branches/udr/

There is a UDR user guide in the doc folder.

In the udr/testsuite/udrlib folder you will find a ready made example UDR complete with SQL scripts to add the test functions, procedures and triggers to a DB and to then to exercise their use. Some of the examples assume the Firebrd example employee database. There is also a runtest.sh script to automate the whole compile - install - test cycle. But that does assume a specific firebird installation in /opt (on Linux of course).
It would be interesting to know if you can duplicate your problem.

SIGSEGV signals are a general problem, as you observe. In testing they have occurred whenever you get a bad memory reference and can crash the process. Firebird SuperClassic seems to be best here. When writing a UDR, you do have to be extra careful to avoid these by being paranoid when it comes to checking pointers and object references.
Quote
Unfortunately, the part of the UDR that depends on FPC itself cannot be influenced. If a member of the FPC team already admits that it is impossible to get the internal memory management TLS in FPC under control with external threads under Linux, then my tests could also confirm this. If you have read the ticket "https://gitlab.com/freepascal.org/fpc/source/-/issues/39531", it should be clear that there is no chance of success. My C/C++ UDF works fine and also the unloading does not cause any problems.

This is how a test should look like:
Runtime problems only occur in my UDF/UDR if several connections have called the same function. Test your UDR/UDF with 20 connections at the same time and see what happens. Create a "StoredProcedure" in which you call three of your functions. Then call this "SP" in a test program 10.000 times. That will still work. But if you now run 20 instances of the test program simultaneously, it will simply crash the Firebird in "SuperServer" mode. But with the C++ UDF it works fine. Maybe it will work in "Classic" mode, where a separate process is used for each connection. But these are limitations that are not acceptable. Either it works 100% or I leave it and use C++.
 


Exception handling in the UDR is something that I have paid considerable attention to. All calls the UDR library are protected within try..except blocks so that Pascal Exceptions can be translated into Firebird status vectors and thus returned to the client.

You are having a specific problem on UDR unload. I am wondering if your problem is with the very Firebird specific unload mechanism. You need to emulate the C++ static class "UnloadDetector". This does sound like where your problem may be. In my UDR implementation, the TFBUDRController class includes this functionality and seems to work well.

tonyw

  • Sr. Member
  • ****
  • Posts: 257
    • MWA Software
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #7 on: February 02, 2022, 10:32:15 am »
Unfortunately, the part of the UDR that depends on FPC itself cannot be influenced. If a member of the FPC team already admits that it is impossible to get the internal memory management TLS in FPC under control with external threads under Linux, then my tests could also confirm this. If you have read the ticket "https://gitlab.com/freepascal.org/fpc/source/-/issues/39531", it should be clear that there is no chance of success. My C/C++ UDF works fine and also the unloading does not cause any problems.

This is how a test should look like:
Runtime problems only occur in my UDF/UDR if several connections have called the same function. Test your UDR/UDF with 20 connections at the same time and see what happens. Create a "StoredProcedure" in which you call three of your functions. Then call this "SP" in a test program 10.000 times. That will still work. But if you now run 20 instances of the test program simultaneously, it will simply crash the Firebird in "SuperServer" mode. But with the C++ UDF it works fine. Maybe it will work in "Classic" mode, where a separate process is used for each connection. But these are limitations that are not acceptable. Either it works 100% or I leave it and use C++.
 
In response:
1. A bug is no more than a problem waiting to be fixed and is not a reason to say that you should never even attempt to write a UDR in Pascal.

2. Have you duplicated the same problem with Delphi? If the same code works with Delphi then you have a good reason to blame FPC.

3. Have you set up a standalone demonstration of the problem? If this is genuinely a problem with try..finally, shared libraries and multiple threads then you should be able to duplicate the problem outside of Firebird. Indeed, this would give the FPC devs a good handle on the problem.

4. My personal preference is for Firebird SuperClassic over SuperServer and hence if this is a actual bug and SuperClassic provides a workaround then why not just say that SuperClassic is the only supported mode until the bug is fixed?

5. I will try and stress test the IBX UDR support package under both FPC and Delphi (both are supported) to see if I can see the same problem.


datiscum

  • New member
  • *
  • Posts: 5
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #8 on: February 02, 2022, 11:07:32 am »
Unfortunately, the part of the UDR that depends on FPC itself cannot be influenced. If a member of the FPC team already admits that it is impossible to get the internal memory management TLS in FPC under control with external threads under Linux, then my tests could also confirm this. If you have read the ticket "https://gitlab.com/freepascal.org/fpc/source/-/issues/39531", it should be clear that there is no chance of success. My C/C++ UDF works fine and also the unloading does not cause any problems.

This is how a test should look like:
Runtime problems only occur in my UDF/UDR if several connections have called the same function. Test your UDR/UDF with 20 connections at the same time and see what happens. Create a "StoredProcedure" in which you call three of your functions. Then call this "SP" in a test program 10.000 times. That will still work. But if you now run 20 instances of the test program simultaneously, it will simply crash the Firebird in "SuperServer" mode. But with the C++ UDF it works fine. Maybe it will work in "Classic" mode, where a separate process is used for each connection. But these are limitations that are not acceptable. Either it works 100% or I leave it and use C++.
 
In response:
1. A bug is no more than a problem waiting to be fixed and is not a reason to say that you should never even attempt to write a UDR in Pascal.

2. Have you duplicated the same problem with Delphi? If the same code works with Delphi then you have a good reason to blame FPC.
Quote
I don't use Delphi.
I'm not blaming FPC, a core developer is just clearly saying that he doesn't see a way to make it work in FPC and blaming it on "glibc".

3. Have you set up a standalone demonstration of the problem? If this is genuinely a problem with try..finally, shared libraries and multiple threads then you should be able to duplicate the problem outside of Firebird. Indeed, this would give the FPC devs a good handle on the problem.
Quote
At the time I thought it was the "try/finally" because it directly caused the error. In the meantime, it has become clear that it is a fundamental problem.


4. My personal preference is for Firebird SuperClassic over SuperServer and hence if this is a actual bug and SuperClassic provides a workaround then why not just say that SuperClassic is the only supported mode until the bug is fixed?

5. I will try and stress test the IBX UDR support package under both FPC and Delphi (both are supported) to see if I can see the same problem.
Quote
It would be very nice if it worked, but I don't believe in it any more. If you have tested it successfully, please let me know.
« Last Edit: February 02, 2022, 05:44:00 pm by datiscum »

PascalDragon

  • Hero Member
  • *****
  • Posts: 3998
  • Compiler Developer
Re: [SOLVED] IBX 2.4.3 : Error, Transaction not assigned
« Reply #9 on: February 02, 2022, 01:25:05 pm »
@datiscum: can you please fix the quotes in your post? Right now it's very hard to see what is yours and what is tonyw's. The general structure should be like this:

Code: [Select]
[quote by user x part 1]

[/quote]

Your response 1

[quote by user x part 2]

[/quote]

Your response 2

 

TinyPortal © 2005-2018