Informix

Informix

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

Drop temp table cause -106 non-exclusive access.

Everett Mills

Everett MillsThu February 20, 2020 10:23 AM

  • 1.  Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 09:33 AM
    Edited by System Admin Fri January 20, 2023 04:33 PM
    Hi All!

    I ran into the next issue:

    I created a temporary table and created a "cursor" on it (foreach or select). If I then want to drop the table, sometimes I get a non-exclusive access error.  
    What could cause my session to not have exclusive access? (I'm thinking about the cursor destroy mechanism cause it)
    Version:
    Informix 14.10.FC3 

    My code:
    create database  if not exists testdb;
    drop procedure if exists temp_test;
    create procedure if not exists temp_test(_repeat integer);
    define i integer;define num integer;
    let i = 0;
    while i < _repeat

    create temp table tmp_test( t_num integer );
    select t_num into num from tmp_test;


    drop table tmp_test;

    let i = i + 1;
    end while;
    end procedure;

    execute procedure temp_test(100000);


    ------------------------------
    Gabor Fekete
    ------------------------------
    #Informix


  • 2.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 10:23 AM

    Try adding WITH NO LOG to the temp table creation.

     

                            --EEM

     






  • 3.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 11:19 AM
    Hi Gabor,

    your code wouldn't reproduce a thing for me, using 14.10.FC3 on Linux, yet
    • I'm not seeing the mentioned cursor in your command sequence
    • there are a few configuration parameters that effect temp table behavior and might be playing a role with you (DBSPACETEMP, dbspaces, TEMPTAB_NOLOG, to name the most importent ones)


    ------------------------------
    Andreas Legner
    ------------------------------



  • 4.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 02:23 PM
    Hi Andreas,

    I checked our onconfig file. I corrected the DBSPACETEMP value but the error still exists.

    I mentioned a select or foreach declare a "cursor" for the execution and i'm thinking the IDS background processes will destroy it. (slowly)
    If we put some slow down code between the select and the drop command. /system(sleep 0.001)/ the error will disappear. 
    ... 
    create temp table tmp_test( t_num integer );
    select t_num into num from tmp_test;

    --something is happening in the IDS background
    drop table tmp_test;
    ... 
    or 
    create temp table tmp_test( t_num integer );
    foreach
    select t_num into num from tmp_test
    --something is happening in the IDS background
    drop table tmp_test;
    end foreach;
    ...

    We have 2 different server. The first error occurs, the second does not.

    1) cpuinfo: model name : Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GH
    "Ubuntu 18.04.3 LTS"

    2) cpuinfo: Vendor=GenuineIntel Model=Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz 
    "CentOS Linux release 7.5.1804 (Core)"




    ------------------------------
    Gábor Fekete
    ------------------------------



  • 5.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 11:51 AM
    Edited by System Admin Fri January 20, 2023 04:28 PM
    Hi Gábor,
    I tested your code with version 14.10.FC3, but the error wasn't reproduced as it was tested by Andreas.
    The -106 error occurs when a DDL(DROP, ALTER..) statement is executed without closing the cursor or statement in another session.
    Is the procedure code used in production? Or is it test code that omits some logic?
    Should the temp table be dropped within the while loop? How about using the DELETE statement instead of DROP statement if the data is repeatedly inserted and deleted in a loop in the temp table?

    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 6.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Thu February 20, 2020 02:23 PM
    Hi,

    We tested the script in 2 different server, the first error occurs (prod enviroment), the second does not (dev enviroment).
    1) cpuinfo: model name : Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz
    "Ubuntu 18.04.3 LTS"
    2) cpuinfo: Vendor=GenuineIntel Model=Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz 
    "CentOS Linux release 7.5.1804 (Core)"

    The code only represents a working principle.The while loop represents as foreach on a customer table. The original code contains a separate procedure for handling the temporary table and we use it more then once. (The procedure leaves no trash behind.) We'll consider rewriting unless otherwise resolved.

    This is my problem:
    The -106 error occurs when a DDL(DROP, ALTER..) statement is executed without closing the cursor (the select/foreach finished) or statement in another session. The temp table is only available in my session. 
    If I put some code after the select/foreach and this code occurs 0.001-0.003 sec {system("sleep 0.001")} delay before a drop statement our code work fine. Our code will slow down a lot after that. (300000 row in the customer table.)




    ------------------------------
    Gábor Fekete
    ------------------------------



  • 7.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Fri February 21, 2020 02:00 AM
    Hi Gábor,
    I ran sleep command inside foreach loop as below but got 106 error. How is it different from yours?
    If you run the drop table outside of the foreach statement, of course there are no errors, but it should probably be handled that way...

    create procedure temp_test(_repeat integer);
    define i integer;
    define num integer;
    let i = 0;
    while i < _repeat
    
    create temp table tmp_test( t_num integer );
    insert into tmp_test values (1);
    foreach select t_num into num from tmp_test
    system 'sleep 5';
    drop table tmp_test;
    end foreach;
    let i = i + 1;
    end while;
    end procedure;
    
    
    
    $ dbaccess testdb -
    
    Database selected.
    
    > execute procedure temp_test(100000);
    
      242: Could not open database table (informix.tmp_test).
    
      106: ISAM error:  non-exclusive access.
    Error in line 1
    Near character position 1
    >​


    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 8.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Fri February 21, 2020 03:11 AM
    Hi Jeong

    Sorry I wrote the example wrong for a foreach. Our foreach end before we want to drop it the temp table. 


    The correct example is this with the whole code.
    drop procedure if exists temp_test2;
    create procedure temp_test2(_repeat integer);
    define i integer;
    define num integer;
    let i = 0;
    while i < _repeat
    create temp table tmp_test( t_num integer ) with no log;

    foreach
    select t_num
    into num
    from tmp_test

    end foreach;

    -- system 'sleep 0.001';
    let i = i + 1;
    drop table tmp_test;

    end while;
    end procedure;

    execute procedure temp_test2(1000000);-- SQL Error (-242) : Could not open database table (informix.tmp_test). [ ISAM error -106 : ISAM error:  non-exclusive access. ]




    ------------------------------
    Gábor Fekete
    ------------------------------



  • 9.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Tue February 25, 2020 03:09 AM
    Hi Gábor,
    I installed informix version 14.10.FC3DE on ubuntu 18.04.4 and centos 7.6 and tested it with the temp_test2 procedure, but the -242 / -106 error was not reproduced.
    I'm sorry it didn't help.
    Have you already contacted IBM?

    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 10.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Tue February 25, 2020 07:43 AM
      |   view attached
    Hi 

    1) Thank you for trying different systems. :)

    2) Yes, I have already contacted IBM. They couldn't reproduce either.
    However, it was possible to trap the -106 / -214 / -242 errors. (onmode -I [errno]). This generate the AF file when was the error occurs.
    I hope they can analyze it soon.

    3) I also tried to move the temp table to another dbspace. Creating the temp table in rootdbs causes the same error.
    4) I upload my latest code.

    I'll let you know what's causing the error if we find out.

    ------------------------------
    Gábor Fekete
    ------------------------------

    Attachment(s)

    txt
    temp_test2.txt   1 KB 1 version


  • 11.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 01:11 AM
    Edited by System Admin Fri January 20, 2023 04:48 PM
    Hi Gábor,
    The information described in IT32027 looks similar to this case.
    http://www.ibm.com/support/docview.wss?uid=swg1IT32027&myns=swgimgmt&mynp=OCSSGU8G&mync=E&cm_sp=swgimgmt-_-OCSSGU8G-_-E

    Based on that, running the procedure with the AUTO_READAHEAD value set to 2,2048 resulted in a 242/106 error.
    The previous setting of 1,128 did not cause the error.

    [informix@db2 skjeong]$ cat proc2.sql
    drop procedure if exists temp_test2;
    create procedure temp_test2(_repeat integer);
    define i integer;
    define num integer;
    let i = 0;
    while i < _repeat
    create temp table tmp_test( t_num integer ) with no log;
    insert into tmp_test values (i);
    
    foreach
    select t_num
    into num
    from tmp_test
    
    update tmp_test set t_num = num*5;
    
    end foreach;
    
    -- system 'sleep 0.001';
    let i = i + 1;
    drop table tmp_test;
    
    end while;
    end procedure;
    
    [informix@db2 skjeong]$ onmode -wf AUTO_READAHEAD=2,4096
    Value for AUTO_READAHEAD (2,4096) was saved in config file.
    Value of AUTO_READAHEAD has been changed to 2,4096.
    [informix@db2 skjeong]$ dbaccess testdb -
    
    Database selected.
    
    > execute procedure temp_test2(1000000);
    
      242: Could not open database table (informix.tmp_test).
    
      106: ISAM error:  non-exclusive access.
    Error in line 1
    Near character position 1
    >
    ​


    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 12.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 11:28 AM
    Hi
    That APAR based on our opened case about this problem. 
    I modified our onconfig parameter tó AUTO_READAHEAD=1,4096 and the error disapear.

    ------------------------------
    Gábor Fekete
    ------------------------------



  • 13.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 11:45 AM
    I had a discussion once with Scott Lashley who designed and wrote the AUTO_READAHEAD management code and he told me, as I have reported to the community before, that one should NEVER use mode '2 - Aggressive readahead' only use mode '1 - Passive readahead'

    I'm guessing that issues like this one are one reason why he said that.

    ------------------------------
    Art Kagel
    ------------------------------



  • 14.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 11:53 AM

    Oh, also I am not a fan of big readahead settings like 1024 or 4096 or more. When I configure a server I set the readahead to 1,64 or 1,32 or even lower. Why? Vis:

    • Your system has smart drives with cache memory on board that are performing readahead
    • Your system or SAN has smart controllers with on board cache memory that are performing readahead
    • The SAN itself had a boatload of cache memory and is smart and is performing readahead
    • Many modern systems are using SSD drives instead of spindles so there is near zero latency and accessing any block on the drive is exactly as fast and any other block on the drive
    With all of that in mind, why in the name of all that is Holy are we wasting Informix buffer cache pages on readahead? I will trade more commonly accessed data in Informix's buffer cache for readahead pages any day because I think that the benefit of readahead in a modern system is nearly zero!

    ------------------------------
    Art Kagel
    ------------------------------



  • 15.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 05:04 PM
    Hi Art,
    Thank you for the advice. I should also review my customers' readahead settings.

    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 16.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 05:07 PM
    It's harder than it used to be. The new RA algorithm does not report most of the used RA pages of different kinds that were not included in RA in the old algorithm so my RAU calculation no longer works. I have an open RFE to exposed the remaining numbers so we can determine the effectiveness of RA and decide whether a particular system needs more RA or less RA.

    Art

    Art S. Kagel, President and Principal Consultant
    ASK Database Management


    Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference.  Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves.








  • 17.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 05:51 PM
    I have already voted on that rfe. I hope that the feature will be adopted in the next version!

    ------------------------------
    SangGyu Jeong
    Software Engineer
    Infrasoft
    Seoul Korea, Republic of
    ------------------------------



  • 18.  RE: Drop temp table cause -106 non-exclusive access.

    Posted Mon March 02, 2020 06:10 PM
    Hi Art,

    We want to take advantage of the readahead parameters during our migration task. Unfortunately, some of these parameters were left in the post-migration user test and this resulted in an error. Based on your suggestions on the production server, you may be skipping the default value of 1,128 or maybe we will set up 1,64.



    ------------------------------
    Gábor Fekete
    ------------------------------