Archive for the Category Linux / Computing

 
 

Heureka, I’ve found it …

Since I’ve build my PC in the beginning of 2008 I’ve been struggling with the disc write performance. Evidence of my problems are these posts: here, here and here and here.

According to the changelogs of the recently released Linux kernels, there were quite a bit of changes in the ext3/ext4 file systems. Therefore in the beginning of October I moved all my file systems from XFS to Ext4 in the hope for things to get better. Once the data was restored the situation was as bad as before, it even felt a bit worse. During this backup and restore process for the first time it dawned on me, that my Samsung F1 hard disk might be the culprit. In particular once I looked at the S.M.A.R.T. data with GSmartControl.

S.M.A.R.T. Data Hardcopy When I looked at the data for the first time after the restore operation, the data looked much than in this screenshot. There recoverd ECC and Soft Errors in 6-7 digit numbers. However never ever did I see that the disk reported an error to the operating system.

And, what I probably should have considered earlier, that the transfer to the external ESATA drive always worked with top performance, the copy back process to the original disk than was awful again. I even went so far to copy the OS to another external USB drive to remove the OS from the equation. I booted from the USB drive and redid the backup and restore operation. Again with the same result, that the Samsung disk showed a very bad write performance. This was when I finally decided to order another hard drive. Tom’s Hardware gave Samsung Spinpoint F3 pretty good marks and that’s the one I ordered then.

Gkrellm Snapshot And what can I say? My problems were gone, completely and utterly gone. Look at the little Gkrellm screenshots on the right. The left half shows the copy process from the old, “bad” disk (top half) to “good” new disk. As you can see, the new disk is even faster than the old one. The right half however shows the copy process from the “good” F3 disk to the “bad”, old F1 disk. Here you can observe the very low write performance of the old F1 disk (top half).

Then I obtained the Samsung hutil disk utility and did a low level reformatting of the old F1 disk and also did self diagnostic with a complete surface scan. Both operation didn’t show any problem whatsoever. I redid some copy operations to the old F1 and the new F3 disks and logged the output from vmstat and created the below diagrams.

Each time the data was copied with the following command line:

tar -c -b 128 -f - source-dir | tar -x --checkpoint=1000 -b 128 -C /destination-dir/

The data was collected with vmstat 10 | tee /tmp/logfile. Roughly 120Gb were transferred.

Optimal Performance Diagram This the diagram for the copy process to the “good” new F3 disk (bi is “block in” for the read op, bo is “block out” for the write op). The source disk was the old F1 disk. The whole process took about 38 minutes. This is the raw text file from the vmstat command. As you can see the read performance of the old F1 disk is perfectly fine.

Bad Performance Diagram And here is the diagram for copy process from the new F3 to the old F1 disk. Simply bloody awful write transfer rate. The whole operation took about 98 minutes. This is the raw text file from the vmstat command. The spikes are probably due to the hard disk write cache. Now wonder, that the whole desktop might get sluggish with such a bad behavior.

I’m so annoyed, that I didn’t draw the right conclusions earlier. I could have spared me more than 1½ year of frustration with Linux in general.

These little (annoying) problems …

SUN Type 6 Keyboard

SUN Type6 Keyboard

In the company I’m using a SUN Type6 USB keyboard. I’ve tried a couple of keyboards, but this still has the nicest feel of them all. The Linux evdev assigns the symbols Super_R (1 in the right picture), Menu (2 in the picture) and ISO_Level3_Shift (3 in the picture) in order to the three key right of the Space key. For me personally the ISO_Level3_Shift is a little bit far to right and I’m missing a right Control key. With Xorg server 1.5.3 I was able to remap the Super_R key to ISO_Level3_Shift and the right most key to Control_R by using setxkbmap and xmodmap.

$ setxkbmap -symbols "pc+de+inet(evdev)+level3(rwin_switch)"
$ xmodmap remapctrl

The file remapctrl contains the lines:

keycode 108 = Control_R Multi_key
clear control
add control = Control_L Control_R

All good and dandy. Then I switched to Xorg server 1.6.3.901-r1 (on Gentoo Linux).

It still sort of works. When I press the remapped ISO_Level3_Shift and “q” on the keyboard I’m getting the expected “@“. The same should be true for the “~” key. However the “~” is a dead key to produce characters like “ã” with two key strokes. Here, the newly remapped ISO_Level3_Shift has no effect and the same with all other dead keys.

When I remap the Menu key to ISO_Level3_Shift however with

