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

New Feature in Informix Version-15-> Informix CDC on Secondary in Informix Ver 15.0.0.1

By Gaurav Kumar posted 8 days ago

  

With Informix version 15, customers can now move their existing CDC applications from the Primary to Secondary servers. They can also create new CDC applications and run them directly on the Secondary.

With Informix version 15.0.0.1, you can use Informix Change Data Capture (CDC) on secondary servers. Specifically, the CSDK enhancements introduced in this version include support for CDC applications on secondary servers.

I believe the customer can run their CDC application—compiled with CSDK 4.50—against an Informix 15 primary server. However, it likely won't work on a 15 secondary server, as "CDC on Secondary" requires both server and CSDK enhancements. While a 4.50 client can connect to a 15 server, it lacks the necessary updates. So, the application likely needs to be recompiled with CSDK 15, not just use its runtime components.

Dependencies:

·      We assume that both the Primary and Read-Only servers are operational on Informix version 15.0.0.1.

·       We assume your CDC was already running on Primary server in older versions like 12 or 14.

    ·       If you are new to CDC & want to configure CDC, so below is the link on How to configure CDC.

https://www.ibm.com/docs/en/informix-servers/15.0.0?topic=guide-getting-started-change-data-capture-api

·      On secondary TEMPTAB_NOLOG configuration needs to be set to disable logging on temporary tables.

Advantages of running CDC on a secondary but not on the primary are:

·       Offloading primary server workload

·       Efficient resource utilization

·       Incase of primary failover, your cdc application still be connected , so high availability and failover capabilities.

Now on your existing table where the flag is mentioned as “TBLspace flagged for External Log Snooping” is the table where you will start your CDC on Secondary.

> oncheck -pt cdc:test

TBLspace Report for cdc:informix.test

    Physical Address               1:91018

    Creation date                  06/11/2025 12:33:10

    TBLspace Flags                 404000902        Row Locking

                                                    TBLspace flagged for External Log Snooping

                                                    TBLspace contains VARCHARS

                                                    TBLspace uses 4 bit bit-maps

                                                    TBLspace uses large rowids

    Maximum row size               6        

    Number of special columns      1        

So now when you are in $INFORMIXDIR/demo/cdc, you can start the CDC for the table/column

IBM/15.0.0.1/demo/cdc> ./cdcapi -D cdc -T "informix.test" -C "name" -f cdclogs.out

Connected to syscdcv1@ids_gk_hdr

CDC_OPENSESS for server ids_gk_hdr with  Timeout 300 Max recs per read 1

Enable for full row logging on Table 'cdc:informix.test'

CDC_STARTCAPTURE of cdc:informix.test on session 192413735

CDC_ACTIVATESESS on  192413735

Start Reading the log records...

bytesread is 54 loreaderr is 0 SQLCODE 0

Got Record type  CDC_REC_TABSCHEM. Size =   18            TabID : 0

                  Fixed length column size (total) : 0

                  Number of fixed lenth column is 0

                  Number of variable lenth column is 1

                  Schema for Table is: 'name varchar(1,0)'

                  Schema matchs: PASSED

create temp table apitest022467( name varchar(1,0) ) at cdcapi.ec:713

                  Column 0 is name, type = 13, size = 1

drop table apitest022467 at cdcapi.ec:746

A typical IDS-CDC application written in ESQL/C will have the following sequence

$connect to "syscdcv1";

$execute function cdc_opensess(:servname,0,-1,1,1,1) into :sessid;

$execute function cdc_activatesess(:sessid, 0) into :retval;

$execute function cdc_set_fullrowlogging(:tabname,1) into :retval;

$execute function cdc_startcapture(:sessid, 0,:tabname, :colname, 0) into :retval;

while (! Timed_out)

{

read_log_records(sessid); ç uses ifx_lo_read(sessid, …)

}

$execute function cdc_endcapture (:sessid, 0, :tabname) into :retval;

