Timeouts for Oracle XA datasources in JBoss EAP 6

The documentation for configuring datasources in JBoss EAP 6 is somewhat lacking when it comes to timeouts. Normally this is fine, but what if there are network issues? With the wrong timeout settings the application can hang until it is killed and restarted. With proper timeouts it can handle an outage and recover.

Here is an example:


<xa-datasource jndi-name="java:/AppDS" pool-name="AppDS">
  <xa-datasource-property name="URL">
    ${appdb.url}
  </xa-datasource-property>
  <xa-datasource-property name="nativeXA">true</xa-datasource-property>
  <xa-datasource-property name="ConnectionProperties">
    oracle.jdbc.ReadTimeout=330000
  </xa-datasource-property>
  <xa-datasource-class>
    oracle.jdbc.xa.client.OracleXADataSource
  </xa-datasource-class>
  <driver>oracle</driver>
  <security>
    <user-name>${appdb.user}</user-name>
    <password>${appdb.password}</password>
  </security>
  <xa-pool>
    <min-pool-size>${appdb.min.pool.size}</min-pool-size>
    <max-pool-size>${appdb.max.pool.size}</max-pool-size>
    <prefill>false</prefill>
    <use-strict-min>false</use-strict-min>
    <flush-strategy>FailingConnectionOnly</flush-strategy>
    <is-same-rm-override>false</is-same-rm-override>
    <no-tx-separate-pools/>
    <pad-xid>true</pad-xid>
    <wrap-xa-resource>true</wrap-xa-resource>
  </xa-pool>
  <validation>
    <valid-connection-checker class-name=
      "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
    <stale-connection-checker class-name=
      "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>
    <exception-sorter class-name=
      "org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
  </validation>
  <timeout>
    <blocking-timeout-millis>60000</blocking-timeout-millis>
    <xa-resource-timeout>310</xa-resource-timeout>
    <query-timeout>300</query-timeout>
    <set-tx-query-timeout/>
  </timeout>
  <statement>
    <track-statements>false</track-statements>
  </statement>
  <recovery no-recovery="false">
    <recover-credential>
      <user-name>${appdb.user}</user-name>
      <password>${appdb.password}</password>
    </recover-credential>
  </recovery>
</xa-datasource>

The oracle.jdbc.ReadTimeout is essential. It sets the network timeout on the socket, making reads time out eventually in the face of a broken connection. The default TCP timeout for established connections is very long, so it is important to set a value. It should be larger than the transaction timeouts. The query timeout and tx-query-timeout both limit the time that individual statements can take. The query timeout is used when there is no transaction, otherwise the remaining time until transaction timeout is used.

Note that read timeout is in milliseconds, query timeout is in seconds.

Categories: Oracle, Java, Networking

Compression ratio and time for common tools

One application I’m working with produces horrendous amounts of log files. They are so large that the process of compressing them and moving them to another server actually has a performance impact on the system in spite of nice and ionice. I decided to compare the most common compression tools. At home I’m using bzip2, as I want the best possible compression ratio. Would that be a good idea?

Compression ratio and time

As the table shows bzip2 is frightfully expensive, but it does produce small files. In addition it makes a big difference if gzip is told to optimize for speed (1) or compression (9), or if it runs at the default level (6). Compress is basically an outdated tool and was included as it is sometimes quoted as being faster than gzip. Here that was not the case.

Categories: Linux

Disable bloatware on Xperia Z5 compact

I recently bought a new phone, the Xperia Z5 compact. It has its strengths and weaknesses. In particular, why do vendors insist on crippling their devices with irritating bloatware?

The Xperia comes with Movie Creator, an app that runs in the background to create meaningless movies from photos. It is about as irritating as Microsoft’s old Clippy. Fortunately it is possible to get rid of the app, even though it can’t be uninstalled. Go to Settings, Apps, All and select Movie Creator. Delete any data it has amassed and then click on disable. That prevents the app from starting. It also removes the icon.

The same procedure should work for other unwanted bundled apps.

Categories: Android

Stupid network issues

Why do all network cards work with Windows, but not with Linux or BSD? Well, whatever. I spent a lot of time this summer trying to get two Internet connections from the same Linux box for high availability. No luck, worked for a while and then failed. Just found out that the built-in network interface from Sundance shuts down under moderate load on Linux. That explains why it didn’t work.

