ASE 15 stored procedure “sp_tables” doesn’t work with SQL UDFs

ASE, Sybase 2 Comments »

The ASE 15 stored procedure sp_tables doesn’t work with SQL UDFs. sp_tables has the udfs coming back as system tables.

repro:
1) create a sql udf in a db
2) run sp_tables, you will see the UDF as a “SYSTEM TABLE”

DBADEV1.sybase_dba.1> sp_tables;
table_qualifier table_owner table_name table_type remarks
--------------- ----------- ---------- ---------- -------
sybase_dba dbo DATE_FORMAT SYSTEM TABLE NULL

In the above example, the DATE_FORMAT UDF is the one at Porting MySQL’s date_format function to Sybase ASE 15.0.2

I’ve opened a case with Sybase to get this fixed - I’ll post the CR # when I get it.

UPDATE:  Sybase assigned CR 497173 to this :)

Listen to this podcast Listen to this podcast

Duplicate rows in sysusers??

ASE, Databases, Sybase No Comments »

If you’re like me, you’ve run into lots of different issues with the Sybase ASE DBMS over the years. Today, Drew Montgomery looked at what happens when the 12.5.x -> 12.5.4 upgrade goes bad:

If you receive the 8419 error on sysusers after applying ASE 12.5.4 (or any other upgrade for that matter) such as the following:

01:00000:00472:2007/12/10 14:46:03.86 server Error: 8419, Severity: 20, State: 3
01:00000:00472:2007/12/10 14:46:03.86 server Could not find index descriptor for objid 10, indid 3 in dbid 13.
01:00000:00472:2007/12/10 14:46:03.88 kernel ************************************
01:00000:00472:2007/12/10 14:46:03.88 kernel SQL causing error : select * from sysusers
01:00000:00472:2007/12/10 14:46:03.88 kernel ************************************
01:00000:00472:2007/12/10 14:46:03.88 server SQL Text: select * from sysusers
01:00000:00472:2007/12/10 14:46:03.89 kernel curdb = 13 tempdb = 9 pstat = 0×10000
01:00000:00472:2007/12/10 14:46:03.89 kernel lasterror = 8419 preverror = 0 transtate = 1

Fear not because Drew has you covered with a simple script that will fix the problem. Note that it involves a dump and load of the affected database but you could just restart the ASE server if you don’t mind the down time:

SP_CONFIGURE "allow updates", 1
go
USE db_with_8419
go

SELECT * INTO tempdb..temp_sysusers FROM sysusers
go

SELECT uid, cnt= COUNT(*)
  INTO tempdb..temp_uid
  FROM tempdb..temp_sysusers
 GROUP BY uid
 HAVING COUNT(*) > 1
go

SELECT s.uid, s.suid
  INTO tempdb..temp_fixuid
  FROM tempdb..temp_sysusers s, tempdb..temp_uid t
 WHERE s.uid = t.uid
go

SELECT uid, MIN(suid) suid
  INTO tempdb..temp_rmuid
  FROM tempdb..temp_fixuid
 GROUP BY uid
go

DELETE tempdb..temp_fixuid
  FROM tempdb..temp_fixuid f, tempdb..temp_rmuid r
 WHERE f.uid = r.uid
   and f.suid = r.suid
go

ALTER TABLE tempdb..temp_fixuid ADD cntr INT IDENTITY
go

DECLARE @max_uid INT
SELECT @max_uid = MAX(uid)
  FROM tempdb..temp_sysusers
 WHERE suid > 16300

UPDATE sysusers
   SET uid = @max_uid + cntr
  FROM sysusers s, tempdb..temp_fixuid f
 WHERE s.uid = f.uid
   and s.suid = f.suid
go

USE master
go

DUMP DATABASE db_with_8419 TO "compress::N::/DumpLocation/dumpfilename.dmp"
go
LOAD DATABASE db_with_8419 FROM "compress::/DumpLocation/dumpfilename.dmp"
go
online DATABASE db_with_8419
go

SP_CONFIGURE "allow updates", 0
go

Bau-jen Liu over at Sybase came up with the following method but it does require rebooting ASE twice:

SP_CONFIGURE "allow updates", 1
go
UPDATE ..sysobjects
SET sysstat = 115, type = "U"
WHERE name = "sysusers"
go

Shutdown ASE, reboot, and log back in as a user with sa_role.

USE dbname
go

CREATE UNIQUE INDEX ncsysusers2 ON sysusers(uid)
go

