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
Enable transactional endpoint evaluation. #700
Conversation
server/src/query/engine.rs
Outdated
let mut borrow = self.stream.borrow_mut(); | ||
borrow.as_mut().unwrap().as_mut().poll_next(cx) | ||
let mut lock_borrow = self.lock.borrow_mut(); | ||
let mut stream_borrow = self.stream.borrow_mut(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs a shitload of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some comments from my limited POV. I don't think I understand it fully though. The code is crazy complicated and it should burn.
It's good, but the unsafe blocks need a lot of comments explaining why they are safe, and potentially some asserts to make sure the pointers are not null and obey preconditions we may want. |
This should probably be rebased -i. For example, there is no reason to define TransactionStatic as Rc and then change it to Arc. |
Also, we should not have a commit message "fix" :-) I did that to have a single commit on top of the old branch, those changes should be split among other commits in a meaningful way. |
likely a squash is enough here |
+1 |
server/src/query/engine.rs
Outdated
pub(crate) type TransactionStatic = Arc<Mutex<Transaction<'static, Any>>>; | ||
|
||
struct QueryResults<T> { | ||
fut: RefCell<Option<T>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a single inner: RefCell is a bit cleaner, but not much.
If smol-rs/async-lock#20 is approved it would simplify this code a bit. |
08bf2d0
to
3eb1f61
Compare
I fixuped the fix commit. |
3eb1f61
to
7aeccd4
Compare
I just noticed that tokio's mutex has an easier to use API: pub async fn lock_owned(self: Arc) -> OwnedMutexGuard which is somewhat on the lines of the patch I sent to async_mutex. Using that could simplify this code, but add more dependencies on tokio. |
@espindola would you mind suggesting a patch? I'm really afraid to touch that code. I think that any simplification would be very appreciated in this case. Regarding Tokio dependencies - is it a problem? |
Please do squash or otherwise reorganize the commits. We still have a patch with:
Also, tests fail in the intermediate commits. |
I will try. Not sure what the status is for trying to not use tokio, but it is always nice to have options. |
7aeccd4
to
b9112db
Compare
Squashed everything. |
I have pushed a496bb3. Feel free to include it if you like it. |
b9112db
to
00e2949
Compare
@espindola very nice, I squashed it in. |
00e2949
to
a5e198f
Compare
And I have now pushed d2a3731, which uses pin_project. The net result is that we get only one extra unsafe with this PR if that is included. |
And d3dc67f on top of that that uses flatten_stream. |
@espindola doesn't this part of the code use a pointer to a local variable (the query_string seems to be just a local string)? That doesn't look very safe at all 🤔 |
It doesn't use a pointer to the String, it uses a pointer to the str. |
a5e198f
to
ba4bc6b
Compare
Oh man, that looks so much better than the original. I can actually understand that. Awesome work. |
BTW, smol-rs/async-lock#20 got merged, so once that is released we should be able to move back to async_mutex. |
@@ -212,7 +212,7 @@ The `findMany()` method is convenient, but also problematic if you have a lot of | |||
entities stored because loading them can take a lot of time and memory. In future | |||
releases of ChiselStrike, the runtime will enforce a maximum number of entities | |||
`findMany()` can return and also enforce timeouts at the data store level. The | |||
runtime will also provide optional pagination for the `findMany()` method. | |||
runtime will also provide optional pagination for the `findMany()` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the future: avoid unrelated changes to the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but this is an editor extension that trims trailing white-spaces on save...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fine, but use git add -p
to select what goes into the PR or not
transaction automatically. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up: Mention that the user should be careful that external accesses like POST requests with side effects obviously are not part of the transaction and users should be careful with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the situation. You mean that our user would call a chisel endpoint within another chisel endpoint? Doesn't that go without saying?
Fix transactions test.
ba4bc6b
to
ee76e53
Compare
So, is this approved? Looks like github somehow lost the approval. |
I had to do another rebase as there were changes in main and approval is lost when you push a change to the branch upon which a PR is based. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reapproving
No description provided.