Registry Mirror
Skip to content

Conversation

@shuwenwei

@shuwenwei shuwenwei commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Add Go client support for IoTDB subscription APIs in the main client module, including management sessions, Pull and Push consumers, tree/table records, provider discovery and recovery, progress/seeking, processors, examples, and server-backed E2E coverage.

Public API

  • Add subscription packages under github.com/apache/iotdb-client-go/v2/subscription, including session, consumer, payload, and processor subpackages. These packages share the main module version with the Session client.
  • Add subscription topic and consumer configuration types, Pull/Push consumer interfaces, record and watermark messages, commit/progress APIs, provider recovery, and SubscriptionError classifications.
  • Add Watermark and ColumnAlign processors with documented ownership and lifecycle contracts.
  • Align exported TSStatusCode constants with the current server definition. The legacy AlreadyHasPrivilege, DatanodeAlreadyRegistered, and RegisterRemovedDatanode exports are removed because they no longer map to valid current statuses; some existing status names also receive updated numeric values. Downstream callers that reference the removed names or rely on the old numeric assignments must migrate.
  • Keep normal Tablet OBJECT writes on SetObjectValueAt so segmented EOF/offset metadata is encoded. Raw OBJECT replacement is limited to Tablets created from decoded subscription payloads.
  • Keep native TsFile payload decoding out of scope: TsFile topic management and subscription are supported, while file payload access returns ErrUnsupportedTsFile without acknowledging or retrying the payload.

Implementation Highlights

  • Decode subscription control and Tablet payloads with typed column storage instead of per-cell interface storage.
  • Implement all-provider seek attempts, pending termination handling, unsubscribe reconciliation, commit retry and redirect ACK behavior, fencing, heartbeat, endpoint discovery, and serial Poll execution.
  • Use an expiry heap for automatic commits, in-place ColumnAlign mutation for decoded messages, and column-based watermark size accounting.
  • Avoid repeated TEXT/STRING conversion and missing-column writes in processor hot paths through raw decoded-value access and backing-column checks.
  • Place subscription code, examples, and E2E tests in directory-isolated packages of the root Go module. They use one go.mod, share one release version, and require no nested modules or local replace directives for consumers.
  • Add shared E2E configuration for Session and subscription tests. Subscription tests are discovered by normal test runs and skip unless IOTDB_SUBSCRIPTION_E2E=1 is set; node addresses and credentials use IOTDB_E2E_* variables with fallbacks.

Validation

  • Root-module go build ./...
  • go test ./client/...
  • go test ./subscription/...
  • E2E package execution from the repository root
  • Full TestSubscriptionTable* suite against a local subscription-enabled server
  • Repeated strict snapshot completion tests for automatic and manual Commit paths
  • Docker Compose configuration validation
  • Subscription E2E cases are disabled in the default Apache CI environment and run only when IOTDB_SUBSCRIPTION_E2E=1 is explicitly configured

No existing Session module paths or core Session methods are removed. The TSStatusCode compatibility changes described above are an intentional exported-constant API change.

Comment thread subscription/internal/record/tablet.go Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reuse the structures already defined in Session-go?

Comment thread subscription/README.md Outdated
Comment on lines +74 to +94
In this section, model constants and `ConnectionConfig` belong to the root package; management configuration belongs to `session`, and consumer configuration and acknowledgment types belong to `consumer`.

Go uses `Dialect` to distinguish the tree and table models. Management and consumption each share a contract rather than duplicating Java's tree/table types and Builder hierarchy.

Java's `ISubscriptionTreeSession/ISubscriptionTableSession`, tree/table Pull interfaces, and tree/table Push interfaces have identical method signatures within each pair. Go therefore uses `SubscriptionSession`, `SubscriptionPullConsumer`, and `SubscriptionPushConsumer` for those common operations. Configuration selects the model through `Dialect`; each instance uses one model.

Only the public method contract is shared. Management sessions pass the model when connecting. Consumer handshakes carry the selected model, and record decoding distinguishes tree device paths from table databases, tables, and TAG identities. Sharing an interface does not require the two models to use the same internal implementation.

