Disable transactions for KeyValueTable or enable per-dataset transactions

16 views
Skip to first unread message

Tuomas D

unread,
Mar 20, 2025, 6:28:48 PMMar 20
to CDAP User
Hi,

I have existing KeyValueTable datasets and workflow (utility) which is initialized from AbstractService (passing DatasetContext and Transactional).

This utility will load datasets and operate on them (read, write, etc).
There is now concurrency access issues as only single transaction cross all threads accessing this utility (via AbstractHttServiceHandler) can be active.
If accessed by multiple threads, even for different dataset instances, it will cause transactional error ("Attempted to start a transaction within active transaction" -> as I'm creating new transactions for each access/thread).

If I would be able to pass DatasetContext and load dataset using through AbstractHttServiceHandler invocation I would have per-thread isolation for transactions but unfortunately I'm not able do that.

Transactions are not need in my use case - each key (row) in namespaced datasets are added, read, updated and deleted in controlled fashion.

Is there way to define existing KVTable as non-transactional?
Is there way to enable transactions per dataset instance?
is there way to start/configure MultithreadDatasetCache for AbstractService?

Sample 
 context -> AbstractService

thread1
  context(Transactional).execute(TXRunnable ->
       keyvalutable = context(DatasetContext).getDataset("namespace1", "mydataset")
       keyvalutable.write(...)
       ....

thread2
  context(Transactional).execute(TXRunnable ->
       keyvalutable = context(DatasetContext).getDataset("namespace2", "mydataset")
       keyvalutable.write(...)
       ....

If threads 1 & 2 run concurrently then latter will receive "Attempted to start a transaction within active transaction"

Thanks, Tuomas
Reply all
Reply to author
Forward
0 new messages