The native engine's streams had one shard that never closed, iterators
that never expired and records trimmed only by count, so the consumer
code that handles an expired iterator, a stale checkpoint or a shard
hand-off only ran for the first time against AWS.
Four settings, each off by default, bring a stream closer to AWS:
- stream-shard-count gives each stream that many open shards. An item's
changes go to the shard its partition key picks, so they stay in order.
- stream-shard-rollover-seconds closes an open shard once it has been
open that long, and a child shard naming it as ParentShardId takes its
keys.
- stream-iterator-expiry-enabled expires an iterator 15 minutes after it
is returned: GetRecords answers ExpiredIteratorException.
- stream-retention-enabled trims records after 24 hours and drops a
closed shard 24 hours after it closes. GetShardIterator then refuses a
trimmed sequence number with TrimmedDataAccessException and one the
shard never held with ValidationException "Invalid SequenceNumber for
the shard".
Disabling a stream closes its open shards, as AWS does, and a closed
shard read to its end returns no NextShardIterator. DescribeStream pages
with Limit and ExclusiveStartShardId. GetShardIterator refuses a shard
the stream does not have, and a sequence iterator with no sequence
number, with AWS's messages. The 1,000-record limit now holds for the
whole stream, and a read is refused as trimmed exactly when its shard
lost a record after the cursor.
Closes#4522
Co-authored-by: Jason Pogozelski <jpogozelski@xoi.io>