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

Amplify Datastore sync stops #6198

Closed
millarm opened this issue Jun 29, 2020 · 5 comments
Closed

Amplify Datastore sync stops #6198

millarm opened this issue Jun 29, 2020 · 5 comments
Labels
DataStore Related to DataStore category to-be-reproduced Used in order for Amplify to reproduce said issue

Comments

@millarm
Copy link
Contributor

millarm commented Jun 29, 2020

Describe the bug
Symptoms:

Amplify react native application that's is working reliably under test conditions, but when I use it for real it stops syncing.

It's an application that's for tracking location data, so testing requires getting up, and away from a desk!

Symptoms are:

App is working fine locally on device, but there is no sync to the backend from DataStore, so other clients don't get updated. No errors are logged, and there doesn't seem to be any API to force DataStore to sync.

First question is:

  1. What's the best way to debug this sort of sync issue? As an amplify developer where should I look for logging/data?

(Seems to be: Amplify.Logger.LOG_LEVEL = 'DEBUG'; which outputs debug logging. Can one enable logging for just DataStore?)

This is my schema:

type Journey
  @model
  @auth(
    rules: [
      {
        allow: owner
      }
    ]
  ) {
  id: ID!
  timestamp: AWSDateTime!
  appVersion: String!
  buildVersion: String!
  bundleIdentifer: String!
  device: String!
  active: Boolean
  segments: [Segment] @connection(keyName: "bySegment", fields: ["id"])
  owner: String
}

type Segment
  @model
  @key(name: "bySegment", fields: ["journeyID"])
  @auth(
    rules: [
      {
        allow: owner
      }
    ]
  ) {
  id: ID!
  journeyID: ID!
  startTime: AWSDateTime!
  startPosition: AWSJSON!
  endTime: AWSDateTime
  endPosition: AWSJSON
  sensorData: String
  locations: AWSJSON!
  owner: String
}

With debug logging on it seems the error is caused by:

Util - attempt #9 with this vars: ["query operation($limit: Int, $nextToken: String, $lastSync: AWSTimestamp){\n\t\tsyncSegments(limit: $limit, nextToken: $nextToken, lastSync: $lastSync){\n\t\t\titems {\n\t\t\t\t\t\t\tid\njourneyID\nstartTime\nstartPosition\nendTime\nendPosition\nsensorData\nlocations\nowner\n_version\n_lastChangedAt\n_deleted\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnextToken\n\t\t\t\t\t\tstartedAt\n\t\t}\n\t}",{"limit":1000,"nextToken":null,"lastSync":0}]

I get an error logged (only with debug logging on)

errors: Array(1)
0:
data: null
errorInfo: null
errorType: "MappingTemplate"
locations: [{…}]
message: "Transformation too large"
path: Array(1)
0: "syncSegments"
length: 1

So... how do I go about establishing what's causing this, and fixing the issue?

@millarm millarm added the to-be-reproduced Used in order for Amplify to reproduce said issue label Jun 29, 2020
@Amplifiyer Amplifiyer added the DataStore Related to DataStore category label Jun 29, 2020
@millarm
Copy link
Contributor Author

millarm commented Jun 29, 2020

More details - the root cause here appears to be the Segment model, and, at a wild guess... the JSON object in locations

This is... an array of locations, so is of variable size.

GraphQL request

{
	"query": "query operation($limit: Int, $nextToken: String, $lastSync: AWSTimestamp) {\n  syncSegments(limit: $limit, nextToken: $nextToken, lastSync: $lastSync) {\n    items {\n      id\n      journeyID\n      startTime\n      startPosition\n      endTime\n      endPosition\n      sensorData\n      locations\n      owner\n      _version\n      _lastChangedAt\n      _deleted\n    }\n    nextToken\n    startedAt\n  }\n}\n",
	"variables": {
		"limit": 1000,
		"nextToken": null,
		"lastSync": 0
	}
}

Response


{
	"data": {
		"syncSegments": null
	},
	"errors": [{
		"path": ["syncSegments"],
		"data": null,
		"errorType": "MappingTemplate",
		"errorInfo": null,
		"locations": [{
			"line": 2,
			"column": 3,
			"sourceName": null
		}],
		"message": "Transformation too large"
	}]
}

@millarm
Copy link
Contributor Author

millarm commented Jun 29, 2020

Notes: the locations array is likely to be around 60 objects -> but could go as high as 150 objects. It's dependent on how fast you are travelling. :-)

@millarm
Copy link
Contributor Author

millarm commented Jun 29, 2020

And... Seem to have fixed this issue by following instructions here:

#5181

Adding this:

DataStore.configure({
  syncPageSize: 100,

})

Seems to have worked around the current issue

@Amplifiyer
Copy link
Contributor

thanks @millarm for confirming. Closing this since the issue is resolved for you.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DataStore Related to DataStore category to-be-reproduced Used in order for Amplify to reproduce said issue
Projects
None yet
Development

No branches or pull requests

2 participants