8 Replies Latest reply on Nov 21, 2012 7:13 AM by hakansu

    Is AsyncStore a reliable way to save data?

      I ran into a problem that if first try to save the data didn't succeed, then the data is lost - there will be no retry to save it once again.

      Am I right? Is there any way to push that (unsaved) objects back to persistent store upon request later?

       

      Use case:

      1. Create async store over JdbcStringBasedCacheStore
      2. Shut down the database
      3. Try to save something
      4. Save operation fails (of course)
      5. Save queue gets lost on next object put into async save!

       

       

      Code snippets from 4.0.0.1.CR3 from AsyncStore to illustrate this:

      4:

             try {

                  AsyncStore.this.applyModificationsSync(mods);

               } catch (Exception e) {

                  if (log.isWarnEnabled()) log.warn("Failed to process async modifications", e);

                  if (log.isDebugEnabled()) log.debug("Exception: ", e);

               }

      5:

      void run0() throws InterruptedException {

               if (trace) log.trace("Checking for modifications");

               boolean unlock = false;

               try {

                  acquireLock(write);

                  unlock = true;

                  swap = state;          // here we loose previously unsaved objects!!

                  state = newStateMap();

               } finally {

                  if (unlock) write.unlock();

               }

       

      Even more, this cannot be changed easily: even if createAsyncProcessor() is protected, it's not possible to provide another (reliable) implementation because 'state' field is private.