The above CREATE INDEX command may fail due to the presence of duplicate key rows in sysusers. If this occurs, recreate the index as non-unique first:

CREATE INDEX ncsysusers2 ON sysusers(uid)
go

Now identify any duplicates that may exist in sysusers:

SELECT uid, name, COUNT(*)
FROM sysusers
GROUP BY uid
HAVING COUNT(*) > 1
go

Remove any duplicates found using the DELETE command and try the CREATE INDEX again:

CREATE UNIQUE INDEX ncsysusers2 ON sysusers(uid)
go

Now, clean up after yourself:

UPDATE ..sysobjects
SET sysstat = 113, type = "S"
WHERE name = "sysusers"
go

SP_CONFIGURE "allow updates", 0
go

Sybase has created bug # 298620 for this issue.

Listen to this podcast Listen to this podcast

Sybase Replication Server: Out of Mutexes? wtf?

Databases, Replication Server, Sybase No Comments »

For those of us that use Sybase’s Replication Server, we have long ago been pacified into believing that there really isn’t much that can be done with Replication Server’s quirks but to endure them.

In today’s edition of the Sybase RepServer Quirks we take a look at the “out of mutexes” error.  A mutex is an exclusive lock on a resource.  If you receive an error about RepServer running out of mutexes, you just don’t have enough defined through RepServer.  Simple huh?

Of course it is.  Ahh..  but then how do how many mutexes your particular Sybase RepServer needs?  How many grains of sand are on the moon?  According to Sybase you should know this already but since you can’t read minds (I hope you can’t because I’m thinking of donuts and not RepServer), I’ll pass on what Sybase is saying when pressed about it (Greg Carter @ Sybase):

> Just to elaborate a bit more on this question of the number of mutexes; as
> you probably know the mutex requirements for RepServer increased
> dramatically with the SMP feature. I have since struggled to come up with a
> formula for estimating mutex requirements so that you may properly set the
> “num_mutexes” configuration. While in the latest iteration of this formula
> I have satisfied myself that all mutexes have been accounted for, still the
> estimate it provides seems to fall short in some cases.
>
> Recent investigations by Connectivity seem to indicate that the problem may
> not be with sizing mutex requirements, but rather with sizing message queue
> (”num_msgqueues”) requirements. It appears that Open Server may be using
> the total of the settings for “num_mutexes” and “num_msgqueues” as the
> upper bound for the creation of these two objects together. So it may be
> that even though “num_mutexes” has been sized properly, if “num_msgqueues”
> is too low then you may see a message regarding the failure to create a
> mutex or the failure to create a message queue depending on which one was
> being created at the time that upper bound was surpassed.
>
> The moral here is that until Open Server resolves this issue you need to
> verify the sizing of both “num_mutexes” and “num_msgqueues” in the event
> that either error message appears since you can not rely on the message to
> indicate which one is low.
>
> For your convenience I’ll include here the latest formulas for estimating
> mutex and message queue requirements. Note that the one for mutexes may not
> agree completely with the one that is given in the 12.6 SMP White Paper - I
> have not compared them.
>
> Mutex requirements for the optimized binary:
> num_mutexes = 75 + Num(partitions) + 4*Num(DSI/S) + 3*Num(DSI/E) +
> 2*Num(Dist) + 2*Num(RepAgent Exec) + 2*Num(RSI User) + 5*Num(Queues) +
> 5*Num(SQT Cache) + Num(rs_subscriptions rows) + Num(RSSD tables) +
> Setting(cm_max_connections) +
> 2*MAX(Admin connections) + 2*Num(Other Connections) + Num(Origins) +
> 2*Num(Threads) + MAX(subscription (de)mat)
>
> Where
> - “Other Connections” are connection to this RepServer including ID Server
> connections, RSM connections, etc.
> - “Origins” are the different origins (or primary databases) that could
> possibly have transactions flowing through this RepServer, whether by a
> RepAgent or by a route (intermediate included)
> - “Threads” includes every thread RepServer may start. These are the
> “Global” thread, the “Initialization” thread, threads for each of the
> daemons (dAIO, dCM, dVersion, dRec, dSub, dStats, dAlarm), RepAgent User
> threads, SQM Writer threads, SQT threads, Distributor threads, DSI/S and
> DSI/E threads, RSI User and RSI threads.
> - “subscription (de)mat” is the number of asynchronous subscription
> management requests for materializing or dematerializing that may be taking
> place at any moment.
>
> Note: For the diagnostic binary you will need to double the figure
> determined with the above formula.
>
> Message queue requirements for the optimized and diagnostic binary:
> num_msgqueues = 10 + Num(DSI/S) + Num(DSI/E) + Num(Queues) + Num(Dist)
>
> Thanks,
> G.Carter

