Skip to content

Commit d6c427b

Browse files
authored
Feature: Add UDP2 interconnect protocol implementation (#1357)
UDP2 is a next-generation interconnect protocol implementation that achieves complete decoupling between the interconnect layer and the database kernel. This implementation introduces: A layered architecture with adapter layer (ic_modules.c, ic_udp2.c) and core communication library (ic_common/) Lightweight data structures (ICCdbProcess, ICExecSlice) to replace complex database kernel structures Standardized C/C++ interfaces for database-agnostic communication CMake-based build system supporting independent compilation Unified error handling mechanism with configurable error levels Key benefits: Independent development and evolution of interconnect layer End-to-end testing without database kernel dependency Clear interface boundaries for easier extension and maintenance Rapid diagnosis of interconnect vs kernel issues
1 parent 12b43e3 commit d6c427b

29 files changed

+12578
-0
lines changed

GNUmakefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ ifeq ($(with_openssl), yes)
3434
endif
3535
ifeq ($(enable_pax), yes)
3636
$(MAKE) -C contrib/pax_storage all
37+
endif
38+
ifeq ($(enable_ic_udp2),yes)
39+
$(MAKE) -C contrib/udp2 all
3740
endif
3841
$(MAKE) -C gpMgmt all
3942
$(MAKE) -C gpcontrib all
@@ -81,6 +84,9 @@ ifeq ($(enable_pax), yes)
8184
endif
8285
ifeq ($(with_openssl), yes)
8386
$(MAKE) -C contrib/sslinfo $@
87+
endif
88+
ifeq ($(enable_ic_udp2),yes)
89+
$(MAKE) -C contrib/udp2 $@
8490
endif
8591
$(MAKE) -C gpMgmt $@
8692
$(MAKE) -C gpcontrib $@

configure

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ PROTOBUF_LIBS
761761
PROTOBUF_CFLAGS
762762
enable_preload_ic_module
763763
enable_ic_proxy
764+
enable_ic_udp2
764765
enable_external_fts
765766
HAVE_CXX14
766767
enable_gpcloud
@@ -909,6 +910,7 @@ enable_shared_postgres_backend
909910
enable_link_postgres_with_shared
910911
enable_gpcloud
911912
enable_external_fts
913+
enable_ic_udp2
912914
enable_ic_proxy
913915
enable_preload_ic_module
914916
enable_pax
@@ -1629,6 +1631,7 @@ Optional Features:
16291631
libpostgres.so
16301632
--enable-gpcloud enable gpcloud support
16311633
--enable-external-fts enable external fts support
1634+
--enable-ic-udp2 enable interconnect udp2 implement
16321635
--enable-ic-proxy enable interconnect proxy mode (requires libuv
16331636
library)
16341637
--disable-preload-ic-module
@@ -9181,6 +9184,38 @@ $as_echo "#define USE_INTERNAL_FTS 1" >>confdefs.h
91819184
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
91829185
fi
91839186

9187+
#
9188+
# ic-udp2
9189+
#
9190+
9191+
9192+
# Check whether --enable-ic-udp2 was given.
9193+
if test "${enable_ic_udp2+set}" = set; then :
9194+
enableval=$enable_ic_udp2;
9195+
case $enableval in
9196+
yes)
9197+
9198+
$as_echo "#define ENABLE_IC_UDP2 1" >>confdefs.h
9199+
9200+
;;
9201+
no)
9202+
:
9203+
;;
9204+
*)
9205+
as_fn_error $? "no argument expected for --enable-ic-udp2 option" "$LINENO" 5
9206+
;;
9207+
esac
9208+
9209+
else
9210+
enable_ic_udp2=no
9211+
9212+
fi
9213+
9214+
9215+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&5
9216+
$as_echo "checking whether to build with interconnect udp2 support ... $enable_ic_udp2" >&6; }
9217+
9218+
91849219
#
91859220
# ic-proxy
91869221
#

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,16 @@ if test "$enable_external_fts" = no; then
923923
CFLAGS="$CFLAGS -DUSE_INTERNAL_FTS=1"
924924
fi
925925

926+
#
927+
# ic-udp2
928+
#
929+
PGAC_ARG_BOOL(enable, ic-udp2, no,
930+
[enable interconnect udp2 implement],
931+
[AC_DEFINE(ENABLE_IC_UDP2, 1,
932+
[Define to 1 to build with interconnect udp2 support (--enable-ic-udp2)])])
933+
AC_MSG_RESULT([checking whether to build with interconnect udp2 support ... $enable_ic_udp2])
934+
AC_SUBST(enable_ic_udp2)
935+
926936
#
927937
# ic-proxy
928938
#

contrib/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ else
104104
ALWAYS_SUBDIRS += pax_storage
105105
endif
106106

107+
ifeq ($(enable_ic_udp2),yes)
108+
SUBDIRS += udp2
109+
else
110+
ALWAYS_SUBDIRS += udp2
111+
endif
112+
107113
# Missing:
108114
# start-scripts \ (does not have a makefile)
109115

