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

java.lang.ArrayIndexOutOfBoundsException when syncing data #3307

Closed
2 of 14 tasks
ewa-radomska-codeclusive opened this issue Jun 23, 2023 · 6 comments
Closed
2 of 14 tasks
Assignees
Labels
Android Issues specific to the Android Platform bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category

Comments

@ewa-radomska-codeclusive

Description

Sometimes during syncing models we see this error:

java.lang.ArrayIndexOutOfBoundsException: length=49; index=49 at java.util.ArrayList.add(ArrayList.java:468) at com.amazonaws.amplify.amplify_datastore.DataStoreHubEventStreamHandler.getHubListener$lambda-0(Unknown Source:12) at com.amazonaws.amplify.amplify_datastore.DataStoreHubEventStreamHandler.a(Unknown Source:0) at d.b.a.e.s0.onEvent(Unknown Source:2) at com.amplifyframework.hub.AWSHubPlugin.a(Unknown Source:4) at d.c.g.b.run(Unknown Source:4) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)

It shows in both headless and foreground mode. It doesn't affect app working, but seems sometimes adding hub event to event history fails.

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

Hard to reproduce it in the app with particular steps. One of our team's member found this when add object and than immediately edit it (but it's not showing all the time in this particular case). We see a lot of this bugs in production and everytime it shows during sync when a lot of models are syncing like in those logs:

[Headless HubListener] networks active : true
13:04:17
[Headless HubListener] sync on models : [Yepic, Image, ImageNote, Task, TaskNote, Stop, YepicVisit, OpenVisit, Note, YepicPlace, VisitNote]
13:04:17
[Headless HubListener] sync on model : Yepic  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:20
[Headless HubListener] sync on model : Image  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:20
[Headless HubListener] sync on model : ImageNote  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:20
[Headless HubListener] sync on model : Task  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:20
[Headless HubListener] sync on model : TaskNote  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:23
[Headless HubListener] sync on model : Stop  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:24
[Headless HubListener] sync on model : YepicVisit  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false
13:04:24
[Headless HubListener] YepicVisit model synced - turning observer on
13:04:24
CRASH
java.lang.ArrayIndexOutOfBoundsException: length=73; index=73
MAPPINGS
Missing 
STATUS

Open
Received:2023-05-24 13:04:24
java.lang.ArrayIndexOutOfBoundsException: length=73; index=73
	at java.util.ArrayList.add(ArrayList.java:468)
	at com.amazonaws.amplify.amplify_datastore.DataStoreHubEventStreamHandler.getHubListener$lambda-0(Unknown Source:12)
	at com.amazonaws.amplify.amplify_datastore.DataStoreHubEventStreamHandler.a(Unknown Source:0)
	at d.b.a.e.s0.onEvent(Unknown Source:2)
	at com.amplifyframework.hub.AWSHubPlugin.a(Unknown Source:4)
	at d.c.g.b.run(Unknown Source:4)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
Expand
13:04:24
[Headless HubListener] sync on model : OpenVisit  , added : 0, deleted : 0, updated : 0, delta sync : true, full sync : false

looks like everytime the problem is connected with adding new event to event history. We are trying to figure out if the problem is on our code side or on Amplify Flutter side and if we are doing something wrong what it can be. Any suggestions will be very helpful

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.10.4

Amplify Flutter Version

1.1.0

Deployment Method

Amplify CLI

Schema

No response

@ragingsquirrel3 ragingsquirrel3 added datastore Issues related to the DataStore Category pending-triage This issue is in the backlog of issues to triage Android Issues specific to the Android Platform labels Jun 23, 2023
@stevegaunt
Copy link

@HuiSF

As an observation

Looking at the stacktrace,
An index out of bounds within the add method will be likely to add something to an Array with an index that was too big. The ArrayList stores its data in an Array and maintains the size of that Array automatically. If 2 threads call add at the same time the check for capacity can pass, with only one thread successfully adding, then the other thread will throw the java.lang.ArrayIndexOutOfBoundsException.

This indicates there is a multithread issue when amplify is playing the events…

@HuiSF
Copy link
Member

HuiSF commented Jun 26, 2023

Hi @stevegaunt thanks for the diagnose, we will look into this issue.

@HuiSF HuiSF added the bug Something is not working; the issue has reproducible steps and has been reproduced label Jun 26, 2023
@cwomack cwomack removed the pending-triage This issue is in the backlog of issues to triage label Jun 29, 2023
@NikaHsn NikaHsn self-assigned this Jun 29, 2023
@stevegaunt
Copy link

@HuiSF @NikaHsn
any updates with this?? It's effecting live users for us

@NikaHsn
Copy link
Member

NikaHsn commented Jul 25, 2023

@stevegaunt I don't have an update yet. I'll see how we can prioritize this and will update here on progress. thanks for your patience.

@BrandowBuenos
Copy link

Same here!

@NikaHsn
Copy link
Member

NikaHsn commented Aug 7, 2023

This has been fixed in v1.3.1. Thanks for your patience resolving this issue.

@NikaHsn NikaHsn closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues specific to the Android Platform bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category
Projects
None yet
Development

No branches or pull requests

7 participants