Skip to content

Conversation

@dannf
Copy link
Contributor

@dannf dannf commented Dec 7, 2025

Fixes #478

Motivation

Our libpulsar builds started failing with latest upstream dependencies (abseil-cpp/protobuf). After creating this patch, I noticed @cho-m had already reported an issue and suggested a couple fixes, which are likely better than this. But that was months ago, so I figured I'd open a PR to push the conversation forward.

Modifications

Explicitly convert absl string_view to std::string for use in the schemaJson.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    No user-visible changes.

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

This resolves the following build failure using abseil-cpp 20250814.1:

```
[  1%] Building CXX object lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o
cd /home/build/pulsar-client-cpp/build/lib && /usr/local/bin/c++ -DBOOST_ALLOW_DEPRECATED_HEADERS -DBOOST_ALL_NO_LIB -DBUILDING_PULSAR -DHAS_SNAPPY=0 -DHAS_ZSTD=0 -DPULSAR_AUXV_GETAUXVAL_PRESENT -I/home/build/pulsar-client-cpp -I/home/build/pulsar-client-cpp/include -I/home/build/pulsar-client-cpp/build/include -I/home/build/pulsar-client-cpp/build/generated -I/home/build/pulsar-client-cpp/build/generated/lib -Wno-array-bounds -O2 -g -DNDEBUG -std=gnu++17 -fPIC -Wall -Wformat-security -Wvla -Werror -Wno-sign-compare -Wno-deprecated-declarations -Wno-error=cpp -msse4.2 -mpclmul -fdiagnostics-show-option -fdiagnostics-color -fvisibility=hidden -MD -MT lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -MF CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o.d -o CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o -c /home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc: In function 'pulsar::SchemaInfo pulsar::createProtobufNativeSchema(const google::protobuf::Descriptor*)':
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc:42:67: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'}
   42 |     const std::string& rootMessageTypeName = descriptor->full_name();
      |                                              ~~~~~~~~~~~~~~~~~~~~~^~
/home/build/pulsar-client-cpp/lib/ProtobufNativeSchema.cc:43:69: error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'absl::lts_20250814::string_view' {aka 'std::basic_string_view<char>'}
   43 |     const std::string& rootFileDescriptorName = fileDescriptor->name();
      |                                                 ~~~~~~~~~~~~~~~~~~~~^~
make[2]: *** [lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/build.make:1052: lib/CMakeFiles/PULSAR_OBJECT_LIB.dir/ProtobufNativeSchema.cc.o] Error 1
```

Signed-off-by: dann frazier <dann.frazier@chainguard.dev>
@dannf
Copy link
Contributor Author

dannf commented Dec 7, 2025

I can't reproduce the CI failure locally. Is this a test that sometimes needs to be retried?

