[ 
https://issues.apache.org/jira/browse/ARTEMIS-5379?focusedWorklogId=964724&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-964724
 ]

ASF GitHub Bot logged work on ARTEMIS-5379:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Apr/25 16:56
            Start Date: 03/Apr/25 16:56
    Worklog Time Spent: 10m 
      Work Description: gtully commented on code in PR #5595:
URL: https://github.com/apache/activemq-artemis/pull/5595#discussion_r2027413792


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/transaction/impl/TransactionImpl.java:
##########
@@ -340,16 +346,98 @@ public void done() {
       }
    }
 
-   protected void doCommit() throws Exception {
-      if (containsPersistent || xid != null && state == State.PREPARED) {
-         // ^^ These are the scenarios where we require a storage.commit
-         // for anything else we won't use the journal
+
+   // This runnable will call the parentContext
+   abstract class DelayedRunnable implements Runnable {
+
+      OperationContext parentContext;
+      OperationContext delayedContext;
+      long id;
+
+      DelayedRunnable(long id) {
+         parentContext = storageManager.getContext();
+         parentContext.storeLineUp();
+         delayedContext = storageManager.newSingleThreadContext();
+         this.id = id;
+      }
+
+      protected abstract void actualRun() throws Exception;
+
+
+      @Override
+      public void run() {
+         OperationContext oldContext = storageManager.getContext();
+         try {
+            storageManager.setContext(delayedContext);
+            actualRun();
+            delayedContext.executeOnCompletion(new IOCallback() {
+               @Override
+               public void done() {
+                  parentContext.done();
+               }
+
+               @Override
+               public void onError(int errorCode, String errorMessage) {
+                  parentContext.onError(errorCode, errorMessage);

Review Comment:
   should old context get an onError callback here too, or when would there be 
a parent and an old and a delayed context, ie: 3?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 964724)
    Time Spent: 0.5h  (was: 20m)

> Journal commit record recorded before Page Writer is finished leading to 
> possible message loss on a crash
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-5379
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5379
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Clebert Suconic
>            Priority: Blocker
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Due to ARTEMIS-5305, the journal commit record could reach the journal before 
> the page writes. 
> The clients were always waiting correctly for the entire portion of the data 
> being stored. However if an uncertainty happened (the failure happened before 
> the page write was finished) you could have a situation where part of the TX 
> is recorded and part is not.
> That could lead to DUPLICATE Cache stored and not the data.
> Or other portion of the TX stored but not the send.
> The fix is to defer the write of the journal record until the page write 
> operation is finished.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to