$ setxkbmap -symbols "pc+de+inet(evdev)+level3(menu_switch)"

then all the dead keys like “~” work again as expected. I guess to need to fiddle with /usr/share/X11/xkb/keycodes/evdev to get a final fix.

Missing icon in systray

Systray Icons

Some time in the past I switched from Amarok 1.4 to Mpd with the client Gmpc as my preferred music listening solution. Originally the icon in the Xfce4 systray looked ok as on the right side in the picture to the right (the light blue musical note).

After having installed the icon set Tango and after having switched the icon set a couple of times, I ended up with a systray, which looked like the left side in the picture (some generic icon for the Gmpc).

I then went searching, why in some icon sets the Gmpc systray icon was displayed correctly, while in others it was replaced with some generic icon.

After a bit of digging I found, that the Tango icon set, that I installed doesn’t inherit from the icon set hicolor, which appears to be the mother of all icon sets. Gmpc installs its icons in the hicolor directory structure. As I looked at the file /usr/share/icons/Tango/index.theme it read like this:

[Icon Theme]
Name=Tango
Comment=Tango Icon Theme
Inherits=gnome,crystalsvg
Example=x-directory-normal

After I changed “Inherits=gnome,crystalsvg” to “Inherits=hicolor,gnome,crystalsvg” everything looked fine in the systray again.

Wrong framerate on virtual consoles

Again, in the company I inherited a newer flat screen display panel compared to the old one, which had a resolution of 1280×1024. The new one now is capable of 1600×1200 pixels. After reconfiguring /etc/X11/xorg.conf and reboot into the X11 session everything was fine. However, now each time, when I’m shutting down the system or when I switch to one of the virtual Linux consoles, I’m getting an error message from the display, that the vertical and horizontal sync frequencies are out of range. Very annoying.

After some experimentation I have found a workaround. Before shutting down or changing the virtual console, I change the X11 resolution of the X11 server to the 1024×768 size with the key combination CTRL+ALT+Keypad- or CTRL-ALT-Keypad+. I’m wondering, if it has something to do with the fact, that I’m using a Nvidia graphics card. I think a came across similar problem reports in Ubuntu forums, which also mentioned Nvidia cards.

Some additional DB2 notes

In my original article I wrote, that I had some problem with the to_char() function while moving the Oracle database structure to DB2. The problem wasn’t so much about, that to_char() isn’t supported on DB2 (it is, it’s basically the same thing as varchar_formar()), but that the Migration Toolkit had generated a 3 argument version of to_char(), the 3rd argument being some I18N parameter. Apparently, what the MTK deduced from the originating database didn’t fit with DB2 9.7. Anyway, this is probably still a MTK issue.

Working with DB2 for the last weeks has been mostly a pleasant experience. First of all there comes a GUI (db2cc aka the DB2 command center, which is basically a front end to a couple of graphical tools) with the database, which simplifies most administration tasks and which also provides a SQL editor to help with the development of your SQL queries. Therefore you don’t necessarily need any 3rd party software, to make your life easier. Second, if you look up the explanation of a particular SQL error (db2 ? SQL?????N), you will receive helpful suggestions, what might have caused the problem. This was frequently good enough for me to keep going without further reading in any manuals.

However I also have an issues with db2ce, the SQL command editor. When I try to save my developed SQL query to a file only the root (/) directory is offered as the destination location. I was unable to select a different location with the file selection box. If I tried to create a directory within the file selection dialog, I received a SQL22204N error and the dump/db2dasdiag.log file contained the following:

2009-08-25-16.19.31.198185+120 I5362G279          LEVEL: Error
PID     : 27995                TID : 3041135504
FUNCTION: DB2 Tools, DB2 administration server, db2dasFMdirectoryCreate, probe:30
CALLED  : DB2 Common, OSSe, ossDirectoryCreate
RETCODE : ECF=0x90000001 Access denied

Unfortunately there is no indication of the file path, which might cause the error.

