marten icon indicating copy to clipboard operation
marten copied to clipboard

On a new database, auto create does not work as expected when there is a transaction scope

Open longility opened this issue 4 years ago • 1 comments

I believe I simplified the issue. If I have more time, I may be able to create an example if needed to reproduce.

On a new database where there are no martendb generated functions, when my code has a transaction scope, postgres command fails to call the insert function when doing the following:

using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
using var session = documentStore.OpenSession(SessionOptions.ForCurrentTransaction());
session.Insert(entity); // Fails here. 
// cannot find db functions that are created by auto create says it does not exist

My guess is we need to autocreate the functions and maybe tables outside of the transaction scope or at least have an option to do that? Thoughts?

longility avatar Apr 11 '20 13:04 longility

@longility sorry for late answer. That sounds weird. Currently I don't know what might be the cause. We'll try to check that up.

oskardudycz avatar Apr 29 '20 17:04 oskardudycz

I was able to reproduce this today, and I have no earthly idea why. I think this is going to need to be strictly a documentation item. Plus encouraging folks to not use ambient transactions.

jeremydmiller avatar Jun 28 '23 17:06 jeremydmiller