-
Notifications
You must be signed in to change notification settings - Fork 92
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
Job cancellation doesn't work in database/sql driver #630
Comments
My guess is that this is due to the I believe we will need to move forward with something like #352 for this to be viable since there is no way using plain To confirm, are you using pgx under the hood somehow and are you using pgbouncer? |
Yes, it's No, My understanding from the docs was that when |
Without opencensus wrapping it also not working. This means, using |
Right the issue is that River's dbsql driver doesn't support listen at all at the moment, so it can't receive notifications. #352 was my idea for how we could solve that. I think while @brandur and I were discussing it we were mostly focused on whether it was needed as an optimization for job fetching, but without really considering job cancellation. We built a poll only mode that covers some of the other features which otherwise use listen/notify, but there is no such fallback for cancellation. The only way a running job actually gets cancelled is if the worker it's running on gets the cancel signal over listen/notify, which essentially means it just doesn't work at all in the dbsql driver as of today. In theory the producer could poll the table for any active jobs being worked, but that's a ton of extra query load for a rare event. I really think some kind of pubsub listener setup is the only good way for that feature to work and we should probably figure out how to make that happen in the dbsql driver. |
I understand. Thanks for getting back to me so quickly. I am still in the research phase. I really liked River, since it fits extremely nicely to our needs and it answers questions that other frameworks don't bother asking (ensuring atomic/consistent job scheduling) but unfortunately I might need to consider other options in this case, since switching to a raw pgx connection does not seem possible with the current code base. |
Just to make sure I understand the use case, are you saying in your setup it would be difficult to make a pgx pool that's solely for the purpose of the 1-conn-per-client listener process (as illustrated in #352)? Or that it would be difficult for you to switch to using a raw pgx pool for all of the rest of your codebase? With the approach in #352 the rest of your codebase would still be able to use whatever abstraction you have today, so long as you can also provide the River driver with a plain pgx pool that it can check out a conn from solely for the purpose of listening for pubsub events. Would love to hear more about it if there's more to the story so I can make sure I'm considering the full set of use cases. Otherwise we could probably ship something like that PR pretty quickly IMO. |
Our workers and clients would run within the same Go app. Am I understanding correctly that the sole purpose of the db connection that is passed to the RiverClient is for listening for jobs? Does this mean that within a client logic, if I were to use the plain sql connection (extracted from GORM) to schedule a job, notification and atomic subscription will work correctly? Also, does this mean that it should not be a problem to use GORM within the Worker's If the |
@mokiat well, my comments were probably pretty confusing in light of how #352 has rotted since it was open (including it being based on an earlier merged PR but showing a huge diff). I just updated it now, so if you check it out again, the following will probably make much more sense.
Nope! There's essentially 3 categories of usage for database connections:
The proposal in #352 is to allow an alternate way for obtaining connections for use case (3) above, and is only applicable to drivers that don't otherwise support
With the I hope that all makes sense! Can you let me know if this answers your questions and if you think this would address your concerns? |
I think I have a better understanding now. My idea and ask was slightly different, however. Let's ignore #352 for a second. What would happen if instead I were to use In other worlds, the I am assuming this would work but just want to make sure. |
Ok, after a bit more playing around, I realize why #352 is required. It all has to do with the I switched to the commit from the PR to give it a try. Scheduling a job from a transaction and cancellation from the UI work as expected. However, cancellation from source code does not work. Neither Also, side note for the docu, the GORM ConnPool could be of type |
Hi!
I am using the example
SortWorker
job with small adjustments to test longer-running jobs with cancellation but it does not seem to work.When the job appears in the User Interface (riverui), I click
Cancel
but the job keeps running. In the logs I eventually get fromSTARTING
toWILL DO
but never observeCANCELLED
.The only thing that indicates some attempt at cancellation is the metadata field on the job which states:
Am I doing something wrong or is there a potential bug?
I am running
v0.12.1
and usingriverdatabasesql.New
, though the underlying connection ispgx
, wrapped with opencensus tracing (ocsql).The text was updated successfully, but these errors were encountered: