Skip to content

triggers - attempt 2 #3367

Closed
Closed

Description

@wojons

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.

Activity

  1. thelinuxlich commented on Nov 22, 2014

    @thelinuxlich

    For me, the most desired feature for changefeeds is that they need to know how to restart and catch updates in-between.

  2. wojons commented on Nov 22, 2014

    @wojons
    ContributorAuthor

    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.

  3. thelinuxlich commented on Nov 22, 2014

    @thelinuxlich

    I also believe that these things would be great for Meteor and Voltrb if they implement RethinkDB as alternative backend

  4. danielmewes commented on Nov 24, 2014

    @danielmewes
    Member

    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.

  5. added this to the backlog milestone on Nov 24, 2014
  6. danielmewes commented on Nov 24, 2014

    @danielmewes
    Member

    @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...

  7. thelinuxlich commented on Nov 24, 2014

    @thelinuxlich

    I'm okay with it losing updates in the rare case of a server going down.

  8. wojons commented on Nov 24, 2014

    @wojons
    ContributorAuthor

    @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.

  9. RubenKelevra commented on Aug 19, 2015

    @RubenKelevra

    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 :)

  10. danielmewes commented on Aug 24, 2015

    @danielmewes
    Member

    @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.

  11. RubenKelevra commented on Aug 24, 2015

    @RubenKelevra

    Nice! 👍

  12. thelinuxlich commented on Mar 26, 2018

    @thelinuxlich

    @srh shouldn't this be closed in favor of write hooks?

  13. modified the milestones: backlog, invalid on Mar 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions