Skip to content

Instantly share code, notes, and snippets.

@yuvalif
Last active March 20, 2024 12:20
Show Gist options
  • Save yuvalif/26ff6c115a8386d1d47f2ed4e38cfd39 to your computer and use it in GitHub Desktop.
Save yuvalif/26ff6c115a8386d1d47f2ed4e38cfd39 to your computer and use it in GitHub Desktop.

From RADOS to REDIS

Background

Bucket notifications are important building block in the object storage ecosystem. And persistent bucket notifications in particular, as they let the system overcome broker outages. However, since the persistent notifications are backed with a RADOS queue, they have a cost. Both in the extra load on the RADOS cluster, and with the inability to operate in environemnts where there is no RADOS backend. In this project, we would like to implement persistent bucket notifications in the RADOS Gateway using a Redis Queue. Combined with the "zipper" project we would be able to enjoy bucket notifications with backends like posix, dbstore, daos etc.

Note that on top of using RADOS for the notification queue, our code is depended with RADOS with its implementation of a distributed lock (to make sure that one and only one RGW serve a queue at a given point in time). as well as the fact that topic and notification configuration stored inside RADOS objets.

Evaluation Stage

Step 1 - Build Ceph and Test Bucket Notifications

First would be to have a linux based development environment, as a minimum you would need a 4 CPU machine, with 8G RAM and 50GB disk. Unless you already have a linux distro you like, I would recommend choosing from:

  • Fedora (38/39) - my favorite!
  • Ubuntu (22.04 LTS)
  • WSL (Windows Subsystem for Linux), though it would probably take much longer...
  • RHEL9/Centos9
  • Other Linux distros - try at your own risk :-)