| Public Go type | Java counterpart | Go representation |
| --- | --- | --- |
| `Dialect`, `TreeDialect`, `TableDialect` | Tree/table Session and Consumer types, SQL dialect | Select the model in `SubscriptionSessionConfig` or `SubscriptionConsumerConfig` |
| `ConnectionConfig` | Session/Consumer Builder settings for nodes, authentication, connection timeout, and maximum frame size | `NodeURLs` represents either a single node or cluster seed addresses; durations use `time.Duration`; plaintext and encrypted passwords are mutually exclusive |
| `SubscriptionSessionConfig` | `SubscriptionTreeSessionBuilder`, `SubscriptionTableSessionBuilder` | Obtain defaults through `DefaultSubscriptionSessionConfig`, then pass them to `NewSubscriptionSession`; construction does not connect |
| `SubscriptionConsumerConfig` | `AbstractSubscriptionConsumerBuilder` | Shared configuration for consumer identity, ownership, heartbeats, endpoint synchronization, and parallelism |
| `SubscriptionPullConsumerConfig` | `AbstractSubscriptionPullConsumerBuilder` | `AutoCommit == nil` selects Java's default, `true`; a pointer to `false` explicitly selects manual commits |
| `SubscriptionPushConsumerConfig` | `AbstractSubscriptionPushConsumerBuilder` | Combines a Handler, ACK strategy, and polling interval and timeout |
| `AckStrategy`, `AckAfterConsume`, `AckBeforeConsume` | `AckStrategy.AFTER_CONSUME`, `BEFORE_CONSUME` | The zero value acknowledges after consumption; callback failure does not cause redelivery when acknowledgment precedes consumption |

`SubscriptionConsumerConfig.OwnerEpoch == nil` means that no epoch was supplied; a pointer to zero explicitly supplies epoch 0. `DefaultSubscriptionConsumerConfig`, `DefaultSubscriptionPullConsumerConfig`, and `DefaultSubscriptionPushConsumerConfig` are available. The default Push Handler remains nil, so callers must supply a real handler. Internal normalization copies endpoint slices and optional pointers. Zero durations select defaults, negative durations return errors, and positive values below Java's minimum are raised to that minimum. Construct consumers with `NewSubscriptionPullConsumer` or `NewSubscriptionPushConsumer`; neither constructor connects to the network.

The management session defaults are `localhost:6667`, the tree model, root/root authentication, a 64 MiB frame limit, and a ten-second connection and authentication timeout. Java management sessions do not limit connection time by default; the Go entry point uses a bounded timeout here. The constructor fills empty endpoints, username, and dialect, as well as zero timeout and frame size, validates addresses and mutually exclusive authentication, and copies the endpoint slice. Passwords are always preserved as supplied, including empty strings. Start with the default configuration function when root/root defaults are needed. To use an encrypted password, clear `Password` and set `EncryptedPassword`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to involve too many technical details and comparisons with the Java edition.
Concentrate on what a real user would concern.
If you wish, may put them in a separate technical report.

@JackieTien97 JackieTien97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this against the Java subscription client (iotdb-client/subscription) and ran it end-to-end against an activated, subscription-enabled 2.0.11-SNAPSHOT server (1C1D, subscription_enabled=true) with Go 1.25.14.

Matches Java

  • Wire format: request/response envelopes; handshake, heartbeat, subscribe, poll, poll-tablets, commit, seek and slice bodies; commit context v2; topic/region/writer progress; poll response kinds including the time-selection maps; Tablet decoding (bitmaps, binary presence bytes, DATE). A proxy capture of the same multi-topic scenario shows the same pipeSubscribe request sequence from both clients.
  • Defaults and minimums, fencing status codes, the Watermark and ColumnAlign processors, seek semantics, and row ordering.

Runs

  • Unit tests pass with -race, and all four examples (tree/table x pull/push) succeed.
  • After a DataNode SIGKILL and restart, the pull consumer recovered on its own and received every row; four rows were redelivered, as expected under at-least-once delivery.
  • The PR's subscription E2E passed 22/24 on the first run and 24/24 on a second run. The two failures are discussed inline.

The inline comments cover a status-code mapping bug (1920), two behavioral differences from Java that should be aligned or documented (Push stopping on critical errors, no TLS), E2E flakiness that appears to be server-side, and test coverage.

Comment thread subscription/consumer/provider.go Outdated
subscriptionFrameReserve = 1024
// Oversized-entry status is returned by servers that enforce subscription
// materialization limits. Keep the compatibility value local to the consumer.
subscriptionOversizedEntryStatus int32 = 1920

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status 1920 is classified as an oversized entry (ErrorKindPayloadExceed), but in IoTDB 1920 is SUBSCRIPTION_CONNECTION_REPLACED. It was added in apache/iotdb#19130, and the DataNode returns it for requests sent on a connection that a reconnection from the same consumer instance has replaced.

