fix the "gc state" warning
This commit is contained in:
parent
24facaab09
commit
409a9414f1
@ -202,7 +202,8 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
if (!conn.isSynced) {
|
if (!conn.isSynced) {
|
||||||
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
|
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
|
||||||
conn.isSynced = true
|
conn.isSynced = true
|
||||||
yield * this.garbageCollectAfterSync()
|
// It is safer to remove this!
|
||||||
|
// TODO: remove: yield * this.garbageCollectAfterSync()
|
||||||
// call whensynced listeners
|
// call whensynced listeners
|
||||||
for (var f of conn.whenSyncedListeners) {
|
for (var f of conn.whenSyncedListeners) {
|
||||||
f()
|
f()
|
||||||
@ -343,7 +344,8 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
}
|
}
|
||||||
defer.resolve()
|
defer.resolve()
|
||||||
})
|
})
|
||||||
/* then apply ds
|
/*
|
||||||
|
then apply ds
|
||||||
db.whenTransactionsFinished().then(() => {
|
db.whenTransactionsFinished().then(() => {
|
||||||
db.requestTransaction(function * () {
|
db.requestTransaction(function * () {
|
||||||
yield * this.applyDeleteSet(m.deleteSet)
|
yield * this.applyDeleteSet(m.deleteSet)
|
||||||
|
@ -39,6 +39,7 @@ export default function extendDatabase (Y /* :any */) {
|
|||||||
*/
|
*/
|
||||||
constructor (y, opts) {
|
constructor (y, opts) {
|
||||||
this.y = y
|
this.y = y
|
||||||
|
opts.gc = opts.gc === true
|
||||||
this.dbOpts = opts
|
this.dbOpts = opts
|
||||||
var os = this
|
var os = this
|
||||||
this.userId = null
|
this.userId = null
|
||||||
@ -121,7 +122,7 @@ export default function extendDatabase (Y /* :any */) {
|
|||||||
this.startRepairCheck()
|
this.startRepairCheck()
|
||||||
}
|
}
|
||||||
startGarbageCollector () {
|
startGarbageCollector () {
|
||||||
this.gc = this.dbOpts.gc == null || this.dbOpts.gc
|
this.gc = this.dbOpts.gc
|
||||||
if (this.gc) {
|
if (this.gc) {
|
||||||
this.gcTimeout = !this.dbOpts.gcTimeout ? 50000 : this.dbOpts.gcTimeout
|
this.gcTimeout = !this.dbOpts.gcTimeout ? 50000 : this.dbOpts.gcTimeout
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,25 @@ export async function garbageCollectUsers (t, users) {
|
|||||||
await Promise.all(users.map(u => u.db.emptyGarbageCollector()))
|
await Promise.all(users.map(u => u.db.emptyGarbageCollector()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. reconnect and flush all
|
||||||
|
* 2. user 0 gc
|
||||||
|
* 3. get type content
|
||||||
|
* 4. disconnect & reconnect all (so gc is propagated)
|
||||||
|
* 5. compare os, ds, ss
|
||||||
|
*/
|
||||||
export async function compareUsers (t, users) {
|
export async function compareUsers (t, users) {
|
||||||
|
await Promise.all(users.map(u => u.reconnect()))
|
||||||
|
if (users[0].connector.testRoom == null) {
|
||||||
|
await wait(100)
|
||||||
|
}
|
||||||
|
await flushAll(t, users)
|
||||||
|
|
||||||
|
await users[0].db.garbageCollect()
|
||||||
|
await users[0].db.garbageCollect()
|
||||||
|
|
||||||
|
var userTypeContents = users.map(u => u.share.array._content.map(c => c.val || JSON.stringify(c.type)))
|
||||||
|
|
||||||
// disconnect all except user 0
|
// disconnect all except user 0
|
||||||
await Promise.all(users.slice(1).map(async u =>
|
await Promise.all(users.slice(1).map(async u =>
|
||||||
u.disconnect()
|
u.disconnect()
|
||||||
@ -27,9 +45,6 @@ export async function compareUsers (t, users) {
|
|||||||
}
|
}
|
||||||
// reconnect all
|
// reconnect all
|
||||||
await Promise.all(users.map(u => u.reconnect()))
|
await Promise.all(users.map(u => u.reconnect()))
|
||||||
if (users[0].connector.testRoom != null) {
|
|
||||||
// flush for sync if test-connector
|
|
||||||
}
|
|
||||||
if (users[0].connector.testRoom == null) {
|
if (users[0].connector.testRoom == null) {
|
||||||
await wait(100)
|
await wait(100)
|
||||||
}
|
}
|
||||||
@ -40,13 +55,8 @@ export async function compareUsers (t, users) {
|
|||||||
})
|
})
|
||||||
))
|
))
|
||||||
|
|
||||||
await flushAll(t, users)
|
|
||||||
// types must be equal before garbage collect
|
|
||||||
var userTypeContents = users.map(u => u.share.array._content.map(c => c.val || JSON.stringify(c.type)))
|
|
||||||
var data = await Promise.all(users.map(async (u) => {
|
var data = await Promise.all(users.map(async (u) => {
|
||||||
var data = {}
|
var data = {}
|
||||||
await u.db.garbageCollect()
|
|
||||||
await u.db.garbageCollect()
|
|
||||||
u.db.requestTransaction(function * () {
|
u.db.requestTransaction(function * () {
|
||||||
var os = yield * this.getOperationsUntransformed()
|
var os = yield * this.getOperationsUntransformed()
|
||||||
data.os = {}
|
data.os = {}
|
||||||
@ -85,7 +95,7 @@ export async function initArrays (t, opts) {
|
|||||||
for (let i = 0; i < opts.users; i++) {
|
for (let i = 0; i < opts.users; i++) {
|
||||||
let y = await Y({
|
let y = await Y({
|
||||||
connector: connector,
|
connector: connector,
|
||||||
db: opts.db,
|
db: Object.assign({ gc: i === 0 }, opts.db), // Only one instance can gc!
|
||||||
share: share
|
share: share
|
||||||
})
|
})
|
||||||
result.users.push(y)
|
result.users.push(y)
|
||||||
@ -108,7 +118,7 @@ export async function initArrays (t, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function flushAll (t, users) {
|
export async function flushAll (t, users) {
|
||||||
users = users.filter(u => u.connector.isSynced)
|
// users = users.filter(u => u.connector.isSynced)
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user