The other issue concerns the user administration. I’m trying to give an additional system user access to some tables from the main schema. I’m received a large Java stack trace once I clicked in the respective dialog box to select the tables from the particular schema and I can’t proceed. Something like this:

    ....
    at javax.swing.JComboBox.setEnabled(JComboBox.java:1381)
    at com.ibm.db2.tools.common.AssistCombo.setEnabled(Unknown Source)
    at db2_udb.UserGroupAddObjectDialog.itemStateChanged(Unknown Source)
    at com.ibm.db2.tools.common.AssistCombo.notifyItemListeners(Unknown Source)
    at com.ibm.db2.tools.common.AssistCombo.itemStateChanged(Unknown Source)
    at javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1214)
    at javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1271)
    at javax.swing.JComboBox.contentsChanged(JComboBox.java:1318)
    at com.ibm.db2.tools.common.AssistCombo.contentsChanged(Unknown Source)
    at javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:111)
    at common.JComboBoxModel.setSelectedItem(Unknown Source)
    at javax.swing.JComboBox.setSelectedItem(JComboBox.java:564)
    at com.ibm.db2.tools.common.AssistCombo.setSelectedItem(Unknown Source)
    at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:612)
    at com.ibm.db2.tools.common.AssistCombo.setSelectedIndex(Unknown Source)
    at common.ComboBox.setSelectedIndex(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.jav
    ....

When I’m terminating the db2cc Java even segfaults:

Unhandled exception
Type=Segmentation error vmState=0x00000000
J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001
Handler1=B7D150E5 Handler2=B7DB7A0D InaccessibleAddress=A9824680
EDI=A8B013DC ESI=00000000 EAX=A9824680 EBX=A946787C
ECX=00000000 EDX=A9824680
EIP=AA9149C8 ES=0000007B DS=0000007B ESP=A94676CC
EFlags=00010282 CS=00000073 SS=0000007B EBP=A94676DC
Module=/home/db2inst1/sqllib/lib32/db2jddba
Module_base_address=AA8BE000 Symbol=_ZN13jdbcAEProfileD1Ev
Symbol_address=AA91497C
Target=2_40_20081105_025433_lHdSMr (Linux 2.6.27-gentoo-r8)
CPU=x86 (4 logical CPUs) (0xbe195000 RAM)
----------- Stack Backtrace -----------

I guess I need to check the DB2 forums for some hints.

Originally I installed DB2 on a AMD64 server to get familiar with the software. The actual destination server however was a 32bit Intel box. There is a PDF in the DB2 9.7 documentation set, which describes the various available options. After some fiddling I choose the combination of db2look and db2move to transfer the data.

On the originating host I executed:

db2look -d httpd -z db2inst1 -dp -e -o struc.sql
db2move HTTPD EXPORT -sn DB2\*

Then the data was transferred to the destination host, where I executed the commands

db2 -tvf struc.sql 
db2move httpd import -io insert

to restore the database. The “-io insert” is important here, otherwise you would have received errors in connection with tables, which reference foreign keys.

Otherwise it’s still smooth sailing with DB2.

DB2 Express-C 9.7: very, very cool

I’m using an old Oracle 8i database on a Linux host. I’m running it for the occasional web development. I think I first installed it on SuSE 7.3 or 8.0 system. I think Linux 2.4 was still young at the time and Glibc was probably 2.1 or 2.2. I’ve been moving the DB installation through the various Linux version until today where it still runs just fine on Gentoo Linux with a 2.6.27 kernel and Glibc 2.9. The only problem is, that I need to restart the DB periodically because the initial connection time becomes worse over time.

Anyway since the DB is so old, I’ve finally decided to move the contents to a new database. I could have used MySQL (I’m already using it for other applications), since I don’t really have any particular requirements for the database. However in the end I went for IBM DB2 Express-C 9.7. The database is completely free (of course without support), but is limited to 2 CPU cores and 2Gb of memory. The size of the database(s) is unlimited as compared to the Oracle XE version, which is limited to 4Gb (not that that wouldn’t be enough for me) and only uses 1Gb of memory and one core. I’ve read some good stuff on the Web (here and here) about DB2 and since I’m doing SAP installation with DB2 (and also with MaxDB and Oracle) as a job, I though it would be a good learning vehicle, it I would use DB2 myself for the little development I’m occasional doing. The last thing, that convinced me to use DB2 is the Migration Toolkit, which immensely simplified the move of the data from the source to the target database.

Download the platform archive and the language pack. The installation then is completely painless. Simply execute db2setup. I suggest to use the “Custom” installation option. This directly allows you to select to install the development libraries required for Perl, Python, PHP or Ruby and to install the text-search option. It took a bit to get the (D)atabase (A)dministration (S)erver running. This forum entry was the solution: the DNS entry for the host was missing. I fixed it by adding the hostname as an alias after localhost in the /etc/hosts file.

Next I played with the MTK to transfer the Oracle data to DB2. Biggest obstacle here was, that there was no indication, that the final script for migrating the Oracle data to DB2 didn’t run. The MTK explicitly uses /usr/bin/ksh to invoke the script. The was no indication in the the console window, that the shell couldn’t be started. However, on my Gentoo system, although the pdksh was installed, it didn’t allow the invocation through /usr/bin/ksh. Once I created the a symbolic link, the data was succesfully copied from Oracle to DB2. You have to examine the log files, to see if all database objects from the source database could be created in DB2.

In my particular case I had 3 issues with the conversion. The DB2 script, which creates the database objects, would try to recreate a particular view, which contained a couple definitions like “TO_CHAR(STATUS_SEIT_DATUM, 'yyyy-mm-dd' AS datum“. I had to edit the DB2 script and change these fields to “VARCHAR_FORMAT(STATUS_SEIT_DATUM, 'yyyy-mm-dd' AS datum“. I think, this is an issue, where the MTK could do better. Another issue concerned CLOB columns. The conversion process would recreate an Oracle CLOB column as “CLOB(2G) NOT LOGGED“, which is basically correct, but if you want to move the data later with the db2move command, you are limited to CLOB(1G), because the db2move command has a limitation in this respect. Another issue, I had to consider was due to the move from an ISO-8859-1 character set to Unicode. A column, which is defined as varchar(72) might get wider as 72 character, because typical German umlaut characters (öäüÖÄÜ) take up 2 charcaters. The last issue I experienced was with foreign key constrains. The conversion process drops any foreign key constraints and recreates them after successfull data loading. However my particular data had degenerated over time, so that the recreation of the foreign contraints failed in the final step. Otherwise is was all pretty smooth sailing. BTW, there is an IBM RedBook “Oracle to DB2 Conversion Guide for Linux, UNIX, and Windows“, which details the Oracle-DB2 migration process.

Next step was to install the Perl DBD::DB2 database driver by executing

DB2_HOME=/opt/db2/V9.7 perl Makefile.PL
LD_RUN_PATH=/opt/db2/V9.7/lib64 make install

The LD_RUN_PATH compiles the load path of the DB2 dynamic libraries directly into the Perl module, so that you won’t have to fiddle with the LD_LIBRARY_PATH variable. To successfully use the DBD::DB2 Perl DBI driver in connection with the Apache::DBI module and mod_perl I needed to set two environment variables in /etc/apache2/modules.d/apache2-mod_perl-startup.pl:

$ENV{DB2DIR} = "/opt/db2/V9.7";
$ENV{DB2INSTANCE} = "db2inst1";

There is only one final issue. On my Gentoo system at home running the 2.6.30 kernel, I always need to issue the db2start command twice. After the first invocation I’m seeing an error message in the db2diag.log file.

2009-08-02-20.47.49.327780+120 I4733E357           LEVEL: Severe
PID     : 31906                TID  : 140015648098048PROC : db2star2
INSTANCE: db2inst1             NODE : 000
FUNCTION: DB2 UDB, base sys utilities, DB2StartMain, probe:580
MESSAGE : ECF=0x900003DE=-1879047202=ECF_TRCAPI_MUTEX_LOCK_ERROR
          Trace facility mutex unexpected lock error

The second invocation of db2start then succeeds.

Otherwise you can consider me an DB2 fan. You will definitely notice, that DB2 is a very mature product.

Pulseaudio, Alsa and Kernel 2.6.30

I’m experiencing some hiccups with kernel 2.6.30, Pulseaudio and Alsa (driver from the kernel). In the company I’m using an older PC, which has a onboard Intel ICH5 audio system and an additional CMI el cheapo audio PCI card. This setup basically came from a time, when the Linux Flash plugin was OSS only. So, the onboard soundcard was basically used for the OSS applications and the CMI card for ALSA applications.

# lspci 
...
00:1f.5 Multimedia audio controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller (rev 02)
...
03:0b.0 Multimedia audio controller: C-Media Electronics Inc CM8738 (rev 10)
...

Now, since I switched to kernel version 2.6.30 I’m seeing the following in my /var/log/messages with a distorted sound, when the problem shows (irrespective of the used sound HW):

pulseaudio[4525]: alsa-util.c: snd_pcm_delay() returned a value that is exceptionally large: 452148 bytes (2563 ms).
pulseaudio[4525]: alsa-util.c: Most likely this is a bug in the ALSA driver '(null)'.
                               Please report this issue to the ALSA developers.
pulseaudio[4525]: alsa-util.c: snd_pcm_dump():
pulseaudio[4525]: alsa-util.c: Hardware PCM card 0 'C-Media CMI8738' device 0 subdevice 0
pulseaudio[4525]: alsa-util.c: Its setup is:
pulseaudio[4525]: alsa-util.c:   stream       : PLAYBACK
pulseaudio[4525]: alsa-util.c:   access       : MMAP_INTERLEAVED
pulseaudio[4525]: alsa-util.c:   format       : S16_LE
pulseaudio[4525]: alsa-util.c:   subformat    : STD
pulseaudio[4525]: alsa-util.c:   channels     : 2
pulseaudio[4525]: alsa-util.c:   rate         : 44100
pulseaudio[4525]: alsa-util.c:   exact rate   : 44100 (44100/1)
pulseaudio[4525]: alsa-util.c:   msbits       : 16
pulseaudio[4525]: alsa-util.c:   buffer_size  : 16384
pulseaudio[4525]: alsa-util.c:   period_size  : 8192
pulseaudio[4525]: alsa-util.c:   period_time  : 185759
pulseaudio[4525]: alsa-util.c:   tstamp_mode  : ENABLE
pulseaudio[4525]: alsa-util.c:   period_step  : 1
pulseaudio[4525]: alsa-util.c:   avail_min    : 15503
pulseaudio[4525]: alsa-util.c:   period_event : 0
pulseaudio[4525]: alsa-util.c:   start_threshold  : -1
pulseaudio[4525]: alsa-util.c:   stop_threshold   : 1073741824
pulseaudio[4525]: alsa-util.c:   silence_threshold: 0
pulseaudio[4525]: alsa-util.c:   silence_size : 0
pulseaudio[4525]: alsa-util.c:   boundary     : 1073741824
pulseaudio[4525]: alsa-util.c:   appl_ptr     : 16614535
pulseaudio[4525]: alsa-util.c:   hw_ptr       : 16501498
pulseaudio[4525]: ratelimit.c: 11481 events suppressed
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 50,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 60,00 ms
pulseaudio[4525]: ratelimit.c: 105 events suppressed
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 70,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 80,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 90,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 100,00 ms
pulseaudio[4525]: ratelimit.c: 11588 events suppressed
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 110,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 120,00 ms
pulseaudio[4525]: ratelimit.c: 11278 events suppressed
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 130,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 140,00 ms
pulseaudio[4525]: alsa-sink.c: Increasing wakeup watermark to 150,00 ms
pulseaudio[4525]: ratelimit.c: 314 events suppressed

This problem apparently only shows with the Pulseaudio daemon and on 32bit Linux. I did an extensive editing session with Audacity, which works directly with the ALSA devices and I didn’t experience any problems here and at home, where I’m running 64bit 2.6.30, the problem also doesn’t show.

Anyway, as a fix I downloaded the latest ALSA driver 1.0.20 from the ALSA website and installed the compiled drivers over the kernel modules. With this, sound works just fine again.

Still disk latency problems with Kernel 2.6.30

I’m still having massive disk latency issues with Linux. They started after I build myself a Core 2 Duo system and switched to 64bit Linux. I wrote about it here, here and here. This workaround appeared to fix the problem first, but after some time and filling up the disk space the latency problems were back on my XFS file systems.

This whole time I’m mostly succeeding in working around the problem by either delaying the job until the time when I’m not recording some music or video or using the much smaller root-partition as scratch space DVD creation. The programs, which pretty reliable trigger the problem are avidemux2 and dviauthor. I’m using avidemux2 to remove any advertisement from a recorded MPEG2 stream. Once I write the output file beside the original file on the same file system the problem is usually triggered. When I’m writing to /tmp on the much smaller root-partition I get by without triggering the latency problem. The same is true, when dviauthor prepares the DVD file structure. When the DVD structure is prepared on the same file system as the originating file, the problem is triggered and not, when written to /tmp.

During the development cycle of kernel 2.6.30 there was much discussion on the net about fixes of latency problems, however primarily in connection to EXT3 and EXT4 file systems. Still I was hoping, that some fix in 2.6.30 would have improved the latency problem for me and my XFS file systems as well.

It appears however, that it is not the case. avidemux2 and dviauthor still trigger the problem. People on the Gentoo forums seem to agree, that the situation might have improved, but isn’t fixed yet. I need to convince myself to backup the data on my multimedia partition and change the file system to EXT4 to see, if it might change the behaviour. This is really a problem, which decreases my trust in Linux.