Java treats it as a retryable connection failure. AbstractSubscriptionProvider converts 1920 into SubscriptionConnectionException and marks the provider unavailable, as asserted by SubscriptionProviderStatusTest#testReplacedConnectionStatusIsRetryable and SubscriptionProviderConnectionTimeoutTest#testReplacedConnectionIsRetryableForPollAndCommit. AbstractSubscriptionConsumer#pollInternal then catches the exception, schedules syncIfUnavailable, and returns an empty list.

Here, verifySubscriptionProviderStatus (L468) reports Kind=ErrorKindPayloadExceed, and Poll returns the error to the caller. I reproduced this with an in-process fake Thrift server that answers POLL with 1920: Poll returned subscription: server status 1920: ..., and errors.As yielded Kind=6 (ErrorKindPayloadExceed). The connection abort at L245 and the follow-up recovery do match Java.

The oversized-entry condition reaches the client in the poll body as a critical ErrorPayload whose message contains SUBSCRIPTION_OVERSIZED_ENTRY. newSubscriptionPollError already handles that case, so it is unrelated to this status code.

Suggestion: add SubscriptionConnectionReplaced int32 = 1920 next to the other subscription codes in client/protocol.go, classify it as ErrorKindConnection, and treat it on the poll path as a retryable provider failure, as Java does. The status.Code != subscriptionOversizedEntryStatus check in commitNode (pull_progress.go L336) already makes 1920 retryable for commits, which looks intended; only the name and classification need to change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested at aeaa5d4 with the same fake-server probe. When the server answers POLL with 1920, Poll now returns no messages and a nil error. The next Poll re-handshakes on a new connection (handshakes 1 → 2) and keeps polling without errors. In the code, commitNode still retries on 1920. This matches Java. Thanks for the fix.

Comment thread subscription/consumer/push_consumer.go Outdated
if err := c.consumer.checkOpen(); err != nil {
return err
}
if flowFatalPollError(failure) || flowCriticalPollError(failure) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavioral difference from Java: a single critical poll error permanently stops Push delivery.

terminalDeliveryError treats every critical error as terminal. That covers server statuses 1900/1901/1909/1912 and anything else that falls into the default branch of verifySubscriptionProviderStatus. It also covers critical ErrorPayloads from the server, such as the WAL replay error and SUBSCRIPTION_OVERSIZED_ENTRY. runDelivery then exits, and the only way to resume is to read Errors() and recreate the consumer.

In Java, AbstractSubscriptionPushConsumer.AutoPollWorker#run catches every exception and polls again on the next autoPollIntervalMs tick. Only close or fencing cancels the worker.

Repro: a fake server answers the first POLL with 1909 and every later POLL normally. The Go delivery loop stops after that first poll, and the server sees no further POLL for the next 2+ seconds. Java's worker would keep polling on its 100 ms schedule.

The README documents the current behavior, so this may be intentional. If it is, please list it explicitly as a difference from Java and explain how to recreate the consumer. Otherwise, consider making only fencing and TsFile terminal, and retrying critical errors on the next round.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested at aeaa5d4. With the first POLL answered by 1909 and later ones answered normally, Errors() reports nothing and the delivery loop keeps polling: 31 POLLs after 3 s, 52 two seconds later. The README (L485) and the Errors() doc comment now describe this behavior, which matches Java's AutoPollWorker. Thanks.

Comment thread subscription/config.go
// ConnectionConfig describes the RPC connections owned by a subscription client.
// Password and EncryptedPassword are mutually exclusive. NodeURLs contains
// host:port addresses and supports a single node as well as a cluster seed list.
type ConnectionConfig struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLS gap compared with Java. The Java subscription session and consumer builders support useSSL, trustStore, trustStorePwd, keyStore, keyStorePwd and sslProtocol, so Java consumers can connect to SSL-enabled clusters. ConnectionConfig has no TLS option, and doc.go states that none is exposed, even though the Session client in this repo already supports client.Config.TLSConfig.

Please either add a TLS option that reuses the existing transport support, or list this next to the TsFile limitation in the documented differences, so users of SSL-enabled clusters know the Go consumer cannot connect.

subscriptionTreeRequireRows(t, subscriptionTreeCollect(t, ctx, second, len(want), false, true), want...)
}

