Giter VIP home page Giter VIP logo

Comments (7)

HDT3213 avatar HDT3213 commented on August 16, 2024

明白, 还真有点难处理。我把 rewrite buffer 改到临时文件好了

from godis.

huangleee avatar huangleee commented on August 16, 2024

提供一种解决方法,如下:

image

from godis.

HDT3213 avatar HDT3213 commented on August 16, 2024

这个方案没有解决 aofRewriteBuffer <- cmd 会阻塞的问题。handleAof 被阻塞后,db.aofChan 很快也会填满,进而阻塞主协程的 addAof 函数, 最终导致所有写命令被阻塞,同时 goroutine 数量迅速上升。我觉得还是从源头上解决 aofRewriteBuffer 会被填满的问题比较好

from godis.

huangleee avatar huangleee commented on August 16, 2024

是的,上面的方案只是解决了死锁的问题。要解决aofRewriteBuffer阻塞的问题,还有个方法:

  1. 直接去掉aofRewriteBuffer,handleAof方法中,收到aofChan的数据后,获取锁,不再同步一份数据到aofRewriteBuffer。
  2. startRewrite方法中,已经获取到了aof 文件的filesize A,这个filesize在finishRewrite方法中可以用上。
  3. finishRewrite方法中,获取到锁之后,handleAof方法无法获取到锁,也就没办法继续往aof文件中写。finishRewrite方法此时再对aof文件sync落盘,此时从filesize A 到aof 文件尾,就是在重写aof文件过程中,处理的请求,直接将这些操作读出来写到临时文件,最后mv就行了

from godis.

HDT3213 avatar HDT3213 commented on August 16, 2024

好主意

from godis.

holicc avatar holicc commented on August 16, 2024

读取aof文件内容,加载内容到临时DB对象

如果当前数据库中有1G的数据,再加载一份AOF文件岂不是内存又多占用了1G?

from godis.

HDT3213 avatar HDT3213 commented on August 16, 2024

fixed in 48ba261

from godis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.