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

the new heap suddenly increase #163

Open
jiangxiaoqiang opened this issue Nov 28, 2023 · 3 comments
Open

the new heap suddenly increase #163

jiangxiaoqiang opened this issue Nov 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@jiangxiaoqiang
Copy link

jiangxiaoqiang commented Nov 28, 2023

Describe the bug

the y-websocket always restart automatically(I am deployment this application in kubernetes pod), I am using the grafana to monitor the y-websocket memory, now I found the momory are increase suddenly and there is no new connection to y-websoket. My document is small(less than 1MB).

image

Expected behavior

The momory could back to normal.

Screenshots

image

Environment Information

  • Node.js
  • y-websocket 1.5.0

I tried to dump the memory and found there have 50000+ map take 68% memory like this:

image

this is the level db file size:

[root@k8smasterone yjs-storage]# pwd
/data/k8s/reddwarf-pro/texhub-server-service/yjs-storage
[root@k8smasterone yjs-storage]# ls -alh
total 13M
drwxr-xr-x 2 root root 4.0K Nov 28 22:13 .
drwxr-xr-x 9 root root 4.0K Oct 18 22:54 ..
-rw-r--r-- 1 root root  450 Nov 28 22:16 001891.log
-rw-r--r-- 1 root root 5.3M Nov 28 22:13 001893.ldb
-rw-r--r-- 1 root root 3.3M Nov 28 22:13 001894.ldb
-rw-r--r-- 1 root root 3.3M Nov 28 22:13 001895.ldb
-rw-r--r-- 1 root root 780K Nov 28 22:13 001896.ldb
-rw-r--r-- 1 root root   16 Nov 28 22:03 CURRENT
-rw-r--r-- 1 root root    0 Sep 12 16:08 LOCK
-rw-r--r-- 1 root root 1.6K Nov 28 22:13 LOG
-rw-r--r-- 1 root root 1.7K Nov 28 20:32 LOG.old
-rw-r--r-- 1 root root 1.6K Nov 28 22:13 MANIFEST-001889

I have tried to diff the dump, somewhere map in the y-websocket did not release. this issue was look like the same with #145

@jiangxiaoqiang jiangxiaoqiang added the bug Something isn't working label Nov 28, 2023
@dmonad
Copy link
Member

dmonad commented Nov 28, 2023

The y-websocket server keeps all documents around forever, unless you specify a persistence provider (like y-leveldb). Is that what's happening?

@jiangxiaoqiang
Copy link
Author

The y-websocket server keeps all documents around forever, unless you specify a persistence provider (like y-leveldb). Is that what's happening?

I have already specify the leveldb and I also checked the level db only have 5MB. load the full db may not take so much memory.

@jiangxiaoqiang
Copy link
Author

jiangxiaoqiang commented Nov 28, 2023

the destroy function are just create a new map? I am confused with this:

if (doc.conns.size === 0 && persistence !== null) {
      // if persisted, we store state and destroy ydocument
      persistence.writeState(doc.name, doc).then(() => {
        doc.destroy()
      })
      docs.delete(doc.name)
    }

this is the destroy implement:

destroy () {
    this._observers = map.create()
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants