Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - okhttp3.internal.io.FileSystem$Companion$SYSTEM$1.rename (FileSystem.java:89) crash #6123

Closed
somekoder opened this issue Jun 9, 2020 · 10 comments
Labels
android Relates to usage specifically on Android bug Bug in existing code needs info More information needed from reporter

Comments

@somekoder
Copy link

These crashes keep happening:
failed to rename /data/user/0/com.package/cache/62ac51d56050cb47dea413039d3e3b67.0.tmp to /data/user/0/com.package/cache/62ac51d56050cb47dea413039d3e3b67.0

They happen randomly and not all the time, I'm unable to reproduce which makes it all the more confusing. The crashes are all similar to this one, but will sometimes be "delete" or "read"

They're happening too often to ignore. Is there a way to mitigate or fix this this? As far as I can tell, it happens on most devices. I apologize for the lack of information. We're using version 4.5.0.

@somekoder somekoder added the bug Bug in existing code label Jun 9, 2020
@swankjesse
Copy link
Member

Full stack trace? I suspect the filesystem is full. OkHttp us supposed to just stop caching when that happens.

@swankjesse
Copy link
Member

Also please try the latest release; we've had cache fixes since 4.5.0.

@yschimke yschimke added android Relates to usage specifically on Android needs info More information needed from reporter labels Jun 10, 2020
@somekoder
Copy link
Author

somekoder commented Jun 13, 2020

I'm sorry for the long reply, here is the stack trace:
Fatal Exception: java.io.IOException: failed to rename /data/user/0/com.package/cache/feef9348d5877ee07813624fb12f97d6.1.tmp to /data/user/0/com.package/cache/feef9348d5877ee07813624fb12f97d6.1
at okhttp3.internal.io.FileSystem$Companion$SYSTEM$1.rename(FileSystem.java:89)
at okhttp3.internal.cache.DiskLruCache.completeEdit$okhttp(DiskLruCache.java:524)
at okhttp3.internal.cache.DiskLruCache$Editor.commit(DiskLruCache.java:865)
at okhttp3.Cache$RealCacheRequest$1.close(Cache.java:406)
at okio.RealBufferedSink.close(RealBufferedSink.java:268)
at okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1.read(CacheInterceptor.java:170)
at okio.RealBufferedSource.read(RealBufferedSource.java:188)
at okio.RealBufferedSource.exhausted(RealBufferedSource.java:198)
at okio.GzipSource.read(GzipSource.java:88)
at okio.RealBufferedSource.read(RealBufferedSource.java:188)
at okio.ForwardingSource.read(ForwardingSource.java:29)
at retrofit2.OkHttpCall$ExceptionCatchingResponseBody$1.read(OkHttpCall.java:288)
at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.java:158)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.java:211)
at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:538)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
at com.package.NullOnEmptyConverterFactory$responseBodyConverter$1.convert(NullOnEmptyConverterFactory.java:16)
at com.package.NullOnEmptyConverterFactory$responseBodyConverter$1.convert(NullOnEmptyConverterFactory.java:8)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.java:504)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)

Although, I will definitely try the lastest version, thank you!

@yschimke yschimke reopened this Jun 13, 2020
@yschimke
Copy link
Collaborator

There are various reasons why this could be normal e.g. The phone or your app is clearing the cache, your disk is full.

Can you collect this information and re-open.

As is this isn't actionable, if you can confirm the cache is full and contents are not being deleted we will reopen and look more.

@dinhhieuac
Copy link

