apache / apache/bookkeeper

Question regarding refcount of ByteBuf in our client API

Aperta
#1,237 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
triage/week-33
Lingua principale
Java
Stelle
2k
Fork
976
Merge medio
6g 15h
PR unite (30g)
7

Descrizione

**QUESTION**

Regarding the refcount of ByteBuf, from what I understand the API method which takes ByteBuf as argument shouldn't increase or decrease the refcount of 'ReferenceCounted' object.

I mean
```
myApplicationMethod() {

ByteBuf byteBuf = createNewInstanceOfByteBuf();
...
APIClass.APIMethod(bytebuf);
...
byteBuf.release();
}
```
here when I create byteBuf the refCount would typically be 1. Now by passing this refcounted object to the standard API method, I don’t expect the APIMethod to decrease the refCount (modify refCount) and finally it is the responsibility of the caller (application) method to release it by calling release method explicitly when they are done with the byteBuf.

But in our case WriteAdvHandle.write(long entryId, ByteBuf data) is decreasing the refcount, this is because of https://github.com/apache/bookkeeper/blob/master/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java#L422 .

**Que:** Why are we doing this? What is the general practice with regards to usage of refcounted objects in API methods? Have we mentioned the expected behavior in detail in our API docs?

Are we doing corresponding release calls in all the places where ByteBuff is created. https://netty.io/4.0/api/io/netty/util/ReferenceCounted.html says that initial count would be 1 when an ReferenceCounted object is created.

Are there enough documentation/comments in code/invariant checks/testcases at each layer for ByteBuf usage in our Client and Server code?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java around the referenced release call, then compare the Client and Server ByteBuf creation and release paths with Netty's ReferenceCounted documentation. Determine the ownership contract for WriteAdvHandle.write(long entryId, ByteBuf data) and identify the relevant documentation, comments, invariant checks, or tests needed to make that contract explicit.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api, backend, distributed-systems
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.