Giter Site home page Giter Site logo

Comments (6)

eolivelli avatar eolivelli commented on June 17, 2024

@merlimat @kishorekasi
do you have time to check ? at the moment you are the most netty 4 experts in the group

from bookkeeper.

kishorekasi avatar kishorekasi commented on June 17, 2024

from bookkeeper.

kishorekasi avatar kishorekasi commented on June 17, 2024

from bookkeeper.

sijie avatar sijie commented on June 17, 2024

marked this as a blocker for 4.5.0, since it seems to indicate some kind of reference leaking in current code base.

from bookkeeper.

sijie avatar sijie commented on June 17, 2024

@eolivelli @kishorekasi

@merlimat and me were looking together at this issue. @merlimat found the problem on how do we handling the invalid op code in v2 protocol.

in TestBackwardCompat#testCompact400, the test is to verify the current client can't talk to a 4.0.0 server.

The 4.5.0 client is sending a protobuf encoded request to 4.0.0 server. The 4.0.0 server will interpret the 4.5.0 protobuf encoded request, but it will realize this is bad request and sending v2 protocol encoded response. because the request is a bad request, 4.0.0 server sent a response back with unknown op code.

In current v2 ResponseEnDecoder (listed as below), when it doesn't know the op code, it will return the buffer to the channel. this might cause the misbehavior in the channel pipeline to decrement reference count.

`
@OverRide
public Object decode(ByteBuf buffer)
throws Exception {
int rc;
long ledgerId, entryId;

        int packetHeader = buffer.readInt();
        byte version = PacketHeader.getVersion(packetHeader);
        byte opCode = PacketHeader.getOpCode(packetHeader);

        switch (opCode) {
        case BookieProtocol.ADDENTRY:
            rc = buffer.readInt();
            ledgerId = buffer.readLong();
            entryId = buffer.readLong();
            return new BookieProtocol.AddResponse(version, rc, ledgerId, entryId);
        case BookieProtocol.READENTRY:
            rc = buffer.readInt();
            ledgerId = buffer.readLong();
            entryId = buffer.readLong();

            if (rc == BookieProtocol.EOK) {
                ByteBuf content = buffer.slice();
                return new BookieProtocol.ReadResponse(version, rc, ledgerId, entryId, content.retain());
            } else {
                return new BookieProtocol.ReadResponse(version, rc, ledgerId, entryId);
            }
        case BookieProtocol.AUTH:
            ByteBufInputStream bufStream = new ByteBufInputStream(buffer);
            BookkeeperProtocol.AuthMessage.Builder builder
                = BookkeeperProtocol.AuthMessage.newBuilder();
            builder.mergeFrom(bufStream, extensionRegistry);
            BookkeeperProtocol.AuthMessage am = builder.build();
            return new BookieProtocol.AuthResponse(version, am);
        default:
            return buffer;
        }
    }

`

One suggested fix from @merlimat is to throw exception in the EnDeCoder when receiving unknown op code. so the netty can close the connection, error out the pending requests and cleaning up the resources.

from bookkeeper.

eolivelli avatar eolivelli commented on June 17, 2024

@kishorekasi my error report was against an old version of the master.
I think that @merlimat suggestion is good. Can you give it a try?

from bookkeeper.

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.