Thanks for clarifying this Thomas, Obviously automatic re-run of the complete transaction is not possible. Automatic re-run of the first statement of a transaction (instead of throwing exception) should be possible however - and that would help a lot in practice in some use cases. But I do realize that this is a bit of a marginal feature.
Keep up great work! Best Regards, Joonas perjantai 2. lokakuuta 2015 9.51.03 UTC+3 Thomas Mueller kirjoitti: > > Hi, > > I guess this could be improved, but it might be complicated; I didn't try > and don't plan to try. > > The "automatic mixed mode" has some limits. It is not possible to > automatically re-run the complete transaction (multiple statements) because > the statements could depend on each other. The most logical way for an > application is to use a loop like this (pseudo-code, with connection pool): > > repeat maxRetries > c = getConnection > c.execute "..." > c.execute "..." > c.commit > finally > c.close > > Regards, > Thomas > > > On Mon, Sep 28, 2015 at 10:08 AM, Joonas Pulakka <[email protected] > <javascript:>> wrote: > >> To elaborete, >> >> I do realize that if the first (server) process shuts down *during* >> incomplete transaction, then obviously that has to trigger an exception in >> the client because the transaction could not be completed, and even if a >> server would be re-started at that point, it would be probably difficult to >> guarantee ACID properties of the transaction. >> >> But I don't understand why there is an exception even if the transaction >> is started way *after* the first (server) process has shut down - >> couldn't the client just start a server in that case? Is this just a corner >> case that happens to be handled the way it is handled currently, or is >> there a specific reason why is has to be handled that way? >> >> Best Regards, >> Joonas >> >> >> perjantai 25. syyskuuta 2015 13.37.15 UTC+3 Joonas Pulakka kirjoitti: >>> >>> From http://h2database.com/html/features.html#auto_mixed_mode and >>> http://h2database.com/html/features.html#auto_reconnect : >>> >>> - (Mixed mode) When the first connection is closed, the server >>> stops. If other (remote) connections are still open, one of them will >>> then >>> start a server (auto-reconnect is enabled automatically). >>> - The auto-reconnect feature causes the JDBC driver to reconnect to >>> the database if the connection is lost. The automatic re-connect only >>> occurs when auto-commit is enabled; if auto-commit is disabled, an >>> exception is thrown. >>> >>> So this means that when mixed mode is used with auto-commits disabled, >>> and the first (server) process shuts down, then the second (client) process >>> throws an exception when processing the next statement, instead of >>> re-connecting to the DB. Furthermore (result of experimentation) it >>> *does* reconnect to the DB just by retrying the statement that threw >>> the exception. After that everything works fine again. Only the first >>> statement that's issued after the server died, receives Connection is >>> broken: "session closed" [90067-185];; Error code: 90067. >>> >>> >>> Question: what's the point of *automatic re-connect only occurs when >>> auto-commit is enabled; if auto-commit is disabled, an exception is >>> thrown*? >>> Does this mean that if I want to use mixed mode with auto-commits disabled, >>> I have to make all my transactions to check for "session closed" exception >>> and retry in that case? Is there a better way? >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "H2 Database" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/h2-database. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
