Okhttp: Crash during journal file rename

Created on 16 Dec 2015  路  16Comments  路  Source: square/okhttp

Get this crash from one of the users

Device: Samsung Galaxy Note 4
Retrofit: v1.9
okhttp: v2.6.0

Fatal Exception: java.lang.RuntimeException: java.io.IOException: failed to rename /data/data/com.bandlab.bandlab/cache/journal.tmp to /data/data/com.bandlab.bandlab/cache/journal
       at com.squareup.okhttp.internal.DiskLruCache$1.run(DiskLruCache.java:181)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)
Caused by java.io.IOException: failed to rename /data/data/com.bandlab.bandlab/cache/journal.tmp to /data/data/com.bandlab.bandlab/cache/journal
       at com.squareup.okhttp.internal.io.FileSystem$1.rename(FileSystem.java:85)
       at com.squareup.okhttp.internal.DiskLruCache.rebuildJournal(DiskLruCache.java:409)
       at com.squareup.okhttp.internal.DiskLruCache.access$400(DiskLruCache.java:88)
       at com.squareup.okhttp.internal.DiskLruCache$1.run(DiskLruCache.java:177)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)
bug

Most helpful comment

And in 3.11.0

All 16 comments

I also get this crash from Crashlytics.
Device:
VIVO: X5PRO D, X5S L, X5 M
SAMSUNG: SMA7000,GT 19500, SM G9250
OPPO: R7T, R8207, R8107

okhttp : v2.3.0

Fatal Exception: java.lang.RuntimeException: java.io.IOException: failed to rename /data/data/com.liwushuo.gifttalk/cache/net_response/journal to /data/data/com.liwushuo.gifttalk/cache/net_response/journal.bkp
at com.squareup.okhttp.internal.DiskLruCache$1.run(SourceFile:181)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Caused by java.io.IOException: failed to rename /data/data/com.liwushuo.gifttalk/cache/net_response/journal to /data/data/com.liwushuo.gifttalk/cache/net_response/journal.bkp
at com.squareup.okhttp.internal.io.FileSystem$1.rename(SourceFile:85)
at com.squareup.okhttp.internal.DiskLruCache.rebuildJournal(SourceFile:408)
at com.squareup.okhttp.internal.DiskLruCache.access$400(SourceFile:88)
at com.squareup.okhttp.internal.DiskLruCache$1.run(SourceFile:177)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)

Getting the same in crashlytics, don't know how to reproduce and fix the same.

okhttp: v2.7.0

same error

We recently also see lots of these crashes in Crashlytics.

OkHttp: 3.2.0

when fix this

Same here, Crittercism/Hockey app is complaining in our released app. Using OkHTTP 2.6.0

same here, using okhttp 3.2.0

It has been fixed in Pull request 2388 if I'm correct. Waiting on a new release now..

Fixed in OkHttp 3.3, coming soon.

just got an instance of this in 3.6.0

And in 3.11.0

still get this error from okhttp:3.13.1.

Caused by java.io.IOException
failed to rename /data/user/0/com.goodboystudios.petparade/cache/picasso-cache/journal.tmp to /data/user/0/com.goodboystudios.petparade/cache/picasso-cache/journal

com.squareup.okhttp.internal.io.FileSystem$1.rename (FileSystem.java:85)

We have just updated to okhttp: 4.2.2 and still getting this error

Caused by java.io.IOException
failed to rename /data/user/0/com.goodboystudios.petparade/cache/picasso-cache/journal.tmp to /data/user/0/com.goodboystudios.petparade/cache/picasso-cache/journal
com.squareup.okhttp.internal.io.FileSystem$1.rename

@dickyabd how common/predictable is it? Is it happening for production clients in the wild?

At this point in DiskLruCache and FileSystem, we have successfully deleted the target file "journal" and are failing with what would hopefully be an atomic rename (same file system) from "journal.tmp" to "journal".

hi @yschimke thanks for the response.

This is very common and this is on production.

here is the exception log :
image

everytime we released an update, the exceptions log warning always highlighted this issue as trending stability issue.

We're not sure why in our app this issue still happening while i saw some comments said they are fixed, as you can see my partner @kevinROctavian has left comment in Februari https://github.com/square/okhttp/issues/2119#issuecomment-465940509

I'm seeing this issue on okhttp 4.9.0. Though I catch it so it doesn't crash the app. Not sure what is causing it - maybe because I'm using a lru cache.

Was this page helpful?
0 / 5 - 0 ratings