Version 2.1.3 uploaded

A new version (2.1.3) is now available from the Android Market. This version fixes a major problem for users of new HTC Sensation 4G devices running the HTC-modified Android version 2.3.4.

HTC decided to patch the SQLite interface in this version such that any database the application opens will be set to the new write-ahead log mode. In this mode, new data is not written to the database file (as is usually the case with SQLite), but instead is appended to a separate file, the write-ahead log file. For further reading, you may want to visit the SQLite website.

This change has major implications when a backup of the database needs to be done. The usual, recommended way (as per the SQLite documentation) is to obtain an exclusive lock on the database, copy the database file, and release the lock. However, when the database is in write-ahead log mode, the application first needs to do a checkpoint of the database in order to transfer the records from the write-ahead log to the main database file.

According to the SQLite documentation, a new database connection always comes up in traditional rollback journal mode. Due to the patch HTC made on their new Android version, this is no longer true on these phones. The database comes up in write-ahead log mode, even though the application did not ask for it and does not know anything about it.

This broke the backup procedure of ECAS and will likely break database backups of many other apps as well. As a guard against this crazy HTC behavior, ECAS now uses a PRAGMA command to force the database to rollback journal mode explicitly. This mode is the desired mode anyways, since it has better read performance. The new write-ahead mode provides better write performance and better concurrency in case of many readers and writers on the same database, but it slows down read operations and needs special attention/check-pointing by the applicaiton.

Make sure to update your application if you own such a phone and need the backup function to work correctly!

This entry was posted in News. Bookmark the permalink.

Leave a Reply