$execute function cdc_set_fullrowlogging(:tabname,0) into :retval;

Majority of code made same for both PRIMARY and SECONDARY for easy maintenance

o   cdc_set_fullrowlogging()

        • o   Same interface in secondary, but ….
        • o   Different internal working in PRIMARY/STANDALONE and SECONDARY
        • o   Must coordinate with PRIMARY to flag LOGFULLROW in the all the partitions used by the table

o   cdc_activatesess(<sessid>, <position>)

        • o   CDC_ACTIVATESESS on  192413735

o   PRIMARY’s current log position is synched to activate session

o   CDC: Log Reader session %u starting to snoop at the %s position, LSN(%d,%x), page %d.

        • o   12:48:03  CDC: Log Reader session 193986599 starting to snoop at the CURRENT PRIMARY LSN position, LSN(13,d73000), page 3443.
        • o   12:48:03  CDC: Log Reader started.  CDC session id 193986599. SQL session id 370.

Each CDC session will have 2 threads on Secondary

·       Onstat –g ath

o    389      5087c6b0         45f3d330         3    sleeping secs: 4        1cpu         sqlexec

o    390      519031e0         45f3de30         1    sleeping secs: 1        1cpu         cdc_370_193986599

Where the cdc thread is named in the form of cdc_<sqlsessid>_<cdcsessid>”

Now we will update the name column in the test table on the primary server to verify whether the change is reflected in the CDC logs on the secondary."

On Primary:

echo "update test set name='k' where id =2"|  dbaccess cdc

Database selected.

1 row(s) updated.

Database closed.

 

On Secondary

IBM/15.0.0.1/demo/cdc> ./cdcapi -D cdc -T "informix.test" -C "name" -f cdclogs.out

Connected to syscdcv1@ids_gk_hdr

CDC_OPENSESS for server ids_gk_hdr with  Timeout 300 Max recs per read 1

Enable for full row logging on Table 'cdc:informix.test'

CDC_STARTCAPTURE of cdc:informix.test on session 192413735

CDC_ACTIVATESESS on  192413735

Start Reading the log records...

bytesread is 54 loreaderr is 0 SQLCODE 0

Got Record type  CDC_REC_TABSCHEM. Size =   18     TabID : 0

         Fixed length column size (total) : 0

         Number of fixed lenth column is 0

         Number of variable lenth column is 1

         Schema for Table is: 'name varchar(1,0)'

         Schema matchs: PASSED

create temp table apitest022467( name varchar(1,0) ) at cdcapi.ec:713

         Column 0 is name, type = 13, size = 1

drop table apitest022467 at cdcapi.ec:746

bytesread is 40 loreaderr is 0 SQLCODE 0

Got Record type   CDC_REC_BEGINTX. Size =    0 LSN = 13:0xd6e020. TXID = 27

         Time = 2025-06-11 12:41:48

Raw Data:  (0/0x0 bytes at address 0x1d61490)

bytesread is 42 loreaderr is 0 SQLCODE 0

Got Record type    CDC_REC_UPDBEF. Size =    2 LSN = 13:0xd6e060. TXID = 27

         TabID = 0

Raw IUD Data:  (2/0x2 bytes at address 0x1d614a8)

01 67                                           .g

         Column Value = 'g'

bytesread is 42 loreaderr is 0 SQLCODE 0

Got Record type    CDC_REC_UPDAFT. Size =    2 LSN = 13:0xd6e0c4. TXID = 27

         TabID = 0

Raw IUD Data:  (2/0x2 bytes at address 0x1d614a8)

01 6b                                           .k

         Column Value = 'k'

bytesread is 36 loreaderr is 0 SQLCODE 0

Got Record type    CDC_REC_COMMTX. Size =    0 LSN = 13:0xd6e128. TXID = 27

         Time = 2025-06-11 12:41:48

Raw Data:  (0/0x0 bytes at address 0x1d61490)

0 comments
12 views

Permalink