Giter Club home page Giter Club logo

Comments (4)

yuyijq avatar yuyijq commented on August 22, 2024 1
    //根据消息的延时时间(scheduleTime),计算该消息应该落在schedule log的哪个分片(segment)
    long baseOffset = resolveSegment(scheduleTime, segmentScale); 
     //如果该分片的偏移比当前正在投递的分片偏移小,则立即添加进内存时间轮
     if (baseOffset < currentBaseOffset) return true; 
      
     //如果该消息正好需要落在当前时间片
     if (baseOffset == currentBaseOffset) {
         //则判断该消息在当前schedule log segment里的偏移是否大于正在加载的最大偏移
         //如果大的话则立即加载到内存时间轮。
         //这里要注意的是,当加载任务决定要加载某个segment的时候,
         //就会立即固定住当时该segment的最大偏移,也就是currentOffset,
         //所以这样就不会将消息重复的加载 
         return currentOffset <= offset; 
     } 

from qmq.

yuyijq avatar yuyijq commented on August 22, 2024 1

@Ah39

不会的

// 这里的loadingCursor.cursor() 是返回的一个新实例的,所以currentCursor只在当前线程可见的,别的线程不会修改它的
WheelLoadCursor.Cursor currentCursor = loadingCursor.cursor();
int currentBaseOffset = currentCursor.getBaseOffset();
long currentOffset = currentCursor.getOffset();

from qmq.

Ah39 avatar Ah39 commented on August 22, 2024

这个里面,多线程好像会有问题

long currentBaseOffset = currentCursor.getBaseOffset();
long currentOffset = currentCursor.getOffset();

在第一行如果是获取到的是比如,2019040219这个小时是baseOffset,如果在极端情况下
假如2019040219 的offset为1500,2019040220这个小时的写入offset为1600
在执行第二句代码的时候,load任务改成了2019040220,offset变成了1600,第二行获取到的就是1600,
long currentOffset = currentCursor.getOffset();
会导致有些消息索引,没有写入时间轮

from qmq.

Ah39 avatar Ah39 commented on August 22, 2024

恩恩,是一个新实例,确实不会有多线程问题

from qmq.

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.