Hi
I have the same problem and it's quite common
Info Device
https://prnt.sc/u7di0b
Fatal Exception: java.io.IOException: failed to rename /data/user/0/com.myapp.and_tv/cache/04ffd598d3450c64ffffab7d2e054719.1.tmp to /data/user/0/com.myapp.and_tv/cache/04ffd598d3450c64ffffab7d2e054719.1
at okhttp3.internal.io.FileSystem$Companion$SYSTEM$1.rename(FileSystem.kt:89)
at okhttp3.internal.cache.DiskLruCache.completeEdit$okhttp(DiskLruCache.kt:532)
at okhttp3.internal.cache.DiskLruCache$Editor.commit(DiskLruCache.kt:901)
at okhttp3.Cache$RealCacheRequest$1.close(Cache.kt:406)
at okio.RealBufferedSink.close(RealBufferedSink.kt:268)
at okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1.read(CacheInterceptor.kt:190)
at okio.RealBufferedSource.read(RealBufferedSource.kt:188)
at okio.ForwardingSource.read(ForwardingSource.kt:29)
at retrofit2.OkHttpCall$ExceptionCatchingResponseBody$1.read(OkHttpCall.java:314)
at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:158)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.kt:211)
at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:538)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:41)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)
at com.google.firebase.perf.network.zzh.onResponse(com.google.firebase:firebase-perf@@19.0.8:22)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Thanks
HieuHD

@oproulx
Copy link

oproulx commented Dec 11, 2020

Hello,

We are still seeing this crash on version 4.9.0.

Fatal Exception: java.io.IOException: failed to rename /data/user/0/OURAPP/cache/57ad8dd5e5e0a9c6b5f4b00d66f8e3c6.0.tmp to /data/user/0/OURAPP/cache/57ad8dd5e5e0a9c6b5f4b00d66f8e3c6.0
       at okhttp3.internal.io.FileSystem$Companion$SystemFileSystem.rename(FileSystem.java:90)
       at okhttp3.internal.cache.DiskLruCache.completeEdit$okhttp(DiskLruCache.java:532)
       at okhttp3.internal.cache.DiskLruCache$Editor.commit(DiskLruCache.java:901)
       at okhttp3.Cache$RealCacheRequest$1.close(Cache.java:406)
       at okio.internal.RealBufferedSinkKt.commonClose(RealBufferedSinkKt.java:203)
       at okio.RealBufferedSink.close(RealBufferedSink.java:286)
       at okhttp3.internal.cache.CacheInterceptor$cacheWritingResponse$cacheWritingSource$1.read(CacheInterceptor.java:190)
       at okio.internal.RealBufferedSourceKt.commonRead(RealBufferedSourceKt.java:39)
       at okio.RealBufferedSource.read(RealBufferedSource.java:189)
       at okio.internal.RealBufferedSourceKt.commonExhausted(RealBufferedSourceKt.java:49)
       at okio.RealBufferedSource.exhausted(RealBufferedSource.java:197)
       at okio.GzipSource.read(GzipSource.java:88)
       at okio.internal.RealBufferedSourceKt.commonRead(RealBufferedSourceKt.java:39)
       at okio.RealBufferedSource.read(RealBufferedSource.java:189)
       at okio.ForwardingSource.read(ForwardingSource.java:29)
       at retrofit2.OkHttpCall$ExceptionCatchingResponseBody$1.read(OkHttpCall.java:288)
       at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.java:158)
       at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:288)
       at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:351)
       at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:180)
       at java.io.InputStreamReader.read(InputStreamReader.java:184)
       at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.java:211)
       at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295)
       at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333)
       at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:538)
       at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
       at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)
       at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)
       at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225)
       at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121)
       at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.java:519)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:764)

Any help is greatly appreciated!

Olivier

@yschimke
Copy link
Collaborator

Any chance you have two Cache instances sharing the same directory?

@oproulx
Copy link

oproulx commented Dec 11, 2020

Any chance you have two Cache instances sharing the same directory?

Here is how we configure the client:

image (1)

We call RetrofitClient.init(context: this) in our .app class, so the cache is configured based on the .app context.

@yschimke
Copy link
Collaborator

yschimke commented Dec 11, 2020

If you have two serviceApi then you likely have two Cache instances sharing the same directory, this is probably the cause.

See https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#okhttpclients-should-be-shared

@oproulx
Copy link

oproulx commented Dec 11, 2020

If you have two serviceApi then you likely have two Cache instances sharing the same directory, this is probably the cause.

See https://square.github.io/okhttp/4.x/okhttp/okhttp3/-ok-http-client/#okhttpclients-should-be-shared

Thanks for the suggestion! We will ensure that only 1 client is created and post back if that resolves the crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Relates to usage specifically on Android bug Bug in existing code needs info More information needed from reporter
Projects
None yet
Development

No branches or pull requests

5 participants