Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Regression of seeking by timestamp in 3.5.0 #420

Closed
2 tasks done
BewareMyPower opened this issue Mar 25, 2024 · 0 comments · Fixed by #422
Closed
2 tasks done

[Bug] Regression of seeking by timestamp in 3.5.0 #420

BewareMyPower opened this issue Mar 25, 2024 · 0 comments · Fixed by #422

Comments

@BewareMyPower
Copy link
Contributor

Search before asking

  • I searched in the issues and found nothing similar.

Version

Client 3.5.0

Minimal reproduce step

Create a main.cc

#include <chrono>
#include <pulsar/Client.h>
using namespace pulsar;

int main(int argc, char *argv[]) {
  Client client{"pulsar://localhost:6650"};
  std::string topic = (argc > 1) ? argv[1] : "my-topic";
  Producer producer;
  if (auto result = client.createProducer(topic, producer);
      result != ResultOk) {
    std::cerr << "Failed to create producer: " << result << std::endl;
    return 1;
  }

  producer.send(MessageBuilder().setContent("msg-0").build());

  Reader reader;
  if (auto result =
          client.createReader(topic, MessageId::latest(), {}, reader);
      result != ResultOk) {
    std::cerr << "Failed to create reader: " << result << std::endl;
    return 2;
  }

  using namespace std::chrono;
  reader.seek(
      duration_cast<milliseconds>(system_clock::now().time_since_epoch())
          .count());

  bool hasMessage;
  if (auto result = reader.hasMessageAvailable(hasMessage);
      result != ResultOk) {
    std::cerr << "hasMessageAvailable failed: " << result << std::endl;
    return 3;
  }

  std::cout << hasMessage << std::endl;

  return 0;
}

Key point: the start position must be latest for Reader.

On macOS m1, install the the macos-arm64.zip and build with those artifacts.

curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.5.0/macos-arm64.zip
unzip -q macos-arm64.zip
g++ main.cc -std=c++17 -I ./include -L ./lib -Wl,-rpath ./lib -lpulsar
./a.out

What did you expect to see?

Outputs (ignore the outputs from the library):

1

What did you see instead?

The output should be 0 like the behavior with 3.4.2

curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.4.2/macos-arm64.zip
unzip -q macos-arm64.zip
g++ main.cc -std=c++17 -I ./include -L ./lib -Wl,-rpath ./lib -lpulsar
./a.out

Outputs:

0

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant