cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How do I simulate assertions with SQL Anywhere 16?

Breck_Carter
Participant
5,171

I want test the behavior of various dbsrv16 -ufd option settings when server-level and database-level assertions occur.

I don't care what the assertion codes are, so fakes are OK.

View Entire Topic
MarkCulp
Participant

One way to generate assertions would be to create a database and then corrupt it by changing the checksum on one of the database pages.

WARNING: DO NOT DO THIS ON ANY DATABASE WITH REAL DATA !!

dbinit bad.db
perl corrupt_the_database.pl bad.db

where corrupt_the_database.pl is the perl script containing:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#
# Corrupt the checksum on page 3 of a SQL Anywhere database
# !! USE WITH EXTREME CARE !!
#
chmod( 0777, $ARGV[0] );
open( FOO, "+<$ARGV[0]" ) || die $?;
binmode( FOO );
seek( FOO, 3*4096-4, 0 ) || die $?;
print( FOO '\\0\\0\\0\\0' ) || die $?;
seek( FOO, 0, 2 );
close( FOO );

When you start the database on bad.db (e.g. "dbeng16 bad.db") the server will generate a "Checksum failure" assertion.

Breck_Carter
Participant
0 Likes

Presumably, that is a permanent error condition. Is there any way to cause a transient assertion, one that would allow dbsrv16 -ufd restart to successfully restart the database?

MarkCulp
Participant
0 Likes

Yes, the corrupted checksum failure would be a permanent condition and therefore the restart attempt would fail.

I do not know of any publicly available way of causing a temporary assertion.

Perhaps one way would be to create a user table, put some data in it, add an index, shutdown the database, and then corrupt the index using a method similar to the above process. Starting the database on such a table would succeed but accessing the table may cause an assertion if the corruption was "just right". Again this type of corruption would be permanent but the restart of the database would succeed.

Breck_Carter
Participant
0 Likes

Soooo... a valuable new feature exists with no way to prove it... 🙂

MarkCulp
Participant

Well, we've proved it in house... but I'm working on a method for you to prove it to yourself... give me a few more minutes days.

Breck_Carter
Participant
0 Likes

Take all the time you need, take weeks!


Re How do I simulate assertions with SQL Anywhere 16