[MDEV-31230] Fix CONNECT_JDBC in CMake Created: 2023-05-10  Updated: 2023-06-02  Resolved: 2023-06-02

Status: Closed
Project: MariaDB Server
Component/s: Configuration, Storage Engine - Connect
Affects Version/s: 10.4
Fix Version/s: N/A

Type: Bug Priority: Blocker
Reporter: Anel Husakovic Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Relates
relates to MDBF-560 Add openjdk to Buildbot builders Closed

 Description   
  1. CMake's Feature Summary is printing wrong information about variable CONNECT_JDBC (CONNECT_WITH_JDBC cached variable), that is by default ON

    - The following features have been disabled:
     * CONNECT_JDBC, Support for JDBC in the CONNECT storage engine
     * CONNECT_MONGODB, Support for MongoDB in the CONNECT storage engine
    

  2. Optimize the Cmake code by:
    1. making Java and JNI modules used by default Cmake module path
    2. making Java and JNI required


 Comments   
Comment by Anel Husakovic [ 2023-05-10 ]

With the suggested fix we get the following outputs:

  1. No java installed, error reported

    CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
      Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
      Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
      (Required is at least version "1.6")
    Call Stack (most recent call first):
      /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake-3.16/Modules/FindJava.cmake:332 (find_package_handle_standard_args)
      storage/connect/CMakeLists.txt:282 (FIND_PACKAGE)
    

  2. Install openjdk-11-jdk-headless (405MB), Java found, but not JNI:

    -- Found Java: /usr/bin/java (found suitable version "11.0.18", minimum required is "1.6") 
    CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
      Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_AWT_INCLUDE_PATH)
    Call Stack (most recent call first):
      /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake-3.16/Modules/FindJNI.cmake:372 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
      storage/connect/CMakeLists.txt:283 (FIND_PACKAGE)
    

  3. Here we need default-jdk (GUI based applications) only for building the package

    -- Found Java: /usr/bin/java (found suitable version "11.0.18", minimum required is "1.6") 
    -- Found JNI: /usr/lib/jvm/default-java/lib/libjawt.so  
     
    The following features have been enabled:
     * CONNECT_LIBXML2, Support for LIBXML2 in the CONNECT storage engine
     * CONNECT_ODBC, Support for ODBC in the CONNECT storage engine
     * CONNECT_JDBC, Support for JDBC in the CONNECT storage engine
    

  4. Feature Summary change

    -- The following REQUIRED packages have been found:
     
     * Curses
     * Java (required version >= 1.6)
     * JNI
    

  5. Appendix:
    I couldn't see the value of using user defined FindJava.cmake and FindJNI.cmake files instead of default modules, so removed it as stated in 2.1 of description of MDEV.
    • Without above files, without Java we get the error:

      -- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
      CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
        Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
        Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
        (Required is at least version "1.6")
      Call Stack (most recent call first):
        /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
        /usr/share/cmake-3.16/Modules/FindJava.cmake:332 (find_package_handle_standard_args)
        storage/connect/CMakeLists.txt:281 (FIND_PACKAGE)
      

    • With above files and no Java (additional file is checked as expected):

      CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
        Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY
        JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
      Call Stack (most recent call first):
        /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
        /usr/share/cmake-3.16/Modules/FindJNI.cmake:372 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
        cmake/FindJNI.cmake:12 (include)
        storage/connect/CMakeLists.txt:283 (FIND_PACKAGE)
      

Comment by Anel Husakovic [ 2023-05-31 ]

Pushed with 1d0e3d80d84c2. Thanks for review.

Comment by Sergei Golubchik [ 2023-06-01 ]

this broke compilation on kvm-bintar-freebsd123-amd64, kvm-bintar-freebsd130-amd64, kvm-bintar-trusty-amd64, kvm-bintar-trusty-x86, kvm-fulltest, kvm-fulltest2, kvm-rpm-rhel8-aarch64, kvm-rpm-rocky8-aarch64, winx64-debug. Additionally it broke srpm builds on kvm-rpm-rhel8-amd64, kvm-rpm-rhel8-ppc64le, kvm-rpm-rocky84-amd64, kvm-rpm-centos74-amd64-debug, kvm-rpm-centos74-amd64, kvm-rpm-alma84-amd64.

Comment by Anel Husakovic [ 2023-06-01 ]

danblack it seems default-jdk (debian/ubuntu) and java-11-openjdk-devel (rhel) is not installed on builders, example of getting the compilation error on aarch

-- Performing Test ODBC_OK - Success
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Java (missing: Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
  Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE) (found suitable version
  "1.8.0_372", minimum required is "1.6")
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindJava.cmake:336 (find_package_handle_standard_args)
  storage/connect/CMakeLists.txt:280 (FIND_PACKAGE)

And not sure do we need this :

   # Add file to populate CPACK_RPM_BUILDREQUIRES
    FIND_FILE(Libjni_h jni.h PATHS ${JAVA_INCLUDE_PATH})
    IF(NOT JAVA_JVM_LIBRARY_DEP)
      MESSAGE(FATAL_ERROR "No JAVA_JVM_LIBRARY_DEP set by FIND_JAVA")
    ENDIF()
    CPACK_RPM_connect-engine_PACKAGE_REQUIRES(${JAVA_JVM_LIBRARY_DEP})

serg, Daniel is off couple of days , should I revert the patch since I don't have access to buildbot machines?

Comment by Sergei Golubchik [ 2023-06-01 ]

revert of fix, whatever you prefer

Comment by Anel Husakovic [ 2023-06-02 ]

Hi serg

 
-- The following features have been disabled:
 * CONNECT_JDBC, Support for JDBC in the CONNECT storage engine - Missing JAVA/JNI
 
-- The following OPTIONAL packages have not been found:
 * Java (required version >= 1.6)
 * JNI
# Rerun:
-- Could NOT find Java (missing: Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE Java_JAVADOC_EXECUTABLE) (found suitable version "11.0.19", minimum required is "1.6")
-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 

I would go with Option 4.

Comment by Sergei Golubchik [ 2023-06-02 ]

removing FindJava and FindJNI wrappers was wrong too, they have a purpose (fix a specific issue in cmake's files) and this issue wasn't fixed in cmake yet (as of 3.26.3)

Comment by Sergei Golubchik [ 2023-06-02 ]

and cmake was not "printing wrong information about variable CONNECT_JDBC", there is no variable CONNECT_JDBC. There is a user-configurable setting CONNECT_WITH_JDBC which convey's user intention to enable the feature. It is ON by default. And there's a feature tag CONNECT_JDBC that shows in the summary whether the feature was actually enabled.

As such there's no bug here, so reverting.

If you want CONNECT_WITH_JDBC=ON to mean "absolutely enable JDBC or abort", then you cannot have it ON by default. Then you change CONNECT_WITH_JDBC to be a 3-value variable ON/OFF/AUTO with the default to AUTO. We have many variables like that: WITH_NUMA, MYSQL_MAINTAINER_MODE, ENABLED_LOCAL_INFILE, WITH_SAFEMALLOC, TRASH_FREED_MEMORY, WITH_INNODB_xxx, WITH_ROCKSDB_xxx, PLUGIN_xxx

Generated at Thu Feb 08 10:22:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.