on 2011 Mar 16 6:01 PM
I'm about to automate a SQL Remote setup migration process. Say, the manual process is well-understood.
One necessary step according to the docs is to note the ending offset of the database's current transaction log file.
That must be done on a shutdown database.
What's the best way to do this automatically?
Transaction log starting offset is 0001086520
SQL Remote truncation offset is 0001104772
Transaction log current relative offset is 0000000000
Is there an easier way to get the precise number of this offset, or do I need to do some kind of (error-prone) text parsing?
Request clarification before answering.
So in the end, based on Jason's and John's (somewhat contradictory) answers, it seems that
(As I understand, one should migrate cleanly shut down databases, and then the output of DBTRAN and DBLOG should match w.r.t. to ending offset.)
Just to add: "derwin" has added a comment on DCX for the referenced page:
The documentation is correct as it stands in that using the dbtran utility is the most reliable way to obtain the accurate ending log offset for the database's current transaction log file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) I don't know why the doc. recommends dbtran. It seems to me that dblog gives the same info., and should do it faster, especially for large logfiles. You have to use dblog to zap the offsets anyway, so why not use it to get them as well
2) The offset information is only dumped out as part of the message callback functions, so yes, you will have to parse those messages to get this information. It might be worth posting an enhancement request to expose a "GetLogInfo()" function in the dbtools api that returns this information specifically, or that the DBChangeLogName() function return this information in a more easily processed way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I agree that starting the database to query it for log offsets is not a good idea. The log offset information will change - at a minimum the server does a checkpoint on shutdown, which will advance the ending log offset.
You could figure out what that adds to the log and add it to the result of your query, but there is no guarantee this value is constant, or that the server won't do other things (like more than one checkpoint), advancing the log further.
dblog essentially reports the expected "start" log position for a database. This is the offset at which recovery would begin if recovery were needed. For a cleanly shutdown database, it is also the offset of the end of the last log.
dbtran returns the end offset for the given log. For a database which did not shutdown cleanly, the log end offset can only be determined by parsing the log since the last log operation may only have been partially written.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The dblog utility will give you the information you need. This uses the DBChangeLogName() function. However, you may still have to do some parsing to get the actual number.
eg.
[C:temp]dblog test.db
SQL Anywhere Transaction Log Utility Version 12.0.0.2566
"test.db" is using log file "test.log"
"test.db" is using no log mirror file
Transaction log starting offset is 0000495001
Transaction log current relative offset is 0000004142
[C:temp]dblog test.log
SQL Anywhere Transaction Log Utility Version 12.0.0.2566
File "test.log" is a transaction log file
File version is 41
Log starts at offset 0000495001
Log ends at offset 0000499143
Log contains 80 pages with a page size of 4096 bytes
4142 bytes in use (1.26%), 323538 bytes free (98.74%)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now I'm somewhat puzzled:
The according doc recommends DBTRAN to get the ending offset, not DBLOG (though the values should be the same). Which is preferable? (Of course, I'm using DBTRAN > NUL as I'm not interested in the translated log contents at all.)
So you say there's no way to get these offset numbers without parsing?
User | Count |
---|---|
82 | |
29 | |
9 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.