Comments (19)
Thanks for that context - I'll chat with our sync team and see what they say.
from realm-js.
@muddy-alex Thank you to getting back. I'll bring up the issue at the next team meeting.
from realm-js.
➤ PM Bot commented:
Jira ticket: RJS-2762
from realm-js.
@muddy-alex There is no API to force sync as the sync client works mostly autonomously. pause()
/resume()
can trigger the sync client to take an extra round trip.
If it is possible, please share the stack trace. resume()
should not cause a SIGSEGV.
from realm-js.
No stack trace, unfortunately.
Pause/Resume seems to work before the initial sync has been completed. However, once it has (based on the realm.syncSession.addConnectionNotification
event handler being called), calling pause/resume causes the process to abruptly exit.
This is all I get...
Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
from realm-js.
Could be related to realm/realm-core#7349? It is possible for you to downgrade? If it works with an earlier version (12.4.0 or older), it could be an indication for us.
from realm-js.
We were originally testing with 12.3.1
when we found the issue, but upgraded to 12.6.2
to check if it was resolved
from realm-js.
Let me get this straight - initial sync is happening, but you have created some data offline and don't want to wait for initial sync to complete before that data gets uploaded, which is why you're pausing and resuming the session?
As Kenneth said, even though this is likely not the intended flow, we shouldn't be crashing. But understanding the circumstances around the crash will allow us to repro it.
from realm-js.
We only have specific time windows on internet access, which is why we need some kind of 'force-sync' feature as we've found that the NodeJS Client doesn't seem to do any further synchronisation during the lifetime of the process (tested over 2 days).
We've found that the initial sync seems to be restricted to 10MB upload, taking the short time window of internet access into account, we would like this 'force-sync' feature to keep pushing up the 10MB chunks until all offline data has been uploaded.
from realm-js.
Hey, so following that conversation, here's a few more questions.
- What do you mean by "initial sync" here? Can you clarify what the flow looks like in your app - possibly with some example code snippets. It doesn't have to be the exact thing, but more for illustrative purposes - e.g.:
realm.subscriptions.update(...) // Subscribe for new data
realm.write(() => {
for (var i = 0; i < 100; i++) {
realm.create(...); // Create some offline data
}
});
// User goes into internet accessible window
realm.syncSession.resume();
// wait for something?
realm.syncSession.pause();
- Where does the 10mb limit come from? There's nothing in the sync protocol that we're aware of that puts 10 mb limit on uploads and there's nothing we're aware of that would cause pausing/resuming session to force sync and have it behave differently compared to the session just being active.
- What is the connection state you're waiting for using
addConnectionNotification
. This API is intended to let you know that a connection is established, but provides no information whatsoever about the state of synchronization. How are you using it and what information are you inferring from the connection state? - If you can consistently reproduce the crash, can you configure logging to log at
trace
level and get us the logs from a run that reproduces the crash?
from realm-js.
@muddy-alex There is no way currently to force-sync the local data: we first download any data from the server, and then we start uploading the local data. Pausing and resuming the session does not change this behavior in any way. We could add a config option to change that though. If you only have asymmetric tables in the schema, then there is nothing to download so upload would start immediately.
from realm-js.
@kneth I can replicate the SIGSEGV here...
import Realm from 'realm';
const ATLAS_APP_ID = '';
const ATLAS_API_KEY = '';
export const Point = {
name: 'Point',
embedded: true,
properties: {
type: { type: 'string', default: () => 'Point' },
coordinates: { type: 'list', objectType: 'double' }
},
};
class Log extends Realm.Object {
static schema = {
name: 'Log',
asymmetric: true,
primaryKey: '_id',
properties: {
_id: 'objectId',
timestamp: 'date',
organisation: 'objectId',
key: 'string',
value: 'mixed?[]',
metadata: 'mixed?{}',
location: 'Point',
locationFix: 'int'
}
};
}
const app = new Realm.App({ id: ATLAS_APP_ID });
Realm.App.Sync.setLogLevel(app, "trace");
const user = app.currentUser
? app.currentUser
: await app.logIn(Realm.Credentials.apiKey(ATLAS_API_KEY));
const realm = await Realm.open({
schema: [Log, Point],
sync: {
cancelWaitsOnNonFatalError: false,
existingRealmFileBehavior: {
type: Realm.OpenRealmBehaviorType.OpenImmediately,
timeOut: 5000,
timeOutBehavior: Realm.OpenRealmTimeOutBehavior.OpenLocalRealm
},
newRealmFileBehavior: {
type: Realm.OpenRealmBehaviorType.OpenImmediately,
timeOut: 5000,
timeOutBehavior: Realm.OpenRealmTimeOutBehavior.OpenLocalRealm
},
flexible: true,
onError: (session, error) => {
console.error('Sync Error!');
console.error(error);
},
user
}
});
realm.syncSession.addConnectionNotification(() => {
console.log('Sync Connected!');
});
realm.syncSession.addProgressNotification(Realm.ProgressDirection.Download, Realm.ProgressMode.ForCurrentlyOutstandingWork, (transferred, transferable) => {
console.log(`Sync Downloading: ${transferred}/${transferable}`);
});
realm.syncSession.addProgressNotification(Realm.ProgressDirection.Upload, Realm.ProgressMode.ForCurrentlyOutstandingWork, (transferred, transferable) => {
console.log(`Sync Uploading: ${transferred}/${transferable}`);
});
setTimeout(async () => {
console.log('Force Sync');
await realm.syncSession.pause()
await realm.syncSession.resume()
}, 15 * 1000);
from realm-js.
@danieltabacaru it was the documentation here that lead me to believe that this might be possible
from realm-js.
@nirinchev When I mention to 'initial sync', I am referring to when Realm uploads offline data for the first time the process starts. Based on my reproduction above, when you see
Sync Connected!
Sync Downloading: 0/0
Sync Uploading: 0/201
Sync Uploading: 201/201
We've found that when this initial sync runs, only a chunk (I can't remember why I assumed it was 10MB) is uploaded - rather than all of the offline data. This meant that we had to restart the process a few times before all data was pushed up to AppSync, hence the reason we are looking for a 'force-sync' solution.
from realm-js.
@muddy-alex I believe the documentation is correct. Forcing sync in that context is forcing connecting to the server, but the behavior is as I described it.
I wrote a similar test and I see no issues with it. I cannot see where class Point is declared in your example. The one you have there looks like a schema. Maybe @kneth can have a look.
from realm-js.
Is there any code following the resume? Maybe something is not cleaned-up properly. You can try to wait for upload completion.
from realm-js.
@danieltabacaru Nothing follows the resume()
. As soon as its called we get the SIGSEGV
from realm-js.
@muddy-alex You are mixing class-based models (Log
) and JS schemas (Point
), and I wonder if it has a negative impact. I mean, our tests are either-or, so you might be in the land of undefined behavior.
from realm-js.
I couldn't find a documented way of using Embedded objects with the Class syntax. Updating the above example to just use JS schemas still results in the SIGSEGV.
from realm-js.
Related Issues (20)
- [realm/react] Account for new `ObjectId` refs used in the dependency list HOT 6
- Multi-threaded support for Electron / NodeJS HOT 3
- baseUrl Change (Realm Web) HOT 1
- Calling `User#linkCredentials` with the email of a non-existing user or wrong password never surface error HOT 1
- "free(): invalid pointer" when running on Ubuntu x86_64 and Node.js >= v20.12.0 HOT 4
- Ensure we have `clang-format` installed on CI runners when generating bindings HOT 2
- Upgrade to Realm Core 14.5.0 HOT 1
- Random SIGSEGV error and crash on production HOT 2
- Error Realm initialization with sync enabled due to mismatch schema is not calling onError function HOT 2
- Version mismatch does not block sync HOT 5
- Run React Native integration tests in more configurations HOT 2
- Cannot index a property using TypeScript HOT 8
- Electron crash on exit (Segmentation fault, MacOS) HOT 5
- Upgrade to Realm Core 14.5.1 HOT 1
- Add ability to pass a configured Realm instance to RealmProvider HOT 2
- The binary file is not permitted. HOT 13
- TypeError: Cannot read property 'size' of undefined HOT 13
- Upgrade to Realm Core v14.5.2 HOT 1
- Cannot find module 'realm' from *** while using jest HOT 2
- Getting Error “Sync session became inactive” unhandled error HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-js.