Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB2 API is returning error -2546 #48

Closed
hsc2013 opened this issue Jun 15, 2022 · 8 comments
Closed

DB2 API is returning error -2546 #48

hsc2013 opened this issue Jun 15, 2022 · 8 comments

Comments

@hsc2013
Copy link

hsc2013 commented Jun 15, 2022

I am trying to perform redirected restore and restore API is returning sqlcode -2546 on the AIX 7.2 environment. I am passing db2 version 11.1.0.0 to the API while restoring. I am running on db2 version DB2 v11.1.1.1.

I am not sure why restore API is returning -2546 error on the AIX environment. Also, I could not see what is error code -2546. Can you please help me to resolve this?

FUNCTION: DB2 UDB, database utilities, sqludMRResponse, probe:1136
DATA #1 : Sqlcode, PD_TYPE_SQLCODE, 4 bytes
-2546
DATA #2 : Hexdump, 0 bytes
Object not dumped: Address: 0x0A0002001AC6E6B0 Size: 0 Reason: Zero-length data

@kdrodger
Copy link
Member

The SQL code descriptions are all available online, or through the Db2 command line processor (CLP).

https://www.ibm.com/docs/en/db2/11.5?topic=messages-sql2500-sql2749#sql2546n

$>  db2 \? sql2546n


SQL2546N  The image on media "<media>" is not the first in sequence from
      the backup or copy.

Explanation:

During restore or load recovery, the first image from the backup or copy
must be processed first. The image found on the media is not the first
in sequence.

The utility waits for a response to continue.

User response:

Mount the media with the correct backup or copy image and return to the
utility with the correct caller action parameter to indicate if
processing should continue or terminate.

@hsc2013
Copy link
Author

hsc2013 commented Jun 16, 2022

Thanks! for this. Any guess why restore API is giving an error? Actually, restore on the source machine is working but whenever we are trying to restore the same backup image on the destination machine it fails with a -2546 error. We are using the same db2 version on the source and destination machine but AIX's service pack level/Technology level is different.

Source machine oslevel -r 7200-03
Destination machine oslevel -r 7200-04

Is this error coming because OS level is not the same on both AIX machines?

@kdrodger
Copy link
Member

It means what the message says, that if you've created a backup that is split into multiple pieces (multiple paths, storage manager sessions, tapes, etc.) then the image numbered .001 must be the first encountered during the restore process. The message is saying that no, in your case the first encountered was another file of the overall backup image.

In a trivial example, like this, it can be recreated by specifying paths out of order:

> mkdir dirA

> mkdir dirB

> db2 backup db sample to ~/dirA, ~/dirB

Backup successful. The timestamp for this backup image is : 20220616140100

>  ls dirA dirB
dirA:
SAMPLE.0.krodger.DBPART000.20220616140100.001

dirB:
SAMPLE.0.krodger.DBPART000.20220616140100.002

> db2 restore db sample from ~/dirB, ~/dirA replace existing without prompting

SQL2546N  The image on media "/home/krodger/dirB" is not the first in sequence 
from the backup or copy.

> db2 restore db sample from ~/dirA, ~/dirB replace existing without prompting

SQL2540W  Restore is successful, however a warning "2539" was encountered 
during Database Restore while processing in No Interrupt mode.

@hsc2013
Copy link
Author

hsc2013 commented Jun 22, 2022

Thanks! but this issue is coming when we are using DB2 C API to restore for command-line backup. Command-line backup and command-line restore are working perfectly. The issue is only with restore API when trying to restore the command-line backup using DB2 C API. Do I need to add a special flag for restoring through db2 C API?

@kdrodger
Copy link
Member

kdrodger commented Jul 5, 2022

The Db2 command line (CLP) uses the same APIs so it's definitely possible to do this successfully. What are your API parameters, how many sequences (backup image files) do you have, and where do they reside?

@hsc2013
Copy link
Author

hsc2013 commented Jul 6, 2022

In API Parameters I am giving below things.

DB2 version(11.1.0.0), db2RestoreStruct and sqlcode. I am splitting the backup image into 2 parts and they reside on some storage machine.

@kdrodger
Copy link
Member

kdrodger commented Jul 6, 2022

It will help if you can be even more specific. How are you filling out the fields of the db2RestoreStruct, especially the piMediaList as well as the contents of its associated structure.

Those structures and parameters should point to the location of your backup image(s), and the order in which the paths are listed matters as it ensures that backup image sequence .001 can be found first by the restore utility.

@hsc2013
Copy link
Author

hsc2013 commented Jul 19, 2022

Thanks! will check it

@hsc2013 hsc2013 closed this as completed Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants