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 — PubSub: Message ordering no longer being honored · Issue #1889 · googleapis/java-pubsub

This repository was archived by the owner on Aug 13, 2026. It is now read-only.
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

PubSub: Message ordering no longer being honored #1889

Copy link
Copy link
Closed
#1903
Closed
PubSub: Message ordering no longer being honored#1889
#1903
Copy link
Assignees
michaelpri10
Labels
api: pubsubIssues related to the googleapis/java-pubsub API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.

Description

@turneand
turneand
opened on Feb 2, 2024
Issue body actions

Environment details

  1. Specify the API at the beginning of the title. For example, "BigQuery: ...").
    General, Core, and Other are also allowed as types
  2. OS type and version: Windows/unix
  3. Java version: 17
  4. version(s): 1.125.11 (works), 1.125.12(broken), 1.126.2(broken)

Steps to reproduce

  1. create a new pubsub topic and subscription with message ordering enabled (and exactly once delivery)
  2. publish 100 messages in a loop, with a simple text message containing the counter, and the ordering key of "defabc"
  3. start a single subscriber to receive the messages
  4. The messages should be received in order (and were in 1.125.11), but are now received only "mostly" in order

Code example

var project =
var topicName = TopicName.of(project, "andrew_test");
var publisher = Publisher.newBuilder(topicName).setEnableMessageOrdering(true).build();

try {
    for (int i = 0; i < 100; i++) {
        var data = ByteString.copyFromUtf8("hello #" + i);
        var message = PubsubMessage.newBuilder().setData(data).setOrderingKey("defabc").build();
        publisher.publish(message);
    }
} finally {
    publisher.shutdown();
    publisher.awaitTermination(1, TimeUnit.MINUTES);
}

var subscriptionName = ProjectSubscriptionName.of(project, "andrew-test-sub");
var subscriber = Subscriber.newBuilder(subscriptionName, (PubsubMessage message, AckReplyConsumer consumer) -> {
    System.out.println("Id: " + message.getMessageId() + " Data: " + message.getData().toStringUtf8());
    consumer.ack();
}).build();

try {
    subscriber.startAsync().awaitRunning();
    subscriber.awaitTerminated(30, TimeUnit.SECONDS);
} catch (TimeoutException e) {
    subscriber.stopAsync();
}

Stack trace

This also seems to lead to more frequent occurrences of this stack trace

io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Some acknowledgement ids in the request were sent out of order.

External references such as API reference guides

n/a

Any additional information below

The above code snippet works fine in 1.125.11, but in 1.125.12 and 1.126.2 (the latest as of raise date) we are getting messages delivered out of order.

I believe the root cause is the change from #1778 where under #1807 the LinkedHashSet was changed to a ConcurrentHashMap. When the notifyAckSuccess method is called, we are iterating over the outstandingReceipts to put into the outstandingBatch. Unfortunately this change switched it from insertion order to hash based ordering.

I can mitigate all of these issues by setting the max-outstanding-element-count down to 1, but then we lose the ability to parallel process, or the benefits of batching.

Activity

  1. blunderbuss-gcf
    assigned
    maitrimangal
    on Feb 2, 2024
  2. product-auto-label
    added
    api: pubsubIssues related to the googleapis/java-pubsub API.
    on Feb 2, 2024
  3. michaelpri10
    added a commit that references this issue on Feb 7, 2024

    chore: update graalvm version to 22.3.3 in kokoro cfg files. (#1889) (#…

    e307513
  4. michaelpri10
    assigned
    michaelpri10
    and unassigned
    maitrimangal
    on Feb 7, 2024
  5. kamalaboulhosn
    added
    priority: p0Highest priority. Critical issue. P0 implies highest priority.
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    and removed
    priority: p0Highest priority. Critical issue. P0 implies highest priority.
    on Feb 8, 2024
  6. michaelpri10
    closed this as completedin #1903on Feb 9, 2024
  7. michaelpri10
    added a commit that references this issue on Feb 9, 2024

    fix: Message ordering fix for #1889 (#1903)

    22a87c6
  8. gcf-merge-on-green
    added a commit that references this issue on Oct 1, 2024

    chore(main): release 1.133.0 (#2206)

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

Metadata

Metadata

Assignees

  • @michaelpri10
    michaelpri10

Labels

api: pubsubIssues related to the googleapis/java-pubsub API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.

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.