fixed some gc issues (unfinished)
This commit is contained in:
parent
480dfdfb77
commit
93c23ddc09
@ -210,6 +210,8 @@ The promise returns an instance of Y. We denote it with a lower case `y`.
|
||||
* Returns a promise
|
||||
* y.db.stopGarbageCollector()
|
||||
* Stop the garbage collector. Call y.db.garbageCollect() to continue garbage collection
|
||||
* y.db.gc :: Boolean
|
||||
* Whether gc is turned on
|
||||
* y.db.gcTimeout :: Number (defaults to 50000 ms)
|
||||
* Time interval between two garbage collect cycles
|
||||
* It is required that all instances exchanged all messages after two garbage collect cycles (after 100000 ms per default)
|
||||
|
2
dist
2
dist
@ -1 +1 @@
|
||||
Subproject commit 7744993dde4e1be525cccc24fd47318bfe9892f8
|
||||
Subproject commit 549ab76b4215dab2299dbcbde271c810aae2ab51
|
@ -150,7 +150,10 @@ module.exports = function (Y/* :any */) {
|
||||
true otherwise
|
||||
*/
|
||||
findNextSyncTarget () {
|
||||
if (this.currentSyncTarget != null || this.isSynced) {
|
||||
if (this.y == null) {
|
||||
debugger
|
||||
}
|
||||
if (this.currentSyncTarget != null) {
|
||||
return // "The current sync has not finished!"
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,18 @@ module.exports = function (Y /* :any */) {
|
||||
}
|
||||
this.gc1 = [] // first stage
|
||||
this.gc2 = [] // second stage -> after that, remove the op
|
||||
this.gcTimeout = !opts.gcTimeout ? 50000 : opts.gcTimeouts
|
||||
this.gc = opts.gc == null || opts.gc
|
||||
if (this.gc) {
|
||||
this.gcTimeout = !opts.gcTimeout ? 50000 : opts.gcTimeout
|
||||
} else {
|
||||
this.gcTimeout = -1
|
||||
}
|
||||
|
||||
function garbageCollect () {
|
||||
return os.whenTransactionsFinished().then(function () {
|
||||
if (os.gc1.length > 0 || os.gc2.length > 0) {
|
||||
if (!os.y.isConnected()) {
|
||||
console.warn('gc should be empty when disconnected!')
|
||||
if (!os.y.isSynced) {
|
||||
console.warn('gc should be empty when not synced!')
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
os.requestTransaction(function * () {
|
||||
@ -149,7 +155,7 @@ module.exports = function (Y /* :any */) {
|
||||
clearInterval(this.repairCheckIntervalHandler)
|
||||
}
|
||||
queueGarbageCollector (id) {
|
||||
if (this.y.isConnected() && this.gcTimeout > 0) {
|
||||
if (this.y.isSynced && this.gc) {
|
||||
this.gc1.push(id)
|
||||
}
|
||||
}
|
||||
@ -204,7 +210,7 @@ module.exports = function (Y /* :any */) {
|
||||
TODO: rename this function
|
||||
|
||||
Rulez:
|
||||
* Only gc if this user is online & gcTimeout > 0
|
||||
* Only gc if this user is online & gc turned on
|
||||
* The most left element in a list must not be gc'd.
|
||||
=> There is at least one element in the list
|
||||
|
||||
@ -214,8 +220,8 @@ module.exports = function (Y /* :any */) {
|
||||
if (
|
||||
op.gc == null &&
|
||||
op.deleted === true &&
|
||||
this.store.gcTimeout > 0 &&
|
||||
this.y.isConnected()
|
||||
this.store.gc &&
|
||||
this.store.y.isSynced
|
||||
) {
|
||||
var gc = false
|
||||
if (left != null && left.deleted === true) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user