Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement savepoint API for Microsoft.Data.Sqlite #22273

Closed
wants to merge 2 commits into from

Conversation

roji
Copy link
Member

@roji roji commented Aug 27, 2020

Closes #20228

@roji roji requested a review from bricelam August 27, 2020 15:02
@roji roji linked an issue Aug 27, 2020 that may be closed by this pull request
global.json Outdated Show resolved Hide resolved
@@ -113,6 +113,74 @@ public override void Rollback()
RollbackInternal();
}

#if NET5_0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should expose the same API on all targets

@ajcvickers
Copy link
Member

A couple of concerns:

  • If the underlying change is not in preview 8, then what happens when someone tries to use our daily build on preview 7?
  • It's pretty late in the game to switch to doing a multi-target build.

Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

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

LGTM

throw new InvalidOperationException(Resources.TransactionCompleted);
}

_connection.ExecuteNonQuery("SAVEPOINT " + savepointName);
Copy link
Contributor

@bricelam bricelam Aug 27, 2020

Choose a reason for hiding this comment

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

Delimit and escape the identifier. Terminate statements.

SAVEPOINT "The ""SaveChanges"" Savepoint";

throw new InvalidOperationException(Resources.TransactionCompleted);
}

_connection.ExecuteNonQuery("ROLLBACK TO " + savepointName);
Copy link
Contributor

Choose a reason for hiding this comment

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

ROLLBACK TO SAVEPOINT (the SQL standard syntax)

throw new ArgumentNullException(nameof(savepointName));
}

if (string.IsNullOrWhiteSpace(savepointName))
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace is allowed

@roji
Copy link
Member Author

roji commented Aug 27, 2020

Yeah, this does mean that until rc1 is released, users of our daily builds would have to also have SDK daily builds. I can also submit this after rc1 if we're OK with doing it even later (and think we'll get approval). I'm not sure what the risks are of multi-targeting, it's always been straightforward for me.

@ajcvickers @bricelam if you're against this, let me know and I'll close.

@bricelam
Copy link
Contributor

bricelam commented Aug 27, 2020

What happens if we add virtual methods to netstandard 2.0 only? Will it explode on 5.0.0-rc.1?

@ajcvickers
Copy link
Member

I feel like adding complications for the community and for daily builds is not wise at this stage. I also don't think this meets the bar to come in after rc1. I think this should just be punted to 6.0 at this point.

@bricelam
Copy link
Contributor

And if we add the methods to netstandard2.0, we can still light it up in the EF Core provider, right?

@roji roji closed this Aug 27, 2020
@roji
Copy link
Member Author

roji commented Aug 27, 2020

In EF we already support savepoints without going through any System.Data API (RelationalTransaction implements everything).

Not sure what happens if we add virtual methods to netstandard2.0, but I'm pretty sure it wouldn't work properly - it's like having the same virtual method signature in a superclass and base class. I can't see any way where polymorphically calling the base virtual method would end up calling the subclass implementation... I guess we can discuss all this for 6.0.

@bricelam
Copy link
Contributor

bricelam commented Aug 27, 2020

So it would hide the ADO.NET versions, and you'd have to cast to SqliteTransaction to call them? I can live with that. Aren't there already providers in the wild that expose these methods and are in the same boat until they can multi-target net5.0?

@bricelam
Copy link
Contributor

I vote for putting these in now and multi-targeting in 6.0. Thoughts @ajcvickers?

@roji
Copy link
Member Author

roji commented Aug 27, 2020

I think there's much less value in doing this if we're not implementing the System.Data methods (i.e. multi-targeting). If you're using SqliteTransaction, you're already coding directly against MS.Data.Sqlite, so it's very easy to just execute the commands yourself. Also, this situation with a netstandard2.0 virtual method with the same signature as a net5.0 one doesn't seem totally kosher...

@ajcvickers
Copy link
Member

This only adds value at the ADO.NET level, right? EF Core should show no change in behavior. I'm really struggling with any risk right now, since it seems to add such minimal value.

@bricelam
Copy link
Contributor

Yeah, given that the EF Core provider supports savepoints without it, I agree we can just punt it.

@roji
Copy link
Member Author

roji commented Aug 27, 2020

The world isn't just about EF 😉

The point here was to start actually delivering the new System.Data APIs we're introducing. At the end of the day the commit went into runtime on August 5th, and we can't deliver our own Sqlite provider with support for it in .NET 5.0 (to be released in a while still...). That makes me sad regardless of whether EF uses it or not.

@bricelam
Copy link
Contributor

Agreed. It's insane that Preview 8 was an entire month stale by the time it was released.

@ajcvickers
Copy link
Member

ajcvickers commented Aug 27, 2020

@roji Agreed, it makes me sad too. However, what we learn from this is that we really need to front-load System.Data work. Like, even more! Also, we should mark the API reviews in dotnet/runtime as blocking based on getting them into an early preview so that we can consume them. So it's sad, but it should be pretty easy for us to do better next time.

@bricelam bricelam reopened this Aug 27, 2020
@roji roji requested a review from dougbu as a code owner August 27, 2020 17:33
@bricelam
Copy link
Contributor

So... I updated it to not depend on the latest SDK. How do we feel about the change now?

@dougbu
Copy link
Member

dougbu commented Aug 27, 2020

users of our daily builds would have to also have SDK daily builds.

Curious: How does the SDK used to build EF bleed into the daily builds❔ If this is about requiring a repo-local version of the SDK, that requirement exists regardless because global.json lists runtimes that must be added.

I updated it to not depend on the latest SDK.

Curious: What problems in the RC1 SDK led you to need the older version❔ I see the above discussion but don't get it.

@ajcvickers
Copy link
Member

I still think it's more sensible to do this in 6.0.

@dotnet/efteam Do others have any thoughts on this?

@AndriySvyryd
Copy link
Member

No user has asked for this, so no-one (except us) would be disappointed if we punt this.

@ajcvickers
Copy link
Member

I know it sucks, but I think we should punt this. Sorry. ☹️

@bricelam bricelam closed this Aug 27, 2020
@smitpatel
Copy link
Member

@roji @bricelam - Does this branch needs to be preserved or can we garbage collect it?

@roji roji deleted the SqliteSavepoints branch October 2, 2020 09:33
@roji
Copy link
Member Author

roji commented Oct 2, 2020

Replaced by #22869

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.

Sqlite: add transaction savepoint API
6 participants