You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been thinking that I still do not use change feeds because they do not give me enough promise that the function is going to run for many reasons. after speaking with @timmaxw for a few minutes there looks like there is an easy way to give users the options for triggers.
use most of the code that runs for when an index starts
before the corutine launches check to see if node is primary of the shard o the document
allow for non determanisc queries
allow for a timeout if the user wants to allow for a timeout
Proposal: triggers #997 allow users to make mistakes. Lots of the issues with dealing with trigger development is making sure the users dont mess up. Let the users mess up and fix the bugs from there. users that are using trigger to update tables will have to be responsible for not ending up in a never ending loop.
True that would be great if it would happen but in my mind what happens if the script dies does not start or you run it on a server that is not primary. and the max size overflows. also i do alot of my work in reql so i dont even need it to come back to my app code i want it done as fast as it can be done inside of the database.
We are going to provide a reliable variant of changefeeds, hopefully relatively soon (#2953 ).
Triggers wouldn't automatically be more reliable than changefeeds. I think we can provide pretty much the same guarantees in either case (we just have to design and implement the semantics for them).
A changefeed based interface on the other hand would fit a little better into our current API.
@VeXocide explained to me that if you need a specific type of guarantee, implementing them with changefeeds is a whole lot more difficult than with triggers.
While you could theoretically run a changefeed client on the same server as the primary for the table to get very similar guarantees as a trigger running on the primary, maintaining this can become a pain when failover and primary changes come into play.
Resumable changefeeds fix many issues, but will still behave somewhat differently from triggers in certain failure cases and require additional code to handle those on the client side.
So I suppose there's a point in having triggers in addition to changefeeds.
A simple implementation of triggers (as the one described in the original post) might be useful already.
It would still not work for cases where you cannot afford to miss a change. If the trigger writes to a table B and the server(s) hosting table B go down, the trigger will be unable to execute and the change will be lost. It would provide stronger guarantees than the current (non-resumable) version of changefeeds, but still might not be strong enough for many applications.
For this, we would probably need to implement some sort of log to rerun triggers at a later time if they fail. That in turn poses the question of what happens if a trigger has other side-effects that succeeded before it failed...
I like to keep my code as close to my data as i can to keep my genrutnees as strong as i can. I think a few options could make this more of the users probelm to solve. For example the user should be able to know that the write to the down table failed so then they can write to another local table that then they can have a function to fix what ever events are missing so then they are incharge of whatever consicstancy issues occure.
If possiable there should be a global hidden table of functions that triggers can use. this way if you need 10 tables to use the same trigger which does a join and replaces the record that becomes an option. My feeling is this works a lot easier being emdbed in the database.
Triggers are used when rethinkdb needs to work with updated or inserted data on its own side internal. Change feeds is when the user application wants to be notified that of changes in the database.
A change feed is like on a message board or blog. someone has added a new comment so the app listening will be able to know and push that out. But triggers are for background jobs data chances in the db that the app doe not need to know abotu and for built in fetaures that can effect the rest of the app easily and does not require restarting a process. A good example of this is logging changes to fields if your appli=cation allows you to edit your email address the trigger will log everytime you change your email address and aovid appliaation logic meaning it will work regardless of client.
@RubenKelevra That sounds like it will be covered by #3471 eventually. The first implementation will be relatively basic, but in the longer term we are planning to implement changefeeds that you can resume after any kind of disconnect or server failure.
Activity
thelinuxlich commentedon Nov 22, 2014
For me, the most desired feature for changefeeds is that they need to know how to restart and catch updates in-between.
wojons commentedon Nov 22, 2014
True that would be great if it would happen but in my mind what happens if the script dies does not start or you run it on a server that is not primary. and the max size overflows. also i do alot of my work in reql so i dont even need it to come back to my app code i want it done as fast as it can be done inside of the database.
thelinuxlich commentedon Nov 22, 2014
I also believe that these things would be great for Meteor and Voltrb if they implement RethinkDB as alternative backend
danielmewes commentedon Nov 24, 2014
We are going to provide a reliable variant of changefeeds, hopefully relatively soon (#2953 ).
Triggers wouldn't automatically be more reliable than changefeeds. I think we can provide pretty much the same guarantees in either case (we just have to design and implement the semantics for them).
A changefeed based interface on the other hand would fit a little better into our current API.
danielmewes commentedon Nov 24, 2014
@VeXocide explained to me that if you need a specific type of guarantee, implementing them with changefeeds is a whole lot more difficult than with triggers.
While you could theoretically run a changefeed client on the same server as the primary for the table to get very similar guarantees as a trigger running on the primary, maintaining this can become a pain when failover and primary changes come into play.
Resumable changefeeds fix many issues, but will still behave somewhat differently from triggers in certain failure cases and require additional code to handle those on the client side.
So I suppose there's a point in having triggers in addition to changefeeds.
A simple implementation of triggers (as the one described in the original post) might be useful already.
It would still not work for cases where you cannot afford to miss a change. If the trigger writes to a table B and the server(s) hosting table B go down, the trigger will be unable to execute and the change will be lost. It would provide stronger guarantees than the current (non-resumable) version of changefeeds, but still might not be strong enough for many applications.
For this, we would probably need to implement some sort of log to rerun triggers at a later time if they fail. That in turn poses the question of what happens if a trigger has other side-effects that succeeded before it failed...
thelinuxlich commentedon Nov 24, 2014
I'm okay with it losing updates in the rare case of a server going down.
wojons commentedon Nov 24, 2014
@thelinuxlich @danielmewes
I like to keep my code as close to my data as i can to keep my genrutnees as strong as i can. I think a few options could make this more of the users probelm to solve. For example the user should be able to know that the write to the down table failed so then they can write to another local table that then they can have a function to fix what ever events are missing so then they are incharge of whatever consicstancy issues occure.
If possiable there should be a global hidden table of functions that triggers can use. this way if you need 10 tables to use the same trigger which does a join and replaces the record that becomes an option. My feeling is this works a lot easier being emdbed in the database.
Triggers are used when rethinkdb needs to work with updated or inserted data on its own side internal. Change feeds is when the user application wants to be notified that of changes in the database.
A change feed is like on a message board or blog. someone has added a new comment so the app listening will be able to know and push that out. But triggers are for background jobs data chances in the db that the app doe not need to know abotu and for built in fetaures that can effect the rest of the app easily and does not require restarting a process. A good example of this is logging changes to fields if your appli=cation allows you to edit your email address the trigger will log everytime you change your email address and aovid appliaation logic meaning it will work regardless of client.
RubenKelevra commentedon Aug 19, 2015
Well it's might be nice to combine both features. Something which works like:
When there are changes on X do notify me.
And then, connect and let the database push me changes.
Else let me fetch the pushes at once, without any push.
When reconnecting via push-request to a trigger, you'll receive everything which hasn't been pushed.
This would meet my requirements :)
danielmewes commentedon Aug 24, 2015
@RubenKelevra That sounds like it will be covered by #3471 eventually. The first implementation will be relatively basic, but in the longer term we are planning to implement changefeeds that you can resume after any kind of disconnect or server failure.
RubenKelevra commentedon Aug 24, 2015
Nice! 👍
thelinuxlich commentedon Mar 26, 2018
@srh shouldn't this be closed in favor of write hooks?