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] Segmentation Fault when using Pulsar Consumer batchReceive #390

Closed
rafael-polakiewicz opened this issue Jul 5, 2024 · 5 comments
Closed
Assignees

Comments

@rafael-polakiewicz
Copy link

Description

I encountered a segmentation fault using pulsar consumer batch receive method. The consumer process terminates unexpectedly with a segmentation fault.

Node and pulsar-client info

  • node version: v20.15.0
  • pulsar-client: "^1.11.0"

Steps to Reproduce

1. Start a local instance of Pulsar

Use the following docker-compose file to start a Pulsar instance:

services:
  pulsar:
    image: apachepulsar/pulsar:3.3.0
    command: "bin/pulsar standalone"
    ports:
        - '7128:8080'
        - '6650:6650'
    volumes:
        - pulsar_data:/pulsar/data
        - pulsar_conf:/pulsar/conf

volumes:
  pulsar_data:
  pulsar_conf:

2. Create a simple consumer script

Save the following code in a file named consumer.js:

const Pulsar = require('pulsar-client');

async function main() {
  const client = new Pulsar.Client({
    serviceUrl: 'pulsar://localhost:6650',
  });

  const consumer = await client.subscribe({
    subscription: 'example-subscription',
    subscriptionType: 'Shared',
    topic: 'persistent://public/default/my-topic',
    batchReceivePolicy: {
      timeoutMs: 3000,
      maxNumMessages: 10
    }
  });

  console.log('consumer created');

  while (true) {
    const messages = await consumer.batchReceive();
    messages.forEach(async (msg) => {
      console.log({ msg: msg.getData().toString() });
      await consumer.acknowledge(msg);
    });
  }
}

main();

3. Run the consumer script

Execute the script using the following command:

node consumer.js

4. Create a producer script

Save the following code in a file named producer.js:

const Pulsar = require('pulsar-client');

async function main() {
  const client = new Pulsar.Client({
    serviceUrl: 'pulsar://localhost:6650',
  });

  const producer = await client.createProducer({
    topic: 'persistent://public/default/my-topic',
    blockIfQueueFull: true,
  });

  for (let i = 0; i < 100; i++) {
    console.log(`sent message ${i}`);
    await producer.send({
      data: Buffer.from("test"),
    });
  }
}

main();

5. Populate the topic

Execute the producer script using the following command:

node producer.js

Expected Behavior

The consumer should process and acknowledge messages without errors.

Actual Behavior

The consumer process ends with the following message:

consumer created
zsh: segmentation fault (core dumped)  node consumer.js

Additional Information

I found that the feature request to support batch receive was closed. Am I doing something wrong here, or is this a bug?
Please let me know if you need any further information.

Thank you for your attention to this matter.

@shibd
Copy link
Member

shibd commented Jul 6, 2024

@rafael-polakiewicz What is the env in which the consumer is running?

can you try this version: npm i [email protected] --pulsar_binary_host_mirror=https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/

@shibd
Copy link
Member

shibd commented Jul 6, 2024

#389 can resolve batch_recieve crash issue when the consumer running on Debian system.

@shibd shibd self-assigned this Jul 6, 2024
@iamseki
Copy link

iamseki commented Jul 7, 2024

The version [email protected] works for me. Environment details:

Node.js version:
v18.13.0

npm version:
8.19.3

Operating System details:
Linux [hostname redacted] 6.5.0-41-generic #41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun  3 11:32:55 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

LSB release information:
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Package versions:
[email protected] /[path redacted]/projects/winston/test-pulsar
└── [email protected]

@shibd
Copy link
Member

shibd commented Jul 8, 2024

v1.11.1 has been released, I think it can resolve this issue.

@shibd shibd closed this as completed Jul 8, 2024
@rafael-polakiewicz
Copy link
Author

Thank you, @shibd !!
Using v1.11.1 fixed the problem

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

No branches or pull requests

3 participants