Giter Site home page Giter Site logo

Comments (4)

reddycharan avatar reddycharan commented on September 26, 2024

yes, with this change org.apache.bookkeeper.auth.TestAuth$LogCloseCallsBookieAuthProviderFactory.close is called twice.

With or without this change BookieServer.shutdown will be called twice because of the following callstacks:

org.apache.bookkeeper.proto.BookieServer.shutdown(BookieServer.java:165)
org.apache.bookkeeper.test.BookKeeperClusterTestCase.restartBookies(BookKeeperClusterTestCase.java:424)
org.apache.bookkeeper.test.BookKeeperClusterTestCase.restartBookies(BookKeeperClusterTestCase.java:373)
org.apache.bookkeeper.auth.TestAuth.entryCount(TestAuth.java:91)
org.apache.bookkeeper.auth.TestAuth.testCloseMethodCalledOnAuthProvider(TestAuth.java:148)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

and

org.apache.bookkeeper.proto.BookieServer.shutdown(BookieServer.java:165)
org.apache.bookkeeper.proto.BookieServer$DeathWatcher.run(BookieServer.java:229)

now because of this change, for the second BookieServer.shutdown call, though 'running' value in BookieServer.shutdown method is false, it will call BookieNettyServer.shutdown, which will in turn call TestAuth$LogCloseCallsBookieAuthProviderFactory.close for the second time. But before this change if 'running' value is false in BookieServer.shutdown method, then it wont call BookieNettyServer.shutdown.

As i mentioned earlier relying on 'running' is not reliable way of handling shutdown logic, especially in the case of partial successful start or partial successful shutdown. Also, all the shutdown/close methods should be idempotent operations. for eg: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html#shutdown() https://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#close() .Similarly here calling BookieNettyServer.shutdown on second BookieServer.shutdown should be ok and it should be idempotent operation.

So fix for this testcase should be to change the expected value to '2' instead of '1' for this failure.

@eolivelli

from bookkeeper.

sijie avatar sijie commented on September 26, 2024

@reddycharan I don't think the right approach is to change to the tests. we should just make the shutdown call idempotent.

from bookkeeper.

eolivelli avatar eolivelli commented on September 26, 2024

@reddycharan @sijie the close method of the factory is expected to be called once.
I am OK with the fact that close methods should be idempotent too but if it is possible it is better to make the call to "close" once. It is cleaner and for the long term it is the best approch

from bookkeeper.

sijie avatar sijie commented on September 26, 2024

sorry I typed the wrong issue id at #437. revert the labels and milestone.

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.