func TestSubscriptionTreeConsumerReadsMultipleTopics(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky against the current server, with an apparently server-side root cause. On the first full run, this test and TestSubscriptionTableSnapshotStrictManualCommitCompletion both hit the 20 s timeout: all rows had arrived, but AllConsumed() never became true.

In repeat loops:

  • This multi-topic case, alternating Go and Java runs: Go passed 1/6, an equivalent Java program 6/6.
  • The table strict manual-commit case: Go passed 4/8, Java 5/8.

Every failing run I inspected, Go and Java alike, has the same server-side signature:

  • Rows were delivered and ACKed, and the terminate events were committed.
  • The ConfigNode logged Detected completion of pipe ....
  • No PipeHandleMetaChangeProcedure was submitted until another pipe completed about 21 s later.

As a result the topic is never marked completed, no TERMINATION is returned, and AllConsumed() stays false. This needs a server-side follow-up. It may be related to the heartbeat-round gating of canSubmitHandleMetaChangeProcedure in PipeHeartbeatParser.

I could not explain why the Go client hits this much more often than Java in the multi-topic case. A proxy capture shows the same pipeSubscribe sequence from both clients: one POLL returning two TABLETS, four continuation polls, and one COMMIT carrying both contexts. Until the server side is fixed, the completion tests will stay flaky wherever IOTDB_SUBSCRIPTION_E2E=1 is set.

Comment thread test/e2e/config_test.go
// explicit environment opt-in. Endpoint and credential defaults come from the
// shared E2E configuration.
const (
subscriptionE2EDefaultEnabled = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the subscription client is not exercised in CI. Because the E2E tests are opt-in, the Apache e2e job reports all 24 TestSubscription* cases as --- SKIP.

Unit-test coverage of the module, measured with go test -cover ./... under subscription/, is 11.4% overall: consumer 0.1%, internal/protocol 34.6%, processor 77.2%. The poll, commit, seek, recovery and push logic in consumer therefore has almost no automated verification in this repo's CI.

Could you add unit tests against an in-process fake Thrift server (rpc.NewIClientRPCServiceProcessor with thrift.NewTSimpleServer4)? A fake of about 150 lines was enough to reproduce the 1920 and Push cases above, so covering the main error, redirect-ACK and recovery branches should be cheap.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status at aeaa5d4: go test -cover ./... under subscription/ reports 11.3% overall: consumer 0.1%, internal/protocol 28.8% (the Tablet decoding tests moved to client), and processor 79.6%. The 1920 and Push fixes came without regression tests, and the Apache e2e job still skips every TestSubscription* case.

The fake server I used for the probes is about 150 lines: an rpc.IClientRPCService implementation that answers PipeSubscribe, served with thrift.NewTSimpleServer4. As a test fixture in consumer, it would give both fixes regression tests and make the error, redirect-ACK and recovery branches cheap to cover.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status at 43ee497: subscription/consumer/provider_retry_test.go adds TestPollRetriesReplacedConnection and TestPushContinuesAfterCriticalPollError, both against an in-process fake server. The 1920 and Push fixes now have regression tests. Thanks for adding them.

go test -cover ./subscription/... now reports 21.0% overall, up from 11.3%: consumer is at 17.8% (was 0.1%), internal/protocol at 28.8%, and processor at 79.6%. The Apache e2e job at this head still reports all 24 TestSubscription* cases as --- SKIP, so the server-backed cases run only when IOTDB_SUBSCRIPTION_E2E=1 is set.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current Apache CI environment cannot run the subscription E2E suite because it does not provide a subscription-enabled server/config. The suite remains opt-in, and all subscription E2E scenarios have already been self-tested locally against the required environment. We plan to enable this coverage in a separate CI branch/pipeline that provisions the required server setup.

@JackieTien97 JackieTien97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up after re-testing at aeaa5d4 against the same activated 2.0.11-SNAPSHOT server (1C1D, subscription_enabled=true) with Go 1.25.14.

Fixed since the last review

  • Status 1920 and Push retry: confirmed with the same fake-server probes. Details are in the replies on those threads.
  • TLS: now documented as unsupported in the README, the example README and doc.go. That works for me.

Still open

  • Unit-test coverage: the fixes came without tests. See the reply on that thread.
  • Snapshot-completion E2E: 23/24 passed. The one failure, TestSubscriptionTableSnapshotStrictAutoCommitCompletion, received and verified all 3 rows, but AllConsumed() never became true. The ConfigNode logged Detected completion of pipe ... about 16 s before the timeout, but did not submit the next PipeHandleMetaChangeProcedure until after the test had timed out and dropped the pipe. This is the same server-side signature as before, and three reruns of the case passed in about 6 s each. Nothing needs to change on the client side.

New in this round

  • subscription/go.mod pins a v2 version that lacks the client APIs this module now uses, so a plain go get of the module does not build (inline).
  • The TSStatusCode alignment in client/protocol.go (inline).
  • go vet stdmethods warnings, which now also appear in the main module (inline).
  • Minor: client.DecodeTablet can return a Tablet with a column absent from the payload (HasColumnValues reports false). If such a Tablet reaches InsertTablet, getValuesBytes panics with interface conversion: interface {} is nil, not []int32. Subscription users never get the *client.Tablet, so this only affects direct callers of the new exported function. Returning an error from getValuesBytes for a column without values would avoid the panic.

With the decoder moved into client, every data check in the E2E suite still passes, so I found no decoding regression from the move.

Comment thread subscription/go.mod Outdated
go 1.25

require (
github.com/apache/iotdb-client-go/v2 v2.0.0-20260914074454-a25f68aa9681

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downstream users cannot build this module as released. This require pins github.com/apache/iotdb-client-go/v2 to a25f68a, the current main before this PR. Inside the repository, replace github.com/apache/iotdb-client-go/v2 => .. hides that, but replace only applies in the main module. A user who runs go get github.com/apache/iotdb-client-go/subscription@latest (README L35) therefore gets v2 at a25f68a.

I checked this with a separate module that replaces only subscription with a local checkout, so v2 is resolved from the module proxy the way it would be for a user:

  • At a53f30e, the build fails with undefined: client.SubscriptionPollError, client.SubscriptionHandshakeError and the other subscription status constants this PR adds to client/protocol.go.
  • At aeaa5d4, internal/record also fails on the new Tablet methods (GetTargetName, GetTimestampAt, ColumnCount, ColumnName, ColumnDataType, ColumnCategory). client.DecodeTablet and client.NewDecodedTablet are also new in this PR, so they are missing from that version as well.

A user can work around this by upgrading v2 separately, but go get of the subscription module alone produces a build that fails. Since the module now depends on unreleased v2 APIs, it needs a two-step release: merge the v2 changes first, then bump this require to a v2 version that contains them before the subscription module is tagged or announced. One way to do that is to move the v2 changes (status codes and the Tablet decoding API) into a separate PR that lands first. This PR can then require the merged commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b0eab1a. The nested go.mod files under subscription/, example/ and test/e2e/ are gone. The subscription packages are now github.com/apache/iotdb-client-go/v2/subscription/... in the root module and share its version. A separate module that imports v2/subscription/consumer from the 43ee497 checkout builds and runs. The README now says go get github.com/apache/iotdb-client-go/v2@latest. The root go.mod already declares go 1.25 on main, so the move doesn't raise the minimum Go version. Thanks.

Comment thread client/protocol.go
)

// TSStatusCode
// The names and values follow the current Java TSStatusCode definition. Legacy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description already calls this out as an intentional API change. Two observations that may still be useful:

  • The change covers the whole v2 status-code table, not just subscription. Against main, this file adds 205 constants, of which 31 relate to subscription, topics or consumers; the rest include stream, LBAC policy/label, TOTP and IoTConsensusV2 codes. It also removes 3 constants and renumbers 4.
  • Six old values now belong to different names: 1000 (DatanodeAlreadyRegistered → AddConfignodeError), 1001 (NoEnoughDatanode → RemoveConfignodeError), 1002 (AddConfignodeError → RejectNodeStart), 1003 (RemoveConfignodeError → NoEnoughDatanode), 1007 (RegisterRemovedDatanode → CanNotConnectDatanode) and 1008 (CanNotConnectDatanode → TransferLeaderError). The renumbering corrects the mapping, but callers that compare against these names change behavior without a compile error, so the release notes should list these values explicitly.

Consider landing the status-code alignment as its own PR, together with the new Tablet decoding API. That lets it be reviewed and released independently of subscription, and it unblocks the subscription/go.mod bump described in the comment on that file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We kept the TSStatusCode alignment in this PR because the separate-module dependency problem that motivated splitting it has been removed. Subscription packages now live in the root github.com/apache/iotdb-client-go/v2 module, so the status-code and Tablet decoding APIs ship in the same module version. The exported-constant removals and renumbering are explicitly documented in the PR description and must be included in release notes. No separate prerequisite PR is required to unblock this work.

Comment thread client/tablet_decode.go Outdated
return value
}

func (d *tabletDecoder) ReadByte() int8 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go vet reports stdmethods here: method ReadByte() int8 should have signature ReadByte() (byte, error). The same check fires twice in subscription/internal/wire/codec.go, for WriteByte(int8) at L42 and ReadByte() int8 at L205. go vet ./client/ is clean on main, so this would be the first vet warning in the main module. CI doesn't run go vet, so nothing fails today. Renaming the methods to ReadInt8/WriteInt8 fixes all three.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 69fdf9a. The methods are now ReadInt8/WriteInt8 in both client/tablet_decode.go and subscription/internal/wire/codec.go, and go vet ./... is clean for the whole module at 43ee497. Thanks.

Comment thread subscription/consumer/provider.go Outdated
subscriptionFrameReserve = 1024
// Oversized-entry status is returned by servers that enforce subscription
// materialization limits. Keep the compatibility value local to the consumer.
subscriptionOversizedEntryStatus int32 = 1920

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested at aeaa5d4 with the same fake-server probe. When the server answers POLL with 1920, Poll now returns no messages and a nil error. The next Poll re-handshakes on a new connection (handshakes 1 → 2) and keeps polling without errors. In the code, commitNode still retries on 1920. This matches Java. Thanks for the fix.

Comment thread subscription/consumer/push_consumer.go Outdated
if err := c.consumer.checkOpen(); err != nil {
return err
}
if flowFatalPollError(failure) || flowCriticalPollError(failure) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested at aeaa5d4. With the first POLL answered by 1909 and later ones answered normally, Errors() reports nothing and the delivery loop keeps polling: 31 POLLs after 3 s, 52 two seconds later. The README (L485) and the Errors() doc comment now describe this behavior, which matches Java's AutoPollWorker. Thanks.

Comment thread test/e2e/config_test.go
// explicit environment opt-in. Endpoint and credential defaults come from the
// shared E2E configuration.
const (
subscriptionE2EDefaultEnabled = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status at aeaa5d4: go test -cover ./... under subscription/ reports 11.3% overall: consumer 0.1%, internal/protocol 28.8% (the Tablet decoding tests moved to client), and processor 79.6%. The 1920 and Push fixes came without regression tests, and the Apache e2e job still skips every TestSubscription* case.

The fake server I used for the probes is about 150 lines: an rpc.IClientRPCService implementation that answers PipeSubscribe, served with thrift.NewTSimpleServer4. As a test fixture in consumer, it would give both fixes regression tests and make the error, redirect-ACK and recovery branches cheap to cover.

@JackieTien97 JackieTien97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up after re-testing at 43ee497 against the same activated 2.0.11-SNAPSHOT server (1C1D, subscription_enabled=true) with Go 1.25.14.

Fixed since aeaa5d4

  • subscription/go.mod: the subscription packages are now part of the root module. Details are in the reply on that thread.
  • go vet: clean for the whole module (reply on that thread).
  • client.DecodeTablet: getValuesBytes now returns an error instead of panicking when a column has no values, and a test covers it.
  • Status 1920 and Push retry: the fake-server probes give the same results as at aeaa5d4, and provider_retry_test.go now covers both fixes.

Still open

  • TSStatusCode: the client/protocol.go thread has no response yet, and the file is unchanged since aeaa5d4.
  • Coverage: better, but the subscription E2E cases still don't run in CI (reply on that thread).

E2E at 43ee497: 21/24 passed

  • TestSubscriptionTableSnapshotStrictManualCommitCompletion and TestSubscriptionTreeConsumerReadsMultipleTopics failed with the server-side signature from the earlier thread. All rows arrived and the ConfigNode logged Detected completion of pipe .... The next PipeHandleMetaChangeProcedure came 48 s later in the first case, and not at all before the second test timed out and dropped its pipes.
  • TestSubscriptionTableColumnFilterNoMatchReturnsNothing failed in cleanup. This is a new, timing-dependent failure in the drop-topic loop; details are inline.
  • Unit tests pass with -race. All eight example runs also succeed against the server: tree and table, each with pull, push, incremental, and incremental with -processors.

Comment on lines +79 to +88
cleanupCtx, cancel := context.WithTimeout(context.Background(), subscriptionE2ECleanupTimeout)
defer cancel()
for {
err := manager.DropTopic(cleanupCtx, name, subsession.DropOptions{IfExists: true})
if err == nil {
return
}
select {
case <-cleanupCtx.Done():
t.Errorf("drop topic %s: %v", name, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup flake: the drop loop can give up before the server releases the consumer.

In the full E2E run at 43ee497, TestSubscriptionTableColumnFilterNoMatchReturnsNothing failed only in this cleanup. For the whole subscriptionE2ECleanupTimeout (10 s), DropTopic returned the topic is subscribed by some consumers. Five reruns of the case passed.

The DataNode log, the code and a fake-server probe point to this sequence:

  • The last quiet Poll reached its deadline before the idle server answered. flowRemainingMilliseconds (pull_flow.go) sends the client's remaining poll time as the server-side poll timeout, so the answer can arrive just after the deadline. transport.Connection.Call then aborts the connection. At that moment the DataNode logged only remove consumer config ... when handling exit.
  • The cleanup Close() ran next. subscriptionProvider.close returns nil without sending CLOSE when the connection is already closed. By then Close() has stopped the background workers, including runEndpointSync, which handles reconnects, so nothing reconnects to send it.
  • The DataNode kept the subscription until its inactivity check closed the consumer (inactive for 14269 ms, exceeding timeout 10000 ms), about 4 s after this loop had given up.

The probe reproduces this deterministically. When the fake server holds POLL past the client deadline, a Close() right after Poll returns nil and the server never receives CLOSE. When the server answers at once, or when Close() comes a second later after recovery has reconnected, CLOSE arrives. Closing a Push consumer while a POLL is in flight also skips CLOSE.

From reading the Java SDK, its close() also skips CLOSE when an RPC is still in flight, because prepareClose() force-closes those connections. The server's inactivity timeout is therefore the fallback in both clients. I did not run the Java client for this case.

The simplest fix is in this loop: give it more time than the server-side cleanup needs, for example 30 s. That cleanup takes the consumer's connection-timeout-ms (10 s in these tests) plus the checker's delay, 14.3 s in this run. Optionally, flowRemainingMilliseconds could leave a small margin so an idle server usually answers before the client deadline. That would also avoid the reconnect and handshake that follow an aborted poll.

Comment thread subscription/go.mod Outdated
go 1.25

require (
github.com/apache/iotdb-client-go/v2 v2.0.0-20260914074454-a25f68aa9681

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b0eab1a. The nested go.mod files under subscription/, example/ and test/e2e/ are gone. The subscription packages are now github.com/apache/iotdb-client-go/v2/subscription/... in the root module and share its version. A separate module that imports v2/subscription/consumer from the 43ee497 checkout builds and runs. The README now says go get github.com/apache/iotdb-client-go/v2@latest. The root go.mod already declares go 1.25 on main, so the move doesn't raise the minimum Go version. Thanks.

Comment thread client/tablet_decode.go Outdated
return value
}

func (d *tabletDecoder) ReadByte() int8 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 69fdf9a. The methods are now ReadInt8/WriteInt8 in both client/tablet_decode.go and subscription/internal/wire/codec.go, and go vet ./... is clean for the whole module at 43ee497. Thanks.

Comment thread test/e2e/config_test.go
// explicit environment opt-in. Endpoint and credential defaults come from the
// shared E2E configuration.
const (
subscriptionE2EDefaultEnabled = false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Status at 43ee497: subscription/consumer/provider_retry_test.go adds TestPollRetriesReplacedConnection and TestPushContinuesAfterCriticalPollError, both against an in-process fake server. The 1920 and Push fixes now have regression tests. Thanks for adding them.

go test -cover ./subscription/... now reports 21.0% overall, up from 11.3%: consumer is at 17.8% (was 0.1%), internal/protocol at 28.8%, and processor at 79.6%. The Apache e2e job at this head still reports all 24 TestSubscription* cases as --- SKIP, so the server-backed cases run only when IOTDB_SUBSCRIPTION_E2E=1 is set.

@JackieTien97
JackieTien97 merged commit a06b95d into main Nov 20, 2026
7 checks passed
@JackieTien97
JackieTien97 deleted the supports_subscription branch November 20, 2026 06:36
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.

3 participants