dann-frazier@dann-frazier-laptop:/tmp/pulsar-client-cpp/build/tests$ ./pulsar-tests --gtest_filter=Pulsar/ReaderSeekTest.testHasMessageAvailableAfterSeekToEnd/0 
Note: Google Test filter = Pulsar/ReaderSeekTest.testHasMessageAvailableAfterSeekToEnd/0
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Pulsar/ReaderSeekTest
[ RUN      ] Pulsar/ReaderSeekTest.testHasMessageAvailableAfterSeekToEnd/0
2025-12-07 11:29:19.467 INFO  [129480440001472] ClientConnection:194 | [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2025-12-07 11:29:19.467 INFO  [129480440001472] ConnectionPool:125 | Created connection for pulsar://localhost:6650-pulsar://localhost:6650-0
2025-12-07 11:29:19.468 INFO  [129480432162496] ClientConnection:411 | [127.0.0.1:39706 -> 127.0.0.1:6650] Connected to broker
2025-12-07 11:29:19.485 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Getting connection from pool
2025-12-07 11:29:19.507 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://broker-1:6650, from [127.0.0.1:39706 -> 127.0.0.1:6650] 
2025-12-07 11:29:19.507 INFO  [129480432162496] ClientConnection:194 | [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2025-12-07 11:29:19.507 INFO  [129480432162496] ConnectionPool:125 | Created connection for pulsar://broker-1:6650-pulsar://localhost:6650-0
2025-12-07 11:29:19.507 INFO  [129480432162496] ClientConnection:413 | [127.0.0.1:39714 -> 127.0.0.1:6650] Connected to broker through proxy. Logical broker: pulsar://broker-1:6650, proxy: , physical address:pulsar://localhost:6650
2025-12-07 11:29:19.511 INFO  [129480432162496] ProducerImpl:147 | Creating producer for topic:persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, producerName: on [127.0.0.1:39714 -> 127.0.0.1:6650] 
2025-12-07 11:29:19.514 WARN  [129480432162496] ProducerImpl:298 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Temporary error in creating producer: ResultDisconnected
2025-12-07 11:29:19.514 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Schedule reconnection in 0.1 s
2025-12-07 11:29:19.515 INFO  [129480432162496] ClientConnection:1790 | Producer id:0 is migrated to pulsar://localhost:6651
2025-12-07 11:29:19.515 INFO  [129480432162496] ProducerImpl:978 | Broker notification of Closed producer: 0
2025-12-07 11:29:19.515 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Schedule reconnection in 0.182 s
2025-12-07 11:29:19.515 INFO  [129480432162496] HandlerBase:204 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Ignoring timer cancelled event, code[system:125]
2025-12-07 11:29:19.697 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Getting connection from pool
2025-12-07 11:29:19.697 INFO  [129480432162496] ClientConnection:194 | [<none> -> pulsar://localhost:6651] Create ClientConnection, timeout=10000
2025-12-07 11:29:19.697 INFO  [129480432162496] ConnectionPool:125 | Created connection for pulsar://localhost:6651-pulsar://localhost:6651-0
2025-12-07 11:29:19.698 INFO  [129480432162496] ClientConnection:411 | [127.0.0.1:54208 -> 127.0.0.1:6651] Connected to broker
2025-12-07 11:29:19.736 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://green-broker-1:6650, from [127.0.0.1:54208 -> 127.0.0.1:6651] 
2025-12-07 11:29:19.737 INFO  [129480432162496] ClientConnection:194 | [<none> -> pulsar://localhost:6651] Create ClientConnection, timeout=10000
2025-12-07 11:29:19.737 INFO  [129480432162496] ConnectionPool:125 | Created connection for pulsar://green-broker-1:6650-pulsar://localhost:6651-0
2025-12-07 11:29:19.737 INFO  [129480432162496] ClientConnection:413 | [127.0.0.1:54218 -> 127.0.0.1:6651] Connected to broker through proxy. Logical broker: pulsar://green-broker-1:6650, proxy: , physical address:pulsar://localhost:6651
2025-12-07 11:29:19.740 INFO  [129480432162496] ProducerImpl:147 | Creating producer for topic:persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, producerName: on [127.0.0.1:54218 -> 127.0.0.1:6651] 
2025-12-07 11:29:19.792 INFO  [129480432162496] ProducerImpl:220 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, ] Created producer on broker [127.0.0.1:54218 -> 127.0.0.1:6651] 
2025-12-07 11:29:19.792 INFO  [129480432162496] HandlerBase:134 | Finished connecting to broker after 94 ms
2025-12-07 11:29:19.793 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Getting connection from pool
2025-12-07 11:29:19.795 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://broker-1:6650, from [127.0.0.1:39706 -> 127.0.0.1:6650] 
2025-12-07 11:29:19.799 WARN  [129480432162496] ConsumerImpl:367 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Temporary error in creating consumer: ResultDisconnected
2025-12-07 11:29:19.800 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Schedule reconnection in 0.1 s
2025-12-07 11:29:19.800 INFO  [129480432162496] ClientConnection:1800 | Consumer id:0 is migrated to pulsar://localhost:6651
2025-12-07 11:29:19.800 INFO  [129480432162496] ConsumerImpl:1318 | Broker notification of Closed consumer: 0
2025-12-07 11:29:19.800 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Schedule reconnection in 0.182 s
2025-12-07 11:29:19.800 INFO  [129480432162496] HandlerBase:204 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Ignoring timer cancelled event, code[system:125]
2025-12-07 11:29:19.982 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Getting connection from pool
2025-12-07 11:29:19.985 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://green-broker-1:6650, from [127.0.0.1:54208 -> 127.0.0.1:6651] 
2025-12-07 11:29:19.987 INFO  [129480432162496] ConsumerImpl:323 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Created consumer on broker [127.0.0.1:54218 -> 127.0.0.1:6651] 
2025-12-07 11:29:19.987 INFO  [129480432162496] HandlerBase:134 | Finished connecting to broker after 5 ms
2025-12-07 11:29:19.995 INFO  [129480440001472] ConsumerImpl:1745 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0]  Seeking subscription to (9223372036854775807,9223372036854775807,-1,-1)
2025-12-07 11:29:19.995 INFO  [129480432162496] ConsumerImpl:1318 | Broker notification of Closed consumer: 0
2025-12-07 11:29:19.995 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Schedule reconnection in 0.1 s
2025-12-07 11:29:19.996 INFO  [129480432162496] ConsumerImpl:1758 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Seek successfully
2025-12-07 11:29:20.095 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Getting connection from pool
2025-12-07 11:29:20.098 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://green-broker-1:6650, from [127.0.0.1:54208 -> 127.0.0.1:6651] 
2025-12-07 11:29:20.099 INFO  [129480432162496] ConsumerImpl:323 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Created consumer on broker [127.0.0.1:54218 -> 127.0.0.1:6651] 
2025-12-07 11:29:20.099 INFO  [129480432162496] HandlerBase:134 | Finished connecting to broker after 3 ms
2025-12-07 11:29:20.198 WARN  [129480432162496] ConsumerImpl:1696 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0]  Could not get connection while getLastMessageId -- Will try again in 100 ms
2025-12-07 11:29:20.206 INFO  [129480440001472] ConsumerImpl:1745 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0]  Seeking subscription to (9223372036854775807,9223372036854775807,-1,-1)
2025-12-07 11:29:20.207 INFO  [129480432162496] ConsumerImpl:1318 | Broker notification of Closed consumer: 0
2025-12-07 11:29:20.207 INFO  [129480432162496] HandlerBase:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Schedule reconnection in 0.1 s
2025-12-07 11:29:20.207 INFO  [129480432162496] ConsumerImpl:1758 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Seek successfully
2025-12-07 11:29:20.307 INFO  [129480432162496] HandlerBase:112 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Getting connection from pool
2025-12-07 11:29:20.308 INFO  [129480432162496] BinaryProtoLookupService:85 | Lookup response for persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, lookup-broker-url pulsar://green-broker-1:6650, from [127.0.0.1:54208 -> 127.0.0.1:6651] 
2025-12-07 11:29:20.310 INFO  [129480432162496] ConsumerImpl:323 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Created consumer on broker [127.0.0.1:54218 -> 127.0.0.1:6651] 
2025-12-07 11:29:20.310 INFO  [129480432162496] HandlerBase:134 | Finished connecting to broker after 2 ms
2025-12-07 11:29:20.408 WARN  [129480432162496] ConsumerImpl:1696 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0]  Could not get connection while getLastMessageId -- Will try again in 100 ms
2025-12-07 11:29:20.410 WARN  [129480440001472] ConsumerImpl:186 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Destroyed consumer which was not properly closed
2025-12-07 11:29:20.410 INFO  [129480440001472] ConsumerImpl:193 | [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, reader-310f5456e1, 0] Closed consumer for race condition: 0
2025-12-07 11:29:20.410 INFO  [129480440001472] ProducerImpl:754 | Producer - [persistent://public/default/test-has-message-available-after-seek-to-end-1765132159, cluster-a-0-23] , [batchMessageContainer = { BatchMessageContainer [size = 0] [bytes = 0] [maxSize = 1000] [maxBytes = 131072] [topicName = persistent://public/default/test-has-message-available-after-seek-to-end-1765132159] [numberOfBatchesSent_ = 3] [averageBatchSize_ = 0] }]
2025-12-07 11:29:20.410 INFO  [129480440001472] ClientImpl:686 | Closing Pulsar client with 0 producers and 0 consumers
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:1305 | [127.0.0.1:39714 -> 127.0.0.1:6650] Connection disconnected (refCnt: 1)
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:1305 | [127.0.0.1:54218 -> 127.0.0.1:6651] Connection disconnected (refCnt: 1)
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:1305 | [127.0.0.1:39706 -> 127.0.0.1:6650] Connection disconnected (refCnt: 2)
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:1305 | [127.0.0.1:54208 -> 127.0.0.1:6651] Connection disconnected (refCnt: 1)
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:283 | [127.0.0.1:54208 -> 127.0.0.1:6651] Destroyed connection to pulsar://localhost:6651-0
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:283 | [127.0.0.1:39706 -> 127.0.0.1:6650] Destroyed connection to pulsar://localhost:6650-0
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:283 | [127.0.0.1:54218 -> 127.0.0.1:6651] Destroyed connection to pulsar://green-broker-1:6650-0
2025-12-07 11:29:20.410 INFO  [129480406984384] ClientConnection:283 | [127.0.0.1:39714 -> 127.0.0.1:6650] Destroyed connection to pulsar://broker-1:6650-0
[       OK ] Pulsar/ReaderSeekTest.testHasMessageAvailableAfterSeekToEnd/0 (943 ms)
[----------] 1 test from Pulsar/ReaderSeekTest (943 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (943 ms total)
[  PASSED  ] 1 test.

@BewareMyPower
Copy link
Contributor

It's a flaky test, let me rerun

@BewareMyPower BewareMyPower added this to the 4.0.0 milestone Dec 8, 2025
@BewareMyPower BewareMyPower merged commit adf3c7c into apache:main Dec 8, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Build fails with Protobuf 30 from type changes

3 participants