Once you have that up and running, you should clone the Ceph repo from github (https://github.com/ceph/ceph). If you don’t know what github and git are, this is the right time to close these gaps :-) And yes, you should have a github account, so you can later share your work on the project.

Install any missing system dependencies use:

./install-deps.sh

Note that, the first build may take long time, so the following cmake parameter could be used to minimize the build time. With a fresh ceph clone use the following:

./do_cmake.sh -DBOOST_J=$(nproc) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_MGR_DASHBOARD_FRONTEND=OFF \
  -DWITH_DPDK=OFF -DWITH_SPDK=OFF -DWITH_SEASTAR=OFF -DWITH_CEPHFS=OFF -DWITH_RBD=OFF -DWITH_KRBD=OFF -DWITH_CCACHE=OFF

if the build directory already exists, you can rebuild the ninja files by using (from build):

cmake -DBOOST_J=$(nproc) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_MGR_DASHBOARD_FRONTEND=OFF \
  -DWITH_DPDK=OFF -DWITH_SPDK=OFF -DWITH_SEASTAR=OFF -DWITH_CEPHFS=OFF -DWITH_RBD=OFF -DWITH_KRBD=OFF -DWITH_CCACHE=OFF ..

then invoke the build process (using ninja) from within the build directory (created by do_cmake.sh). Assuming the build was completed successfully, you can run the unit tests (see: https://github.com/ceph/ceph#running-unit-tests).

Now you are ready to run the ceph processes, as explained here: https://github.com/ceph/ceph#running-a-test-cluster You probably would also like to check the developer guide (https://docs.ceph.com/docs/master/dev/developer_guide/) and learn more on how to build Ceph and run it locally (https://docs.ceph.com/docs/master/dev/quick_guide/). Ceph's bucket noptification documentation:

Run bucket notification tests for persistent notifications using an HTTP endpoint:

  • start the vtsart cluster:
$ MON=1 OSD=1 MDS=0 MGR=0 RGW=1 ../src/vstart.sh -n -d
  • on a separate terminal start an HTTP endpoint:
$ wget https://gist.githubusercontent.com/mdonkers/63e115cc0c79b4f6b8b3a6b797e485c7/raw/a6a1d090ac8549dac8f2bd607bd64925de997d40/server.py
$ python server.py 10900
  • install the awc cli tool
  • configure the tool according to the access and secret keys showing in the output of the vstart.sh command
  • set the region to default
  • create a persistent topic pointing to the above HTTP endpoint:
$ aws --endpoint-url http://localhost:8000 sns create-topic --name=fishtopic \
  --attributes='{"push-endpoint": "http://localhost:10900", "persistent": "true"}'
  • create a bucket:
$ aws --endpoint-url http://localhost:8000 s3 mb s3://fish
  • create a notification on that bucket, pointing to the above topic:
$ aws --endpoint-url http://localhost:8000 s3api put-bucket-notification-configuration  --bucket fish \
  --notification-configuration='{"TopicConfigurations": [{"Id": "notif1", "TopicArn": "arn:aws:sns:default::fishtopic", "Events": []}]}'

Leaving the event list empty is equivalent to setting it to ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]

  • create a file, and upload it:
$ head -c 512 </dev/urandom > myfile
$ aws --endpoint-url http://localhost:8000 s3 cp myfile s3://fish
  • on the HTTP terminal, see the JSON output of the notifications

Step 2 - Build Test Tools

using the boost Redis client:

  • write a standalone client that pushes to the Redis Queue (input could be stdin, or any other option)
  • write a standalone client that pull from the Redis Queue (output could be stdout, or any other option)

Note that currently Ceph as a Redis cpp client that we have as a submodule, but this will be changed soon in favor of boost Redis.

  • optional: using gtest write a unit test that excersite the above clients

Project Goals

  • create an abstraction layer that could be implemented using cls_2pc_queue or a REDIS client
  • use this abstraction layer in the bucket notification code and break its dependency with RADOS
  • implement using boost redis client (that soon will be incorporated as a submodule in the Ceph source tree)
  • add a config option to select the implementation used in runtime
  • add test and setup instructions when using RADOS backend

Stretch Goal

  • create an abstraction layer for cls lock
  • use this abstraction layer in the bucket notification code
  • implement using our cpp redis submodule. see: redis distributed lock
  • move rgw_notify.cc outside of the driver/rados directory
  • test and setup instructions when using a non-RADOS backend (e.g. posix)
@yuvalif
Copy link
Author

yuvalif commented Mar 11, 2024

ancjainil

@ancjainil, it would be great if you can prepare a small repo with the code fro the redis producer and consumer of the queue.
together with a readme that would allow me to build, run your code and test it.
as an optiona task, you can create a gtest based unit test that run it as well.

@ancjainil
Copy link

@yuvalif, here is the demo code repository for the Redis queue including a gtest that runs it as well. Let me know if you have any doubts and do let me know any next tasks.

Thanks

Repo link: https://github.com/ancjainil/Redis-producer-consumer/tree/master

@9401adarsh
Copy link

9401adarsh commented Mar 13, 2024

Hello @yuvalif, I am currently facing errors when I try to run an example file from the Boost.redis repository. I had to download Boost 1.84.0 from source and I built them under the home directory, as Boost.redis is automatically present in Boost 1.84.0.

Build Output:

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    /home/adarsh9401/boost_1_84_0

The following directory should be added to linker library paths:

    /home/adarsh9401/boost_1_84_0/stage/lib

Now, in order to test if my source installation was valid I ran the following boost-version.cpp file to test if the installation was successful.

#include <boost/version.hpp>
#include <iostream>
#include <iomanip>

int main()
{
    std::cout << "Boost version: " 
          << BOOST_VERSION / 100000
          << "."
          << BOOST_VERSION / 100 % 1000
          << "."
          << BOOST_VERSION % 100 
          << std::endl;
    return 0;
}

I compiled this file as follows:

g++  boost-version.cpp -o boost-version.exe -I /home/adarsh9401/boost_1_84_0

This file successfully compiled, and gave the following output.

Boost version: 1.84.0

Now, when I compiled this example file (https://github.com/boostorg/redis/blob/develop/example/cpp17_intro.cpp) from the Boost Redis repository using the following command - (I have named the file as boost-redis-test.cpp on my local)

g++ boost-redis-test.cpp -o boost-redis.exe -I /home/adarsh9401/boost_1_84_0

I get the following errors:

/usr/bin/ld: /tmp/cc4ct3eW.o: in function `main':
boost-redis-test.cpp:(.text+0x377): undefined reference to `boost::redis::connection::connection(boost::asio::io_context&, boost::asio::ssl::context_base::method, unsigned long)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `auto main::{lambda(auto:1, auto:2)#1}::operator()<boost::system::error_code, unsigned long>(boost::system::error_code, unsigned long) const':
boost-redis-test.cpp:(.text+0x1094): undefined reference to `boost::redis::connection::cancel(boost::redis::operation)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::redis::request::check_cmd(std::basic_string_view<char, std::char_traits<char> >)':
boost-redis-test.cpp:(.text._ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE[_ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE]+0x43): undefined reference to `boost::redis::detail::has_response(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::asio::error::detail::ssl_category::message[abi:cxx11](int) const':
boost-redis-test.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x1d): undefined reference to `ERR_reason_error_string'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei[_ZNK5boost4asio5error6detail12ssl_category7messageB5cxx11Ei]+0x39): undefined reference to `ERR_lib_error_string'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::asio::ssl::context::~context()':
boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0x27): undefined reference to `SSL_CTX_get_default_passwd_cb_userdata'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0x66): undefined reference to `SSL_CTX_set_default_passwd_cb_userdata'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0x7a): undefined reference to `SSL_CTX_get_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0x98): undefined reference to `SSL_CTX_get_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0xcd): undefined reference to `SSL_CTX_set_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl7contextD2Ev[_ZN5boost4asio3ssl7contextD5Ev]+0xdc): undefined reference to `SSL_CTX_free'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::asio::ssl::detail::engine::~engine()':
boost-redis-test.cpp:(.text._ZN5boost4asio3ssl6detail6engineD2Ev[_ZN5boost4asio3ssl6detail6engineD5Ev]+0x28): undefined reference to `SSL_get_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl6detail6engineD2Ev[_ZN5boost4asio3ssl6detail6engineD5Ev]+0x51): undefined reference to `SSL_get_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl6detail6engineD2Ev[_ZN5boost4asio3ssl6detail6engineD5Ev]+0x7e): undefined reference to `SSL_set_ex_data'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl6detail6engineD2Ev[_ZN5boost4asio3ssl6detail6engineD5Ev]+0x9b): undefined reference to `BIO_free'
/usr/bin/ld: boost-redis-test.cpp:(.text._ZN5boost4asio3ssl6detail6engineD2Ev[_ZN5boost4asio3ssl6detail6engineD5Ev]+0xb6): undefined reference to `SSL_free'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::system::error_code::error_code<boost::redis::error>(boost::redis::error, boost::system::detail::enable_if<boost::system::is_error_code_enum<boost::redis::error>::value||std::is_error_code_enum<boost::redis::error>::value, void>::type*)':
boost-redis-test.cpp:(.text._ZN5boost6system10error_codeC2INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE[_ZN5boost6system10error_codeC5INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE]+0x47): undefined reference to `boost::redis::make_error_code(boost::redis::error)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `void boost::redis::request::push<char [12]>(std::basic_string_view<char, std::char_traits<char> >, char const (&) [12])':
boost-redis-test.cpp:(.text._ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_[_ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_]+0x3f): undefined reference to `boost::redis::resp3::add_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::redis::resp3::type, unsigned long)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `auto boost::redis::connection::async_run<boost::asio::detached_t>(boost::redis::config const&, boost::redis::logger, boost::asio::detached_t)::{lambda(auto:1, boost::redis::connection*, boost::redis::config const*, boost::redis::logger)#1}::operator()<boost::asio::detail::detached_handler>(boost::asio::detail::detached_handler, boost::redis::connection*, boost::redis::config const*, boost::redis::logger) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_[_ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_]+0x6d): undefined reference to `boost::redis::connection::async_run_impl(boost::redis::config const&, boost::redis::logger, boost::asio::any_completion_handler<void (boost::system::error_code)>)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `boost::redis::resp3::add_bulk_impl<std::basic_string_view<char, std::char_traits<char> > >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> > const&)':
boost-redis-test.cpp:(.text._ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_[_ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_]+0x26): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/cc4ct3eW.o: in function `auto boost::redis::resp3::add_bulk_impl<std::tuple<char const (&) [12]> >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::tuple<char const (&) [12]> const&)::{lambda((auto:1 const&)...)#1}::operator()<char [12]>(char const (&) [12]) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_[_ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_]+0x39): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
collect2: error: ld returned 1 exit status

After going through stackoverflow, I compiled with the following, which did reduce the errors:

 g++ boost-redis-test.cpp -o boost-redis.exe -I /home/adarsh9401/boost_1_84_0 -lboost_system -lboost_thread -lpthread -lssl -lcrypto

On Compilation:


/usr/bin/ld: /tmp/cccwGPW7.o: in function `main':
boost-redis-test.cpp:(.text+0x377): undefined reference to `boost::redis::connection::connection(boost::asio::io_context&, boost::asio::ssl::context_base::method, unsigned long)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `auto main::{lambda(auto:1, auto:2)#1}::operator()<boost::system::error_code, unsigned long>(boost::system::error_code, unsigned long) const':
boost-redis-test.cpp:(.text+0x1094): undefined reference to `boost::redis::connection::cancel(boost::redis::operation)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `boost::redis::request::check_cmd(std::basic_string_view<char, std::char_traits<char> >)':
boost-redis-test.cpp:(.text._ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE[_ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE]+0x43): undefined reference to `boost::redis::detail::has_response(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `boost::system::error_code::error_code<boost::redis::error>(boost::redis::error, boost::system::detail::enable_if<boost::system::is_error_code_enum<boost::redis::error>::value||std::is_error_code_enum<boost::redis::error>::value, void>::type*)':
boost-redis-test.cpp:(.text._ZN5boost6system10error_codeC2INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE[_ZN5boost6system10error_codeC5INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE]+0x47): undefined reference to `boost::redis::make_error_code(boost::redis::error)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `void boost::redis::request::push<char [12]>(std::basic_string_view<char, std::char_traits<char> >, char const (&) [12])':
boost-redis-test.cpp:(.text._ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_[_ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_]+0x3f): undefined reference to `boost::redis::resp3::add_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::redis::resp3::type, unsigned long)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `auto boost::redis::connection::async_run<boost::asio::detached_t>(boost::redis::config const&, boost::redis::logger, boost::asio::detached_t)::{lambda(auto:1, boost::redis::connection*, boost::redis::config const*, boost::redis::logger)#1}::operator()<boost::asio::detail::detached_handler>(boost::asio::detail::detached_handler, boost::redis::connection*, boost::redis::config const*, boost::redis::logger) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_[_ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_]+0x6d): undefined reference to `boost::redis::connection::async_run_impl(boost::redis::config const&, boost::redis::logger, boost::asio::any_completion_handler<void (boost::system::error_code)>)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `boost::redis::resp3::add_bulk_impl<std::basic_string_view<char, std::char_traits<char> > >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> > const&)':
boost-redis-test.cpp:(.text._ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_[_ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_]+0x26): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/cccwGPW7.o: in function `auto boost::redis::resp3::add_bulk_impl<std::tuple<char const (&) [12]> >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::tuple<char const (&) [12]> const&)::{lambda((auto:1 const&)...)#1}::operator()<char [12]>(char const (&) [12]) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_[_ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_]+0x39): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
collect2: error: ld returned 1 exit status

Could you suggest on how to proceed ?

@dynamic-entropy
Copy link

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/home/adarsh9401/boost_1_84_0

The following directory should be added to linker library paths:

/home/adarsh9401/boost_1_84_0/stage/lib

Hi Adarsh
I believe you also need to add /home/adarsh9401/boost_1_84_0/stage/lib to your linkers search path.
This would be done with the -L flag (similar to -I for adding files to your compiler's search path).

You can also try removing the -lboost_system and other additional flags which uses the systems boost library as opposed to the one you installed. (Note the l in the -lboost_system).

Cheers

@9401adarsh
Copy link

@dynamic-entropy , thanks for the reply!

I tried compiling the file using the following command:

g++ boost-redis-test.cpp -o boost-redis-test.exe -I /home/adarsh9401/boost_1_84_0 -L /home/adarsh9401/boost_1_84_0/stage/lib -l ssl -l pthread -l crypto

I got the following error, the same as before.

/usr/bin/ld: /tmp/ccXgT0a9.o: in function `main':
boost-redis-test.cpp:(.text+0x377): undefined reference to `boost::redis::connection::connection(boost::asio::io_context&, boost::asio::ssl::context_base::method, unsigned long)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `auto main::{lambda(auto:1, auto:2)#1}::operator()<boost::system::error_code, unsigned long>(boost::system::error_code, unsigned long) const':
boost-redis-test.cpp:(.text+0x1094): undefined reference to `boost::redis::connection::cancel(boost::redis::operation)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `boost::redis::request::check_cmd(std::basic_string_view<char, std::char_traits<char> >)':
boost-redis-test.cpp:(.text._ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE[_ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE]+0x43): undefined reference to `boost::redis::detail::has_response(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `boost::system::error_code::error_code<boost::redis::error>(boost::redis::error, boost::system::detail::enable_if<boost::system::is_error_code_enum<boost::redis::error>::value||std::is_error_code_enum<boost::redis::error>::value, void>::type*)':
boost-redis-test.cpp:(.text._ZN5boost6system10error_codeC2INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE[_ZN5boost6system10error_codeC5INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE]+0x47): undefined reference to `boost::redis::make_error_code(boost::redis::error)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `void boost::redis::request::push<char [12]>(std::basic_string_view<char, std::char_traits<char> >, char const (&) [12])':
boost-redis-test.cpp:(.text._ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_[_ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_]+0x3f): undefined reference to `boost::redis::resp3::add_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::redis::resp3::type, unsigned long)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `auto boost::redis::connection::async_run<boost::asio::detached_t>(boost::redis::config const&, boost::redis::logger, boost::asio::detached_t)::{lambda(auto:1, boost::redis::connection*, boost::redis::config const*, boost::redis::logger)#1}::operator()<boost::asio::detail::detached_handler>(boost::asio::detail::detached_handler, boost::redis::connection*, boost::redis::config const*, boost::redis::logger) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_[_ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_]+0x6d): undefined reference to `boost::redis::connection::async_run_impl(boost::redis::config const&, boost::redis::logger, boost::asio::any_completion_handler<void (boost::system::error_code)>)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `boost::redis::resp3::add_bulk_impl<std::basic_string_view<char, std::char_traits<char> > >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> > const&)':
boost-redis-test.cpp:(.text._ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_[_ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_]+0x26): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/ccXgT0a9.o: in function `auto boost::redis::resp3::add_bulk_impl<std::tuple<char const (&) [12]> >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::tuple<char const (&) [12]> const&)::{lambda((auto:1 const&)...)#1}::operator()<char [12]>(char const (&) [12]) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_[_ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_]+0x39): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
collect2: error: ld returned 1 exit status

@dynamic-entropy
Copy link

Apologies, I did not intend to say that you add a space after -l.
I wanted to point to the fact that those flags are asking the linker to link those libraries. You may remove the space.

The -L would tell your linker the path to search in. But it won't link those libraries.
You will also need to explicitly add -lboost_redis. (And possibly others, for e.g. boost_asio too).

Try doing a ls in /home/adarsh9401/boost_1_84_0/stage/lib.
You will see the file names to use.
Hope this helps.

Cheers

@9401adarsh
Copy link

9401adarsh commented Mar 13, 2024

@dynamic-entropy as suggested, I ran the following commands

adarsh9401@fedora:~/Desktop/Dev/scripts/cpp1$ ls -a /home/adarsh9401/boost_1_84_0/stage/lib | grep redis
adarsh9401@fedora:~/Desktop/Dev/scripts/cpp1$ ls -a /home/adarsh9401/boost_1_84_0/stage/lib | grep asio

For which there were no outputs, which makes sense atleast in the case of Boost.asio, which is a header-only library.

The same error persists, even while ignoring the space for -l and keeping -L flag as per your recommendation.

adarsh9401@fedora:~/Desktop/Dev/scripts/cpp1$ g++ boost-redis-test.cpp -o boost-redis-test.exe -I/home/adarsh9401/boost_1_84_0 -L/home/adarsh9401/boost_1_84_0/stage/lib -lpthread -lssl -lcrypto -lboost_system -lboost_thread

Error log:

/usr/bin/ld: /tmp/ccmIdN9x.o: in function `main':
boost-redis-test.cpp:(.text+0x377): undefined reference to `boost::redis::connection::connection(boost::asio::io_context&, boost::asio::ssl::context_base::method, unsigned long)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `auto main::{lambda(auto:1, auto:2)#1}::operator()<boost::system::error_code, unsigned long>(boost::system::error_code, unsigned long) const':
boost-redis-test.cpp:(.text+0x1094): undefined reference to `boost::redis::connection::cancel(boost::redis::operation)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `boost::redis::request::check_cmd(std::basic_string_view<char, std::char_traits<char> >)':
boost-redis-test.cpp:(.text._ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE[_ZN5boost5redis7request9check_cmdESt17basic_string_viewIcSt11char_traitsIcEE]+0x43): undefined reference to `boost::redis::detail::has_response(std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `boost::system::error_code::error_code<boost::redis::error>(boost::redis::error, boost::system::detail::enable_if<boost::system::is_error_code_enum<boost::redis::error>::value||std::is_error_code_enum<boost::redis::error>::value, void>::type*)':
boost-redis-test.cpp:(.text._ZN5boost6system10error_codeC2INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE[_ZN5boost6system10error_codeC5INS_5redis5errorEEET_PNS0_6detail9enable_ifIXoosrNS0_18is_error_code_enumIS5_EE5valuesrSt18is_error_code_enumIS5_E5valueEvE4typeE]+0x47): undefined reference to `boost::redis::make_error_code(boost::redis::error)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `void boost::redis::request::push<char [12]>(std::basic_string_view<char, std::char_traits<char> >, char const (&) [12])':
boost-redis-test.cpp:(.text._ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_[_ZN5boost5redis7request4pushIJA12_cEEEvSt17basic_string_viewIcSt11char_traitsIcEEDpRKT_]+0x3f): undefined reference to `boost::redis::resp3::add_header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, boost::redis::resp3::type, unsigned long)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `auto boost::redis::connection::async_run<boost::asio::detached_t>(boost::redis::config const&, boost::redis::logger, boost::asio::detached_t)::{lambda(auto:1, boost::redis::connection*, boost::redis::config const*, boost::redis::logger)#1}::operator()<boost::asio::detail::detached_handler>(boost::asio::detail::detached_handler, boost::redis::connection*, boost::redis::config const*, boost::redis::logger) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_[_ZZN5boost5redis10connection9async_runINS_4asio10detached_tEEEDaRKNS0_6configENS0_6loggerET_ENKUlS9_PS1_PS6_S8_E_clINS3_6detail16detached_handlerEEEDaS9_SA_SB_S8_]+0x6d): undefined reference to `boost::redis::connection::async_run_impl(boost::redis::config const&, boost::redis::logger, boost::asio::any_completion_handler<void (boost::system::error_code)>)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `boost::redis::resp3::add_bulk_impl<std::basic_string_view<char, std::char_traits<char> > >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> > const&)':
boost-redis-test.cpp:(.text._ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_[_ZN5boost5redis5resp313add_bulk_implISt17basic_string_viewIcSt11char_traitsIcEEE3addERNSt7__cxx1112basic_stringIcS5_SaIcEEERKS6_]+0x26): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: /tmp/ccmIdN9x.o: in function `auto boost::redis::resp3::add_bulk_impl<std::tuple<char const (&) [12]> >::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::tuple<char const (&) [12]> const&)::{lambda((auto:1 const&)...)#1}::operator()<char [12]>(char const (&) [12]) const':
boost-redis-test.cpp:(.text._ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_[_ZZN5boost5redis5resp313add_bulk_implISt5tupleIJRA12_KcEEE3addERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS7_ENKUlDpRKT_E_clIJA12_cEEEDaSL_]+0x39): undefined reference to `boost::redis::resp3::boost_redis_to_bulk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::basic_string_view<char, std::char_traits<char> >)'
collect2: error: ld returned 1 exit status

@dynamic-entropy
Copy link

The "space" wasn't the actual recommendation to solve the issue (it was a comment about with and without space being the same thing).

What's confusing is that ls -a /home/adarsh9401/boost_1_84_0/stage/lib should not have returned nothing, but instead, library files to link.

@9401adarsh
Copy link

9401adarsh commented Mar 14, 2024

Ah my apologies, for misunderstanding about the "space",

From what I have understood, the only libraries which have to be linked are those that are earmarked by Boost to be built separately and only those object files are present in the /path/to/boost/stage/lib folder.

I have also raised an issue on the Boost.redis repository, to get some help. Will keep you posted in case of any movement.

@9401adarsh
Copy link

9401adarsh commented Mar 14, 2024

@yuvalif @dynamic-entropy
I have found the fix. I forgot to add the #include <boost/redis/src.hpp> as mentioned in the docs. I forgot I was trying to compile a single file, and hence the header wasn't included.

The file successfully compiles with the following:

g++ boost-redis-test.cpp -o boost-redis.exe -I /home/adarsh9401/boost_1_84_0 -lpthread -lcrypto -lssl

@dynamic-entropy
Copy link

Great!! Glad that you found it.

@9401adarsh
Copy link

@yuvalif I have completed the mandatory deliverables for the second tasks. The files can be found here on this repo: https://github.com/9401adarsh/ceph-redis-push-popper/.

I'll be moving on to the optional task now. Could you suggest what to do next after the second task is done ?

@Neelaksh-Singh
Copy link

@yuvalif I have shared my draft proposal with you. Could u suggest any changes to it (if necessary).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment