 
         return new_val
 
-    # If we get a fatal error, then we wait a bit.  This could happen due to being signed out,
-    # or thinking we're signed in, but not being signed in (since we *just* are in the process of
-    # being signed out).  It's rare, but there are dozens of tables, so even a 1% chance can
-    # easily happen.
-    _set_fatal: (why) =>
-        if @_fatal
-            return
-        tm = 10000 + Math.random()*20000
-        #console.log("_set_fatal", @_query, tm, why)
-        @_fatal = true
-        @_fatal_interval = setTimeout(@_unset_fatal, tm)
-
-    _unset_fatal: =>
-        #console.log("_unset_fatal", @_query)
-        delete @_fatal
-        delete @_fatal_interval
-
     close: =>
-        if @_fatal_interval
-            clearTimeout(@_fatal_interval)
-            delete @_fatal_interval
         if @_state == 'closed'
             # already closed
             return

        else
            @__is_saving = true
            @__save (err) =>
                @__is_saving = false
                if is_fatal(err)
                    @_set_fatal(err)
                cb?(err)

    __save: (cb) =>
        if @_state == 'closed'
            cb?("closed")
            return
        if @_fatal
            cb?()
            return
        # console.log("_save('#{@_table}')")
        # Determine which records have changed and what their new values are.


{defaults, required} = misc

cb_fatal = (err, cb) ->
    if not cb?
        return
    if typeof(err) == 'string' and err.slice(0,5) == 'FATAL'
        # throw in an arbitrary pause to wait for proper connection or
        # give the backend time to breath
        setTimeout((->cb(err)), 5000 + Math.random()*5000)
    else
        # cb as usual
        cb(err)

# We represent synchronized tables by an immutable.js mapping from the primary
# key to the object.  Since PostgresQL primary keys can be compound (more than
