2 Replies Latest reply on Nov 3, 2009 6:38 AM by marklittle

    proposal for Xid format change

    jhalliday

      Xid creation is somewhat slow at present and misses the opportunity to encode some useful information. I propose some changes.

      Old version:

      gtrid = nodename.getBytes()+"#"+tx_uid.stringForm().getBytes();
      bqual = new Uid().stringForm().getBytes();

      Converting Uids to string form is expensive and should be avoided as we are just going to convert it straight back to binary anyhow. The only advantage of the string form is it makes Xid.toString easy. However, it's better to avoid the overhead on Xid creation and move it to Xid.toString instead i.e. decode the data back in to a Uid in toString.

      I was mulling over moving nodename from String to int for similar reasons, but I'm scrapping that idea in favor of just cleaning up the code so it uses a fixed charset - right now bad things happen if the encoding and decoding take place on systems with different default charset.

      The branch qualifier should be extended to encode the EIS ID of the XAResource the branch is being created for, if it's available. This will help in new versions of the server, where the JCA should supply a meaningful EIS ID (e.g. the JNDI name of the Datasource) so that Xids/XAResourceRecords can then be matched to data sources.

      This is useful for diagnosing failures. It's also handy in recovery situations - if you have a record with a specific EIS ID and also a current XAResource with the same, then if the recovery pass on that resource does not include the Xid as in-doubt, you can conclude the tx completed but the tx manager crashed before removing its log file. Currently there is insufficient information to draw that conclusion, making cleaning up the log file a more risky proposition.

      Thus we arrive at the new version:

      gtrid = nodename.getBytes("UTF-8")+"#"+UidHelper.getBytes(tx_uid);
      bqual = eisId.getBytes("UTF-8")+#"+UidHelper.getBytes(new Uid());

      Comments?