📝Daily

Day 21

Tony Duong

Tony Duong

Apr 13, 2026 · 2 min

Also available in:🇫🇷🇯🇵
#engineering#ddia#reading#transactions#youtube#video#concurrency#testing#distributed-systems#aws#iam-identity-center#sandbox#ai
Day 21

Today, I:

Generic Ruby/Rails RSpec snippet

# spec/models/job_concurrency_spec.rb
it "keeps both updates without lost update" do
  job = Job.create!(state: { "a" => { "status" => "pending" }, "b" => { "status" => "pending" } })
  ready = Queue.new
  go = Queue.new

  threads = %w[a b].map do |key|
    Thread.new do
      ActiveRecord::Base.connection_pool.with_connection do
        local = Job.find(job.id)
        ready << true
        go.pop
        local.update_node_status!(key, "succeeded")
      end
    end
  end

  2.times { ready.pop }
  2.times { go << true }
  threads.each(&:join) # wait for both threads to finish

  result = Job.find(job.id)
  expect(result.state.dig("a", "status")).to eq("succeeded")
  expect(result.state.dig("b", "status")).to eq("succeeded")
end
# app/models/job.rb
def update_node_status!(key, status)
  with_lock do
    data = state.deep_dup
    data[key]["status"] = status
    update!(state: data)
  end
end

AWS Innovation Sandbox on AWS (quick summary)

  • uses IAM Identity Center to let admins/managers/sandbox users access sandbox accounts with centralized authn/authz
  • serves the web ui through CloudFront + S3, with API traffic protected by WAF and routed via API Gateway
  • executes workflow logic with Lambda, EventBridge, and Step Functions for account lifecycle and automation
  • stores state/config in DynamoDB and AppConfig, with a clear separation between control plane and managed sandbox accounts

AWS Innovation Sandbox architecture

Tony Duong

By Tony Duong

A digital diary. Thoughts, experiences, and reflections.