Writing to a stream and setting stream metadata in a transaction.

I’m attempting to:

  1. Write events to a stream

  2. Add metadata to the stream metadata

These are two different operations but I would like them to be transactional in nature…if one fails roll them both back.

It didn’t look like the transaction support encompassed this scenario. Did I miss something? Does anybody have a recommendation on how to handle this?

In our case we’ll only write the metadata when the stream is initially created (and then we’ll read it often).

When creating the stream, should we write the metadata first, stream first, or does it matter?

Thanks

You can handle this with at least once and expected version.
Idempotency gives you most of the support.

You can handle this with at least once and expected version.

Idempotency gives you most of the support.

This workaround does not really solve the issue:

If adding events and metadata is not transactional, one could be written without the other. So I have either a metadata-stream without events or an event-stream without metadata. Both is not desirable.

I take it there is not transaction support for write operations that span multiple streams?

We have looked at adding it, its actually pretty trivial to add (on a single replica set). What has held us back from doing it is that we are currently working towards multiple node replica sets where it becomes a problem.

Thanks for getting back on this so quickly.

So I guess we just have to live with a small potential window of inconsistency for now.