Skip to content

Fix SessionDataSet: row count, async dispose, and null measurement issues (#53, #54, #55)#56

Merged
HTHou merged 2 commits intoapache:mainfrom
CritasWang:fix/session-dataset-issues-53-54-55
Apr 28, 2026
Merged

Fix SessionDataSet: row count, async dispose, and null measurement issues (#53, #54, #55)#56
HTHou merged 2 commits intoapache:mainfrom
CritasWang:fix/session-dataset-issues-53-54-55

Conversation

@CritasWang
Copy link
Copy Markdown
Contributor

@CritasWang CritasWang commented Apr 28, 2026

…sues (apache#53, apache#54, apache#55)

修复 SessionDataSet 行数统计、异步释放及空值测点问题

- Fix CurrentBatchRowCount() always returning 0 by eagerly constructing
  the first TsBlock in RpcDataSet constructor when initial data is available
  修复 CurrentBatchRowCount() 始终返回 0 的问题,在构造函数中预先反序列化首个 TsBlock

- Add IAsyncDisposable to SessionDataSet and RpcDataSet, providing
  DisposeAsync() that properly awaits Close() to avoid sync-over-async deadlocks
  为 SessionDataSet 和 RpcDataSet 添加 IAsyncDisposable 接口,支持 await using 语法

- Fix GetRow() including null-valued columns in RowRecord by using
  IsNull() check before calling type-specific getters, instead of relying
  on value type null checks which always pass for int/bool/float/etc.
  修复 GetRow() 中值类型默认值绕过 null 检查导致空值列被错误包含的问题
Copy link
Copy Markdown
Contributor

@HTHou HTHou left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes. The main direction looks good: eager TsBlock construction addresses CurrentBatchRowCount(), and the explicit null check in GetRow() fixes the value-type default-value issue.

One thing I think should be fixed before merge: SessionDataSet.Close() still never sets _isClosed = true. After the first successful close it also sets _client = null, so a second call to Close() can enter the same branch again and dereference _client.SessionId. This becomes more visible now that both Dispose() and DisposeAsync() route through Close(). Could we make Close() idempotent, for example by marking _isClosed = true in the close path before returning the client and avoiding re-adding a null/already-returned client?

It would also be great to add regression tests for:

  • CurrentBatchRowCount() returning the first TsBlock size before reading the first row.
  • GetRow() excluding null-valued measurements for value types like BOOLEAN, INT32, and DOUBLE.

修复 SessionDataSet.Close() 幂等性问题并添加回归测试

- Set _isClosed = true in Close() finally block to prevent
  NullReferenceException on repeated Close/Dispose/DisposeAsync calls
  在 Close() 的 finally 块中设置 _isClosed = true,防止重复调用导致空引用异常

- Add RpcDataSetTests covering:
  - CurrentBatchRowCount returns correct size before first row read
  - CurrentBatchRowCount returns 0 when no data
  - GetRow excludes null-valued measurements for value types (BOOLEAN, INT32, DOUBLE)
  - DataTypes/Measurements/Values lists stay consistent
  添加 RpcDataSet 回归测试覆盖行数统计和空值测点排除
@CritasWang
Copy link
Copy Markdown
Contributor Author

Thanks for the fixes. The main direction looks good: eager TsBlock construction addresses CurrentBatchRowCount(), and the explicit null check in GetRow() fixes the value-type default-value issue.

One thing I think should be fixed before merge: SessionDataSet.Close() still never sets _isClosed = true. After the first successful close it also sets _client = null, so a second call to Close() can enter the same branch again and dereference _client.SessionId. This becomes more visible now that both Dispose() and DisposeAsync() route through Close(). Could we make Close() idempotent, for example by marking _isClosed = true in the close path before returning the client and avoiding re-adding a null/already-returned client?

It would also be great to add regression tests for:

  • CurrentBatchRowCount() returning the first TsBlock size before reading the first row.
  • GetRow() excluding null-valued measurements for value types like BOOLEAN, INT32, and DOUBLE.

fixed

Copy link
Copy Markdown
Contributor

@HTHou HTHou left a comment

Choose a reason for hiding this comment

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

Thanks, the requested idempotency fix and regression tests are in place. CI is green and the changes look good to me.

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.

2 participants