Archive

Author Archive

Beware of interned strings with G1

Interned strings can always be problematic, as the size of the hash table is fixed. Perhaps the -XX:+UseStringDeduplication option can make things worse, as (according to native memory tracing) it seems to use the same pool. However, at present there is a more pressing problem with Java 8 and 9 using the G1 garbage collector: interned strings may not be garbage collected at all, resulting in a native memory leak. See JDK-8180048. What to do? Stay calm or switch to another garbage collector. But be sure to keep an eye on the native memory usage of your Java applications!

Categories: Java

Fighting with biosboot and efi boot in CentOS 7

In two recent Linux installations I have struggled with biosboot and efi boot partitions. At first I didn’t know why they were needed, I have never seen them before, perhaps because I generally use old hardware for my Linux boxes.

The rule is apparently fairly simple. If the system booted in efi mode, the disks must use gpt and an efi boot partition is required. If on the other hand the system booted in legacy mode there are two options. If the disk is larger than 2T then gpt is required and a biosboot partition is needed. For smaller disks it is possible to use msdos without a biosboot or efi boot partition, using only the mbr for the boot loader.

You can tell if the system booted in efi by checking for /sys/firmware/efi. If it exists the system booted in efi, otherwise it booted in legacy mode. The boot method is controlled by bios settings, not by Linux.

I tried to install CentOS 7. For a simple one-disk installation it is a breeze, but what do you do if you want to use software raid? The installer can create boot and root in raid1, but there is no support for creating efi boot or biosboot partitions on multiple drives.

For biosboot I solved it by escaping to a command prompt, (Ctrl-Alt-F2), creating a gpt disk with gdisk with a single 1M partition created in advance for all disks. That worked, but of course the boot loader is only installed on one of the disks, so after a reboot I had to run grub2-install for all disks.

For efi boot I failed. The installer didn’t like my M2 disk and kept complaining. I tried without it, using two other identical disks. That worked better, but I still couldn’t create the partition from the installer and when I used gdisk the installer would either complain that /boot/efi had to exist on a valid gpt disk or that there was an invalid software raid setup on the newly formatted disks. After several attempts, each needing a reboot cycle, I gave up and booted the system in legacy mode, using msdos disks with classic mbr. Everything worked, including the M2 disk.

This should not be rocket science. The end result is well defined, the problem is when you have to work against the installer rather than with it. I realize that most of Red Hats corporate customers use hardware RAID, but there are many servers out there using software raid as well. Better support for mirrored disks in the installer would be great!

Categories: Linux

Effective low-tech alternative to @formatter:off for Java

I love automatic formatting for source code. Back in 2004 I scrapped the detailed formatting guide for the project I was running and replaced it with a single sentence: all code must be formatted by the automatic formatter using the project’s conventions. Done. Sure, manual formatting can look better, but at what cost (and tedium)?

There are some places where the automatic formatter always fails, though, for example string concatenation for SQL commands. No problem, use @formatter:off and @formatter:on and there you are – until someone comes along who hasn’t enabled the tags. And disabling formatting completely can introduce tabs where there should be spaces, for example.

Fortunately there is an effective low-tech alternative that works everywhere (cross-IDE): comments! Use line comments after each line and the formatter can’t join them:


   "select something from some_table " //
   + " where some_column = ?"

It will still handle indentation.

Categories: Java

Windows 10 update issues

With Windows 10 there is no easy way to block an update. If Windows Update thinks you need it, well then there you are. Perhaps that is good, perhaps it is bad. I don’t like it. However, it turns out to be particularly nasty if an update fails!

In my case the printer driver for HP LaserJet CM1415 had a new version, but the update consistently failed. Not a big deal, the old driver worked well – or so I thought. Unfortunately the failure to install this one update caused Windows Update to ignore all others. It would keep trying with the printer driver every and keep failing. As a result none of the really important updates got through. So, if an update fails, don’t ignore it.

When that had been solved the Anniversary Update started, but consistently failed with a black screen. It took me some time to determine why. Apparently it didn’t play well with TrueCrypt (Windows Home does not support Bitlocker). Decrypting the drive for the update solved the issue.

Categories: Windows

ActiveMQ redelivery plugin fails when client side redelivery is active

We recently had serious issues with the ActiveMQ redelivery plugin. Under high load messages would not be redelivered at all (according to the application logs), they went straight to the DLQ. In isolated tests redelivery worked, but not as intended. We would get six redeliveries in a few milliseconds and then nothing. Why?

It turned out to be a conflict between client-side redelivery and broker redelivery. The client side redelivery kicked in and quickly failed six times. Then when the broker got a chance the maximum redelivery count had already been reached, so the message was moved to the DLQ. See this post.

Following the advice in the post we added jms.redeliveryPolicy.maximumRedeliveries=0 to the broker url, and voila! It worked.

Categories: Java

Prevent hawtio from phoning home

Hawtio is bundled in several applications as a management console. In one project we are using it with JBoss EAP 6. However, when the application server starts hawtio attempts to update itself from Github:


Performing a pull in git repository .hawtio/config on remote URL:
https://github.com/hawtio/hawtio-config.git.
Subsequent pull attempts will use debug logging
Failed to pull from the remote git repo with credentials null due:
https://github.com/hawtio/hawtio-config.git:
407 Proxy Authentication Required. This exception is ignored.

I certainly don’t want applications in production to update themselves dynamically with unforseen effects and neither do I want them to phone home. What to do? Fortunately it is possible to control this, see the documentation. Simply add the following Java options:


-Dhawtio.offline=true
-Dhawtio.config.cloneOnStartup=false
-Dhawtio.config.pullOnStartup=false

Problem solved.

Categories: Java

Free toolset for JMS tests released

In 1996 I worked with IBM MQ Series using OS/2 and CICS. That was the first time I worked with performance tuning for messaging. Since then I have been involved in many projects with the same basic goal: make sure it works correctly (no lost messages under any circumstances) and make it fast. It has never been my full-time job, but as a consultant I have been there and done that a few times now. The more memorable have been webMethods, AQ, HornetQ, ActiveMQ/AMQ and (again) AQ. Every time I have ended up writing my own tools. Yes, every time. So, I’ll do it again, but this time I’ll release the code and make it work for as many JMS providers as possible. Or at least the ones I need.

You can find the project, now in 1.0, at GitHub. If you find it useful, please let me know. One major benefit of making the code open source is that the vendors always need to reproduce any issues on their own. With an open source tool that is easier. A widely used tool is even better, as it has some credibility from the start, so spread the word (and the code)!

If I have time during the summer I will write a series of posts on how to use the tools. Let me know if there is anything in particular I should cover!

Categories: Java, Performance