Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 799729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:10:37+00:00 2026-05-14T23:10:37+00:00

What happens when you create nested dosync calls? Will sub-transactions be completed in the

  • 0

What happens when you create nested dosync calls? Will sub-transactions be completed in the parent scope? Are these sub-transactions reversible if the parent transaction fails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:10:38+00:00Added an answer on May 14, 2026 at 11:10 pm

    If you mean syntactic nesting, then the answer is it depends on whether the inner dosync will run on the same thread as the outer one.

    In Clojure, whenever a dosync block is entered, a new transaction is started if one hasn’t been running already on this thread. This means that while execution stays on a single thread, inner transactions can be said to be subsumed by outer transactions; however if a dosync occupies a position syntactically nested within another dosync, but happens to be launched on a new thread, it will have a new transaction to itself.

    An example which (hopefully) illustrates what happens:

    user> (def r (ref 0))
    #'user/r
    user> (dosync (future (dosync (Thread/sleep 50) (println :foo) (alter r inc)))
                  (println :bar)
                  (alter r inc))
    :bar
    :foo
    :foo
    1
    user> @r
    2
    

    The “inner” transaction retries after printing :foo; the “outer” transaction never needs to restart. (Note that after this happens, r‘s history chain is grown, so if the “large” dosync form were evaluated for a second time, the inner dosync would not retry. It still wouldn’t be merged into the outer one, of course.)

    Incidentally, Mark Volkmann has written a fantastic article on Clojure’s Software Transactional Memory; it’s highly recommended reading for anyone interested in gaining solid insight into details of this sort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've installed Awesome Nested Set, but something weird happens when I try to create
I want to know what happens when I create an instance of a ServiceHost
This is just a quick question to understand correctly what happens when you create
What happens to dangling threads in Java? Like if I create an application and
i.e. if I create a VARCHAR(50) field, what happens if I try to assign
Background / Goal More or less, I'm trying to create a nested group of
When deploying or starting websphere aplication server this happens : Failed to create temporary
Given three models that are each nested in each other. If I create the
I was trying to figure out what happens when you create an Object but
I am putting an XSL together than will create a NAnt build script using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.