contrib/udp2/CMakeLists.txt

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
cmake_minimum_required(VERSION 3.11.0)
19+
project(udp2)
20+
21+
set(CMAKE_CXX_STANDARD 14)
22+
set(CMAKE_CXX_STANDARD_REQUIRED True)
23+
24+
# Get the top-level project directory
25+
set(TOP_DIR ${PROJECT_SOURCE_DIR}/../..)
26+
set(CBDB_INCLUDE_DIR ${TOP_DIR}/src/include)
27+
28+
# CMAKE_INSTALL_PREFIX should be set by the calling Makefile
29+
# If not set, we'll use a reasonable default but warn about it
30+
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
31+
message(WARNING "CMAKE_INSTALL_PREFIX not set by parent build system, using default")
32+
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install prefix" FORCE)
33+
endif()
34+
35+
# Check for debug/release configuration from main project
36+
include(CheckSymbolExists)
37+
set(PG_CONFIG_HEADER_FILE "${CBDB_INCLUDE_DIR}/pg_config.h")
38+
if(EXISTS "${PG_CONFIG_HEADER_FILE}")
39+
CHECK_SYMBOL_EXISTS(USE_ASSERT_CHECKING "${PG_CONFIG_HEADER_FILE}" UDP2_USE_DEBUG)
40+
if(UDP2_USE_DEBUG)
41+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
42+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Debug' based on main project configuration")
43+
else()
44+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
45+
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Release' based on main project configuration")
46+
endif()
47+
else()
48+
# Fallback to Release if pg_config.h is not found
49+
if(NOT CMAKE_BUILD_TYPE)
50+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
51+
message(STATUS "Setting default CMAKE_BUILD_TYPE to 'Release'")
52+
endif()
53+
endif()
54+
55+
# First, build and install ic_common as a subdirectory
56+
add_subdirectory(ic_common)
57+
58+
# Set up include directories
59+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
60+
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/)
61+
include_directories(${CMAKE_INSTALL_PREFIX}/include/postgresql/udp2/)
62+
include_directories(${CBDB_INCLUDE_DIR})
63+
include_directories(${CBDB_INCLUDE_DIR}/server)
64+
65+
# Set up library directories
66+
link_directories(${CMAKE_INSTALL_PREFIX}/lib/postgresql/)
67+
68+
# Source files for udp2 module
69+
set(UDP2_SOURCES
70+
ic_udp2.c
71+
ic_modules.c
72+
)
73+
74+
# Create the udp2 shared library
75+
add_library(udp2 SHARED ${UDP2_SOURCES})
76+
77+
# Set compiler flags consistent with main project
78+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv")
79+
80+
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
81+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -ggdb")
82+
message(STATUS "Building udp2 in Debug mode")
83+
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
84+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O2 -DNDEBUG")
85+
message(STATUS "Building udp2 in Release mode")
86+
endif()
87+
88+
# Link against ic_common library
89+
target_link_libraries(udp2 ic_common)
90+
91+
# Make sure ic_common is built before udp2
92+
add_dependencies(udp2 ic_common)
93+
94+
# Set output name and remove lib prefix
95+
set_target_properties(udp2 PROPERTIES
96+
OUTPUT_NAME "udp2"
97+
PREFIX ""
98+
)
99+
100+
# Install the udp2 library
101+
install(TARGETS udp2
102+
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
103+
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/postgresql/"
104+
)
105+
106+
# Install udp2 headers
107+
install(FILES
108+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_udp2.h"
109+
"${CMAKE_CURRENT_SOURCE_DIR}/ic_modules.h"
110+
DESTINATION "${CMAKE_INSTALL_PREFIX}/include/postgresql/"
111+
)

contrib/udp2/Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
# contrib/udp2/Makefile
18+
19+
top_builddir = ../..
20+
21+
# Include the standard PostgreSQL build system to get variables like prefix, DESTDIR, etc.
22+
ifdef USE_PGXS
23+
PG_CONFIG = pg_config
24+
PGXS := $(shell $(PG_CONFIG) --pgxs)
25+
include $(PGXS)
26+
else
27+
subdir = contrib/udp2
28+
include $(top_builddir)/src/Makefile.global
29+
include $(top_srcdir)/contrib/contrib-global.mk
30+
endif
31+
32+
# Use CMake for building this module
33+
CMAKE_BUILD_DIR = build
34+
35+
# Default target
36+
all: $(CMAKE_BUILD_DIR)/udp2.so
37+
38+
# Create build directory and configure with CMake
39+
$(CMAKE_BUILD_DIR)/Makefile:
40+
@echo "Configuring udp2 with CMake..."
41+
@mkdir -p $(CMAKE_BUILD_DIR)
42+
@cd $(CMAKE_BUILD_DIR) && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) ..
43+
44+
# Build the project using CMake
45+
$(CMAKE_BUILD_DIR)/udp2.so: $(CMAKE_BUILD_DIR)/Makefile
46+
@echo "Building udp2 with CMake..."
47+
@cd $(CMAKE_BUILD_DIR) && $(MAKE)
48+
@cp $(CMAKE_BUILD_DIR)/udp2.so udp2.so
49+
50+
# Install target
51+
install: $(CMAKE_BUILD_DIR)/udp2.so
52+
@echo "Installing udp2..."
53+
@cd $(CMAKE_BUILD_DIR) && $(MAKE) install
54+
55+
# Clean target
56+
clean:
57+
@echo "Cleaning udp2..."
58+
@rm -rf $(CMAKE_BUILD_DIR)
59+
@rm -f udp2.so
60+
61+
# Ensure ic_common is built first
62+
ic_common:
63+
@echo "Building ic_common..."
64+
@mkdir -p ic_common/build
65+
@cd ic_common/build && cmake -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(prefix) .. && $(MAKE) && $(MAKE) install
66+
67+
# Make sure ic_common is built before udp2
68+
$(CMAKE_BUILD_DIR)/udp2.so: ic_common
69+
70+
.PHONY: all install clean ic_common

0 commit comments

Comments
 (0)