GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Weird behavior when pulling messages and using modifyAckDeadline · Issue #1017 · googleapis/google-cloud-java

Weird behavior when pulling messages and using modifyAckDeadline #1017

New issue
Copy link
New issue
Copy link
Closed
Closed
Weird behavior when pulling messages and using modifyAckDeadline#1017
Copy link
Assignees
mziccard
Labels
api: pubsubIssues related to the Pub/Sub API.

Description

@mziccard
mziccard
opened on May 20, 2016
Issue body actions

The scenario is the following: 1 topic and 1 subscription with default ack deadline (10 seconds). I publish 2 messages (message1 and message2) to the topic and then pull messages from the subscription.

After the first pull I set the ack deadline of message1 to a big value (let's say 100 seconds). Then I pull messages from the subscription every 20 seconds. The expected behavior is that pulls return only message2 until ~100 seconds are passed, and then return both message1 and message2.

When I run this scenario against the actual service I get the weird behavior: pull requests made before that ~100 seconds are passed after the deadline modification return no messages (as if both messages where affected by modifyAckDeadline).

The veneer toolkit code that reproduces the error is the following:

PublisherApi publisher = PublisherApi.create(publisherSettings);
SubscriberApi subscriber = SubscriberApi.create(subscriberSettings);
String topicName = PublisherApi.formatTopicName("gcloud-devel", "test-topic");
String subscriptionName =
    SubscriberApi.formatSubscriptionName("gcloud-devel", "test-subscription");
publisher.createTopic(topicName);
subscriber.createSubscription(Subscription.newBuilder()
    .setName(subscriptionName)
    .setTopic(topicName)
    .setAckDeadlineSeconds(10)
    .build());
publisher.publish(topicName, ImmutableList.of(
    PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message1")).build(),
    PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message2")).build()));
PullResponse pullResponse = subscriber.pull(subscriptionName, true, 2);
List<ReceivedMessage> receivedMessages = pullResponse.getReceivedMessagesList();
for (ReceivedMessage message : pullResponse.getReceivedMessagesList()) {
  System.out.printf("[%d][PULLED MESSAGE %s]%n",
      System.currentTimeMillis(), message.getMessage().getData().toStringUtf8());
}
// Set the deadline of the first message far away
subscriber.modifyAckDeadline(subscriptionName,
    ImmutableList.of(receivedMessages.get(0).getAckId()), 100);

// Second message should be again available for pulling after .sleep()
Thread.sleep(20000);
for (int i = 0; i < 10; i++) {
  pullResponse = subscriber.pull(subscriptionName, true, 2);
  receivedMessages = pullResponse.getReceivedMessagesList();
  if (receivedMessages.isEmpty()) {
    System.out.printf("[%d][PULLED NO MESSAGES]%n", System.currentTimeMillis());
  } else {
    for (ReceivedMessage message : pullResponse.getReceivedMessagesList()) {
      System.out.printf("[%d][PULLED MESSAGE %s]%n",
          System.currentTimeMillis(), message.getMessage().getData().toStringUtf8());
    }
  }
  Thread.sleep(20000);
}
publisher.deleteTopic(topicName);
subscriber.deleteSubscription(subscriptionName);

When I run it against the actual service I get the following output:

[1463750536877][PULLED MESSAGE message1]
[1463750536877][PULLED MESSAGE message2]
[1463750561558][PULLED NO MESSAGES] // <-- here and in the following I would expect message2
[1463750584638][PULLED NO MESSAGES]
[1463750608178][PULLED NO MESSAGES]
[1463750631240][PULLED NO MESSAGES]
[1463750653656][PULLED MESSAGE message1]
[1463750653657][PULLED MESSAGE message2]
[1463750676241][PULLED MESSAGE message1]
[1463750676241][PULLED MESSAGE message2]
[1463750698302][PULLED MESSAGE message1]
[1463750698302][PULLED MESSAGE message2]
[1463750720269][PULLED MESSAGE message1]
[1463750720270][PULLED MESSAGE message2]
[1463750742847][PULLED MESSAGE message1]
[1463750742847][PULLED MESSAGE message2]

Instead when I run it agains the emulator the output is as expected:

[1463749875238][PULLED MESSAGE message1]
[1463749875238][PULLED MESSAGE message2]
[1463749895270][PULLED MESSAGE message2]
[1463749915289][PULLED MESSAGE message2]
[1463749935308][PULLED MESSAGE message2]
[1463749955329][PULLED MESSAGE message2]
[1463749975347][PULLED MESSAGE message1]
[1463749975347][PULLED MESSAGE message2]
[1463749995363][PULLED MESSAGE message1]
[1463749995363][PULLED MESSAGE message2]
[1463750015384][PULLED MESSAGE message2]
[1463750015384][PULLED MESSAGE message1]
[1463750035403][PULLED MESSAGE message2]
[1463750035403][PULLED MESSAGE message1]
[1463750055421][PULLED MESSAGE message2]
[1463750055422][PULLED MESSAGE message1]

@eschapira @garrettjonesgoogle Any idea about what's going on?

Activity

  1. mziccard
    added
    api: pubsubIssues related to the Pub/Sub API.
    on May 20, 2016
  2. garrettjonesgoogle commented on May 20, 2016

    @garrettjonesgoogle
    garrettjonesgoogle
    on May 20, 2016
    Contributor
    More actions

    I tried this out myself, but adding one thing to the printout, the ack id:

          System.out.printf("[%d][PULLED MESSAGE %s, ackId = %s]%n",
              System.currentTimeMillis(), message.getMessage().getData().toStringUtf8(),
              message.getAckId());
    

    What I discovered is that the ack id was the same for both message1 and message2.

  3. mziccard commented on May 20, 2016

    @mziccard
    mziccard
    on May 20, 2016
    ContributorAuthor
    More actions

    What I discovered is that the ack id was the same for both message1 and message2.

    Actually they are very similar but different (they differ of a couple of letters).

    I managed to reproduce this issue (thanks to @garrettjonesgoogle) also with gcloud-node (code can be found here).

    The problem seems to be related to the fact that the two messages are published using a single call to publish. If we use two publish calls:

    publisher.publish(topicName, ImmutableList.of(
        PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message1")).build()));
    publisher.publish(topicName, ImmutableList.of(
        PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("message2")).build()));

    The issues does not occur and the example programs works as expected. Any clues?
    `

  4. mziccard commented on Sep 6, 2016

    @mziccard
    mziccard
    on Sep 6, 2016
    ContributorAuthor
    More actions

    This issue was reported internally, can be closed here

  5. mziccard
    closed this as completedon Sep 6, 2016
  6. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  7. github-actions
    added a commit that references this issue on Aug 9, 2022

    chore(main): release 3.2.0 (#1017)

    722238d
  8. github-actions
    added a commit that references this issue on Oct 25, 2022

    deps: update dependency com.google.cloud:google-cloud-core to v2.8.23 (…

    03d6da6
  9. suztomo
    added a commit that references this issue on Feb 1, 2023

    chore(java): update dependencies in java requirements file (#1695) (#…

    0c8f5b1
  10. meltsufin
    added a commit that references this issue on Dec 22, 2025

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    30ce3e5
  11. chingor13
    added a commit that references this issue on Jan 22, 2026

    chore(main): release 2.14.1 (#1017)

    4e84334
  12. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore(deps): update dependency jinja2 to v3.1.2 (#1017)

    70b32ef
  13. suztomo
    added a commit that references this issue on Mar 11, 2026

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

    0f295da
  14. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore(deps): update dependency jinja2 to v3.1.2 (#1017)

    63d130e
  15. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    deps: update dependency org.graalvm.buildtools:junit-platform-native …

    d5e17a5

    chore(main): release 2.7.11 (googleapis#1020)

    6591158
  16. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    deps: update dependency com.google.cloud:google-cloud-core to v2.5.4 (#…

    55c53e3

    deps: update dependency com.google.cloud:google-cloud-core to v2.5.4 (#…

    8f3746b
  17. benjaminp
    added a commit that references this issue on Jul 13, 2026

    build(deps): update dependency com.google.cloud:google-cloud-shared-c…

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

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.