Neither this explanation or the two equations are anywhere in the manuals.  I’ve opened feature request 485482 for RepServer to handle this automagically as there really is NO NEED for a RepServer admin to have to worry about this.  If you are or ever have run into this problem, give Sybase a holler and tell them to fix this bug.

Listen to this podcast Listen to this podcast

Sybase ASE: 17283 error when trying to extend a database segment?

ASE, Databases, Sybase 1 Comment »

Did you ever receive the error 17283 “Procedure ’sp_extendsegment’, Line 182 ‘tempdev1′ is reserved exclusively as a log device.” error? You can get the 17283 error when there is a device fragment that contains only the log segment. Part of the problem is when you extend the log segment onto a device, it will usually drop all other segments so it becomes ‘log only’.

 device_fragments               size          usage                created             free kbytes
 —————————— ————- ——————– ——————- —————-
 master                                8.0 MB data and log         Dec 16 2004  4:09AM             3376
 tempdev1                           1024.0 MB data and log         Dec 16 2004  7:02AM          1044480
 tempdev1                            256.0 MB data and log         Mar  9 2005 10:49AM           261120
 tempdev1                            256.0 MB log only             Mar  9 2005 10:54AM not applicable
 tempdev1                            488.0 MB data and log         Mar  9 2005 12:10PM           497760
 tempdev1                            256.0 MB data and log         Mar 11 2005  2:03PM           261120
 tempdev1                            244.0 MB data and log         Mar 11 2005  3:09PM           248880
 tempdev1                            200.0 MB data and log         Jun  1 2005 12:33PM           204000
 tempdev1                            200.0 MB data and log         Jul  8 2005  2:55PM           203808
 tempdev1                            200.0 MB data and log         Jul 21 2005  2:54PM           204000
 tempdev1                           1000.0 MB data and log         Feb  6 2006  1:11PM          1020000

So, how to fix this? Well, Sybase doesn’t provide any way to do so without modifying the system tables.

USE master
EXEC SP_CONFIGURE "allow updates", 1
go
BEGIN TRAN
go
– since we are dealing with tempdb and we want data and log on all the device fragments, we can make a blanket update.  We would make the update more selective if we had other requirements (update only one row or something)
UPDATE sysusages SET segmap = 7 WHERE dbid = DB_ID("tempdb")
go
– if the number of rows updated exceed the number of rows for the database, issue a ‘rollback’
SELECT segmap FROM sysusages WHERE dbid = DB_ID("tempdb")
go
– all good?  if so, issue a ‘commit’
COMMIT TRAN
go
EXEC SP_CONFIGURE "allow updates", 0
go
– Now that the system table is updated, we need to refresh the dbtable memory structure so that the changes we made become ‘live’
DBCC dbrepair(tempdb, remap)
go

That’s it! It’s fixed and running with the segmaps without having to restart ASE. Wasn’t that easy?

Listen to this podcast Listen to this podcast

ASE 12.5.x (64bit) and ASE 15 fail to start using GLIBC

ASE, Linux, OS, Sybase 7 Comments »

If you are going to be using ASE 12.5 or ASE 15 with the upcoming Red Hat Enterprise Linux 5.0, there are two CRs that you need to know about:

  1. CR 450004 - XP Server and Backupserver (64bit)
  2. CR 432482 - ASE 15

The problem is the result of using the jmp() and longjmp() functions in the GNU C Library version 2.4 (glibc 2.4).

setjmp() and longjmp() are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. setjmp() saves the stack context/environment in env for later use by longjmp(). The stack context will be invalidated if the function which called setjmp() returns.

Starting in glibc 2.4, the jmpbuf is unavailable due to a security exploit known for several years.  Restricting access to the jmpbuf was an effort by the glibc maintainers to ‘close this hole’ by forcing the application writers to use the sigsetjmp() and siglongjmp() instead.

The problem with using sigsetjmp() and siglongjmp() is that they aren’t thread safe.  This is supposed to be fixed in glibc 2.6 according to a contact at Sybase but Sybase *does* have a workaround for this issue and will be putting it into the ASE v15 codeline when they perform the RHEL 5 certification sometime next year.

I wasn’t able to find much information the supposed exploit.  I only found a few newsgroup posts that didn’t provide any details.

Read the rest of this entry »

Listen to this podcast Listen to this podcast
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in
Close
E-mail It