Now I want to use the same box for a DMZ. We have a smart TV and I don’t trust it at all. It needs Internet access, but I won’t allow it anywhere near anything important. I don’t trust my phone (unfortunately) and I certainly won’t trust a TV!

Fortunately the Linux box has one free PCI-e slot, so this should be easy. Just install a new network card and go! Well, not quite. I hate VIA on Linux. I bought two network cards as the first failed to deliver, but the final solution was to add some boot options to grub: pci=nomsi,noaer.

There are still warnings about interrupts that nobody cares about (irqpoll might help, but increases power consumption), but for now it seems to work.

Categories: Linux, Networking

Take care with BTRFS

I have long been an avid fan of ZFS, but though I have been running it on Linux for quite some time I’m not ready to trust it there. The upgrades can be painfull. No lost data so far, but several temporary outages with down time. Perhaps BTRFS is ready for prime time? In short no. It seems very promising, but Red Hat still has reservations. I have tested it with non-essential data. The basics are there and there are many cool features, but when I started to use some of them the file system suddenly turned read only. Why? Tried again, several times. Finally found it – old and fixed bug, but the fix is in the 4.x kernels. Way ahead of Red Hat/CentOS 7.
Of course, a read-only file system is much better than a corrupted one, so that was good. Even so I’ll wait a few more years before I trust anything vital to BTRFS, just in case. Having said that the long-term promise is there, so in five years I bet my servers will be running on BTRFS (unless the ZFS on Linux story changes)!

Categories: Linux

Sorting and rotating photos

I have long used my own Java program for sorting and adjusting photos, but now I have found a better solution: jhead for Linux. Combining it with Dropbox and a cron job I can get my uploaded images, move them out of Dropbox (to save space online, I don’t pay and I like to keep my data close), rotate if needed and sort into folders by year, month and day. The jhead command is simple:


jhead -n%Y/%m/%d/%f -autorot -exonly *.*

This sorts photos by the date taken and rotates them as needed. Images without creation date are left in the main folder for manual sorting.

Categories: Linux

Windows-like keyboard shortcuts in Linux Eclipse

I have worked with Windows as my main development platform since Windows 3.1 and the keyboard shortcuts are hardwired by now. Unfortunately Microsoft has failed utterly. In my opinion Windows 7 is the pinnacle from a usability standpoint, Windows 8 was a disaster and Windows 10 is not that much of an improvement. It is time to move on, in particular as Microsoft seems determined to spy on customers.

Java is cross-platform, so I can use Linux. It works well and bash is great, but the keyboard shortcuts are plain wrong. Fortunately there is a solution. For example, to expand a treeview in Eclipse StackOverflow recommends this for GTK 2:


binding "gtk-binding-tree-view" {
    bind "j"        { "move-cursor" (display-lines, 1) }
    bind "k"        { "move-cursor" (display-lines, -1) }
    bind "h"        { "expand-collapse-cursor-row" (1,0,0) }
    bind "l"        { "expand-collapse-cursor-row" (1,1,0) }
    bind "o"        { "move-cursor" (pages, 1) }
    bind "u"        { "move-cursor" (pages, -1) }
    bind "g"        { "move-cursor" (buffer-ends, -1) }
    bind "y"        { "move-cursor" (buffer-ends, 1) }
    bind "p"        { "select-cursor-parent" () }
    bind "Left"     { "expand-collapse-cursor-row" (0,0,0) }
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) }
    bind "semicolon" { "expand-collapse-cursor-row" (0,1,1) }
    bind "slash"    { "start-interactive-search" () }
}
class "GtkTreeView" binding "gtk-binding-tree-view"

And this for GTK 3:


@binding-set MyTreeViewBinding {
    bind "Left"     { "select-cursor-parent" ()
                      "expand-collapse-cursor-row" (0,0,0) };
    bind "Right"    { "expand-collapse-cursor-row" (0,1,0) };
}
GtkTreeView {
    gtk-key-bindings: MyTreeViewBinding;
}

With Ubuntu the files to edit are found below /usr/share/themes.

Categories: Java, Linux, Windows
Follow

Get every new post delivered to your Inbox.