These are chat archives for akkadotnet/akka.net

3rd
Nov 2015
Yin Zhang
@melcloud
Nov 03 2015 01:57 UTC
Hi guys. I am revisiting the akka design pattern course. Can any explain to me why the way IdentityWriterActor uses CanProceed is a very weak manner?
Aaron Stannard
@Aaronontheweb
Nov 03 2015 03:17 UTC
@melcloud
Whoops - typing on mobile
Yin Zhang
@melcloud
Nov 03 2015 03:18 UTC
:smile:
Aaron Stannard
@Aaronontheweb
Nov 03 2015 03:18 UTC
That code is naive on purpose
It's just to illustrate a way to implement some sort of consensus model using messages
Yin Zhang
@melcloud
Nov 03 2015 03:22 UTC
I see.
Aaron Stannard
@Aaronontheweb
Nov 03 2015 03:25 UTC
It's good enough for non distributed contexts if you add some metadata
Yin Zhang
@melcloud
Nov 03 2015 03:30 UTC
So if I have a AtLeastOnceDeliveryActor, should I use this to do idempotent check?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 06:23 UTC
@Zetanova which part is supposed to take 30min? Only sending the state back or the whole process?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 06:29 UTC
Maybe this is obious, but basically each actor playing in the saga is supposed to persist all incoming events.
I don't see, where TaskScheduler should be used.
Hussein Ait-Lahcen
@hussein-aitlahcen
Nov 03 2015 07:40 UTC
@Horusiath What is the best way to delay the delivery of a message ? ScheduleTellOnce ? I have two actors A and B, a tells B to update, B send back it state, A compute the next time it should update and delay the update message in order to have a constant intervall between updates
cyril andreichuk
@andreichuk
Nov 03 2015 08:00 UTC
hi. is there any way to set actor's dispatcher? i was not able to do so using HOCON config (i do not use deployment), nor by code (because of the exception i posted here last night). any help?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 08:08 UTC
@hussein-aitlahcen you could just schedule interval for updates directly in actor B, and let actor A subscribe to actor B for updates. This way when scheduled tick occurs, B updates it's state and send it to all subscribers
but remember that schedulers have limited resolution, as they work in intervals themselfs (by default it's around 10ms)
@andreichuk my guess is that string, you've provided in dispatcher is invalid, but maybe it's a bug. Could you write an issue on github and describe your case?
cyril andreichuk
@andreichuk
Nov 03 2015 08:16 UTC
maybe. could you please provide me with an full example of dispatcher configuration?
there are some examples in the docs but they are not full so it's not clear where exactly put dispatcher configuration there
Hussein Ait-Lahcen
@hussein-aitlahcen
Nov 03 2015 08:49 UTC
@Horusiath Assuming my actor need to be update 60 times per second, can i predict the Scheduler interval (will not be accurate of course) by deducting the 10 ms ?
This is a critical point of my system
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 09:18 UTC
I know that you can configure the interval, but I'm not sure, how will it behave in intervals lower than 10ms. I don't think, it was designed for high time sensitivity, but for 60 frames/sec it should be sufficient. However if I were you, I would check if it fits your needs
Hussein Ait-Lahcen
@hussein-aitlahcen
Nov 03 2015 09:22 UTC
So you think that i should do that outside the actor system
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 09:22 UTC
no, I think that you should measure first ;)
don't be driven by the belief. If you won't measure and stay with built-in scheduler, it may give you some performance problems later. But if it turns out it's sufficient, but you've moved this part outside an actor system, then you may end with unnecessarily complicated solution
cyril andreichuk
@andreichuk
Nov 03 2015 09:45 UTC
after downloading and debugging the sources i fixed my issue by providing a full path of the dispatcher. like this:
.WithDispatcher("akka.dedicated-dispatcher")
Zetanova
@Zetanova
Nov 03 2015 11:10 UTC
@Horusiath the process to download the data can take 30min, its an import from the external system. Because this process relays on the read-model for index lookup, maybe should it just be outside? the AR have near the same ImportCommand. It just query the external service for the data and generates a Created+Updated Event. On CreateCommand the AR is creating the external account first and generates the Created Event.
Zetanova
@Zetanova
Nov 03 2015 12:31 UTC
I moved the process from outside to an actor-process so it can run to the end when the client disconnects and i got a error that the actor "akka.persistence.snapshot-store.sql-server" is not unique!" Its still coming
some race conditions
when i push messages to the AR
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 12:43 UTC
@Zetanova yes, it's a bug. Could you create an issue for that?
Zetanova
@Zetanova
Nov 03 2015 12:47 UTC
just looking in to it
how to force the creation of the snapshot extension?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 12:52 UTC
create persistent actor with snapshot store configured, and initialize it by sending a message
Zetanova
@Zetanova
Nov 03 2015 12:52 UTC
Its something related to a Lazy<Extension> that will becreated twice in race condition
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 12:53 UTC
yes
in scala it was solved as each snapshot store is initialized as akka extension (extensions registration is thread safe) using anonymous classes initialization... but C# haven't got anonymous classes
nonetheless it can be solved quite easily, I've just forgot to think about that
Zetanova
@Zetanova
Nov 03 2015 13:09 UTC
yes i wrote it
Lazy<>(...,true)
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 13:10 UTC
thank you good man
Zetanova
@Zetanova
Nov 03 2015 13:12 UTC
as long as the extension initializion process dont call the same method where the Lazy helper is created and query itself, all will be good.
Thomas Lazar
@thomaslazar
Nov 03 2015 13:38 UTC
is there a way to find out from an IActorRef what the type of the actual underlying actor is?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 13:40 UTC
@thomaslazar nope, there is no correlation there
Thomas Lazar
@thomaslazar
Nov 03 2015 13:42 UTC
ok. other question. can i somehow convert a IActorRef into a TestActorRef?
i have an actor i want to test. i send it a message and get an IActorRef in return and i just want to make sure that it's actually the actor i want.
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 13:45 UTC
you could do this for LocalActorRef but first think, if YAGNI
Thomas Lazar
@thomaslazar
Nov 03 2015 13:50 UTC
well my situation is this. i have an actor A that creates 2 child actors B and C, both are doing stuff with resources. A has messages E/F that are used to return an IActorRef of B or C so code can work with the underlying resources. if certain stuff happens A tells B and C to shut down and when nobody is using them anymore they kill themselves. A creates a new B and C that get handed off to new caller asking message E/F. i just want to test sending message E and F if i get their corresponding B and C types back.
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 13:56 UTC
it sounds, like you're trying to test implementation (type of an actor) instead of behavior (what actor does). You could just invoke the test scenario. It's like duck typing - if actor behaves like B, it means it's B. If not and it behaves like C, it means, you've invoked C
Thomas Lazar
@thomaslazar
Nov 03 2015 13:58 UTC
yeah... but that would make a simple "check if type is B" into "send actorref messages and see if it is actually the actor i wanted", which would be much more code.
Zetanova
@Zetanova
Nov 03 2015 17:32 UTC
Akka.Persistence.Journal.AsyncWriteJournal.HandleWriteMessages(Akka.Persistence.WriteMessages message )
"New transaction is not allowed because there are other threads running in the session."
Zetanova
@Zetanova
Nov 03 2015 17:44 UTC
@Horusiath If a command handler is Persiting two events and the Event Handler fails on the first event. On Recover of the AR will both events come in the same order? (Created+Updated)
Zetanova
@Zetanova
Nov 03 2015 17:52 UTC
Somehow the create event is lost
Zetanova
@Zetanova
Nov 03 2015 17:58 UTC
If the message handler of Akka.Persistence.Eventsourced.AroundReceive failes, then it is generating an infinit loop without calling OnReplayFailure()
Cleared the Journal and now i am getting NullRefException In Akka.Persistence.Sql.Common.Journal.JournalDbEngine
at System.Collections.Generic.LinkedList1.Find(T value) at System.Collections.Generic.LinkedList1.Remove(T value)
at Akka.Persistence.Sql.Common.Journal.JournalDbEngine.<>cDisplayClass1.<ReplayMessagesAsync>b0(Task1 task) at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
;(
Zetanova
@Zetanova
Nov 03 2015 18:06 UTC
How to download the Debug Files (*.pdb) for the Dev builed. I added https://nuget.symbolsource.org/MyGet/akkadotnet to the Source Urls but VS cant find them there
Zetanova
@Zetanova
Nov 03 2015 18:17 UTC
PendingOperations the LinkedList.Remove() is not thread safe
Need to get my Dev-fork up
Chris G. Stevens
@cgstevens
Nov 03 2015 18:39 UTC
Quick Question: It does look like this is happening but want to validate. I am seeing, based on the messages, that when my member joins it is set to the Leader for that role before I get the message that it is actually up. Is this how it is actually happening or I am just getting that message first. In fact I am getting the message that the member is up 3-6 seconds after I was told that it is the leader for that role.... if it is happening this way why is it being promoted to leader when it isn't considered up.
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 19:14 UTC
@Zetanova concerning transactions errors - they should be fixed by #1306
I'll start to fix the rest of the errors you've found today
Zetanova
@Zetanova
Nov 03 2015 19:24 UTC
@Horusiath thx, is there a Lock Free LinkedList in Akka or similar?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 19:28 UTC
thx, but let me see, maybe it won't be necessary, if it won't be possible to make whole operation working on synchronous inside an actor, we still have an arsenal of atomic/immutable options inside akka itself
Zetanova
@Zetanova
Nov 03 2015 19:41 UTC
LinkList and Set is fine in an actor, but if some concurrent is using them, there can be hiden bugs. 10M operations can be successfull 10M+1 is failing once in a week. LockFree Queue and LinkedList are nice because it can be a proteced property of a base class. Immutable Lists need still the lock or spin-lock to copy the list, like ConcurrentBag<T>
Christian Duhard
@cduhard
Nov 03 2015 19:59 UTC
hmm this Terminated code doesn't seem to work
it's failing on _pendingCommands = groups.First(x => !x.Key).ToList();
Zetanova
@Zetanova
Nov 03 2015 20:02 UTC
yes
@cduhard fast fix
var commands = new List<PendingCommand>(_pendingCommands.Count - i);
commands.AddRange(_pendingCommands.Where(cmd => cmd.PersistenceId != pid));
_pendingCommands = commands;
Christian Duhard
@cduhard
Nov 03 2015 20:05 UTC
so i ma replacing all 3 lines with that
where does I come from?
Zetanova
@Zetanova
Nov 03 2015 20:07 UTC
found commands
i++ in the loop
_pendingCommands.Where(cmd => cmd.PersistenceId == pid)
Christian Duhard
@cduhard
Nov 03 2015 20:08 UTC
i'm missing something
Zetanova
@Zetanova
Nov 03 2015 20:08 UTC
remove this toList and stuff
Christian Duhard
@cduhard
Nov 03 2015 20:08 UTC
the current code is
            var groups =
                _pendingCommands.GroupBy(cmd => cmd.PersistenceId == terminated.ActorRef.Path.Name).ToArray();
            _pendingCommands = groups.First(x => !x.Key).ToList();
            var commands = groups.First(x => x.Key);
            foreach (var pendingCommand in commands)
            {
                var child = Recreate(pendingCommand.AggregateId, pendingCommand.PersistenceId);
                child.Tell(pendingCommand.Command, pendingCommand.Sender);
            }
Zetanova
@Zetanova
Nov 03 2015 20:11 UTC
var pid = terminated.ActorRef.Path.Name;
int i = 0;
foreach (var pendingCommand in _pendingCommands.Where(cmd => cmd.PersistenceId == pid))

{

    var child = Recreate(pendingCommand.AggregateId, pendingCommand.PersistenceId);

    child.Tell(pendingCommand.Command, pendingCommand.Sender);
    i++;       
}

var commands = new List<PendingCommand>(_pendingCommands.Count - i);
commands.AddRange(_pendingCommands.Where(cmd => cmd.PersistenceId != pid));
_pendingCommands = commands;
Christian Duhard
@cduhard
Nov 03 2015 20:13 UTC
got it, thanks. I'll give this a try.
@Zetanova what are you using for storage?
Zetanova
@Zetanova
Nov 03 2015 20:16 UTC
sql-server for now. but the storage type should be picked by the AR-type
Christian Duhard
@cduhard
Nov 03 2015 20:17 UTC
how do you mean?
Zetanova
@Zetanova
Nov 03 2015 20:17 UTC
file, document-store, sql are all valid
Christian Duhard
@cduhard
Nov 03 2015 20:17 UTC
i was going to give EventStore a try
Zetanova
@Zetanova
Nov 03 2015 20:18 UTC
File => for very large AR's maybe explicit on a partition/drive SSD
DocumentStore => normal for AR's
sql => maybe faster for some kind of operations (need to test later on)
Christian Duhard
@cduhard
Nov 03 2015 20:19 UTC
weird getting dead letters now
Zetanova
@Zetanova
Nov 03 2015 20:34 UTC
In a local akka.net buget build where to set the BUILD_NUMBER of a package? Want to patch the Akka.Persistence.Sql.Common so that the SqlServer is dont updating it on install
Zetanova
@Zetanova
Nov 03 2015 20:40 UTC
RELEASE_NOTES.md file.
Christian Duhard
@cduhard
Nov 03 2015 20:54 UTC
wonder why EventStore ain't got no love for a Akka.Persistence
Yin Zhang
@melcloud
Nov 03 2015 20:58 UTC
Dear all,
just wondering if it is safe to use PersistView?
My idea is to have an actor which persist events such as quoteCreated. Then once another service is online, a persistView actor is created and do at least once delivery to that service
Zetanova
@Zetanova
Nov 03 2015 21:39 UTC
@Horusiath You already change in Akka.Persistence.Sql.Common the DbConnection to short use pattern?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 21:40 UTC
@rogeralsing I think, we still have some problems concerning stashing and message duplicates - we changed custom equality to reference equality to detect duplicates inside the stash, but actually sometimes we may want to store the same message twice (like in the case of singleton messages or strings)
@Zetanova what do you mean?
Zetanova
@Zetanova
Nov 03 2015 21:43 UTC
@Horusiath currently in JournalDbEngine and DbSnapshotStore the dbconnection is a singleton but executes concurrent sqlCommands on it (at least it is trying to do). the dbConnection should be create for each execution and disposed after. It is backed by the sql-connection-pool
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 21:44 UTC
this part is covered by #1306 - it will use new connection for each operation
Zetanova
@Zetanova
Nov 03 2015 21:45 UTC
its not realy using a new connection, its peeking one from the sql-connection-pool
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 21:45 UTC
yes, I know ;)
Aaron Stannard
@Aaronontheweb
Nov 03 2015 21:45 UTC
@stefansedich working on upgrading the version of Mono on our build agents
since the DNS system still barfs up those DNS assertions whenever I use NuGet.exe
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 21:46 UTC
when I said new connection, I meant new instance of DbConnection
Aaron Stannard
@Aaronontheweb
Nov 03 2015 21:46 UTC
switching to the alpha channel I think
Zetanova
@Zetanova
Nov 03 2015 21:54 UTC
@Horusiath the SnapshotStore is implemented as an actor and can use the singleton dbconnection and LinkList. Why not implement JournalDbEngine like this too? And maybe both .WithRouter()
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:11 UTC
@Zetanova SnapshotStore now will use dbconnection per request to. Also I'm concerned, that routers will affect reliability of message ordering
Zetanova
@Zetanova
Nov 03 2015 22:13 UTC
@Horusiath even with this Hash-Router?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:13 UTC
and since we already use async ADO.NET API for database communication I'm not so sure if spawning more journals/snapshot stores will be much help - but this could be measured
Zetanova
@Zetanova
Nov 03 2015 22:18 UTC
I am not so sure that if the JournalEntires are processed in parallel, that they will be on disk in serial, most likly overlapped with the SeqNr.
of course in sql u can sort by SeqNr. on a FileStorage its maybe a bug
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:19 UTC
seqnr is generated by persistent actor itself
Zetanova
@Zetanova
Nov 03 2015 22:19 UTC
yes but not saved
the JournalEntries are processed in batch
if one batch gets SeqNr 1-10 and the second batch 11-20
then it will land on disk most likly overlapped
1,2,3,4,5,6,11,7,8,12,8,13,14,9,15,10,16,17,18,19,20
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:22 UTC
AFAIK we use file storage only for snapshots right now - and it's highly not recommended to use it for anything else than tests
Zetanova
@Zetanova
Nov 03 2015 22:24 UTC
and what are EventStorageEngines are doing with this seq. ?
ordering in memory and saving them or replying them 1:1 later?
Aaron Stannard
@Aaronontheweb
Nov 03 2015 22:25 UTC
@stefansedich nope, we're still screwed: https://bugzilla.xamarin.com/show_bug.cgi?id=35509
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:26 UTC
sequenceNr is necessary to ordering events in scope of the persistent id used
Zetanova
@Zetanova
Nov 03 2015 22:27 UTC
i dont not see your new code, but the current one from JournalDbEngine will overlap the batches
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:27 UTC
basically it's increased monotonically by the persistent actor (therefore there can be only 1 instance of it per persistent id at the moment) and saved with event. Once persistent actors recovers, the highest seqNr is retrieved from the journal before continuing any work
Aaron Stannard
@Aaronontheweb
Nov 03 2015 22:27 UTC
working on compiling Mono from scratch now to see if that fixes it #yolo
Zetanova
@Zetanova
Nov 03 2015 22:28 UTC
Is JournalDbEngine created for each PersistentActor?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:29 UTC
This message was deleted
my bad, it's created once for whole journal
Zetanova
@Zetanova
Nov 03 2015 22:30 UTC
yes
and even if
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:30 UTC
with regard, that there's only one journal for each persistent backend
Zetanova
@Zetanova
Nov 03 2015 22:31 UTC
if the PersistentActor is calling WriteMessages() with the first batch
sec
and who is calling WriteMessages() ?
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:33 UTC
journal itself
Zetanova
@Zetanova
Nov 03 2015 22:33 UTC
parallel, most likly because i get this race conditions
it is fine until the batch of one PersitentActor are executed in parallel
and there should be a check in the Recovery Processdur
when the SeqNr > SnapshotNr+1 then RecoveryFailure
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:39 UTC
sorry, but I'm programming from like 15 hours now, but I seem to missed SnapshotNr somewhere in our discussion ;)
Zetanova
@Zetanova
Nov 03 2015 22:39 UTC
I am allready missing Event-1 of an AR and get insatnly Event-2
SeqNr of the Snapshot
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:40 UTC
snapshot uses the same sequencer as journal, but it doesn't increment it
Zetanova
@Zetanova
Nov 03 2015 22:40 UTC
If one Journal Event is missing in the recovery it should Fail
because of this bug, i have this state, not the AR is getting the second Event on recovery and missing the first one.
State of the AR can be then unlear and dangures
yes , i the same
did my TAX decalaration today at night
last minute
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 22:45 UTC
to make some quick summary: you've encountered moment, when you had sql journal storing in parallel events a-1 and a-2, but for some reason a-2 has been stored, while a-1 not, right?
Zetanova
@Zetanova
Nov 03 2015 22:45 UTC
yes, because of the bug
it was now 4times
i am testing with 200 AR's
each gets a command and is persisting two events
(Created+Updated)
Zetanova
@Zetanova
Nov 03 2015 22:51 UTC
I removed now the locks from the DBSnapotStore and getting again the Error at PendingOperations.Remove(tokenSource);
in the LoadAsync method
wahahahah
PipeTo is not waiting to complition
This message was deleted
Zetanova
@Zetanova
Nov 03 2015 22:57 UTC
=> Concurrent execution in the Snapshot Actor
LoadAsync() => sawns a new thread (or takes one from the pool)
PipeTo is just execution on the same new thread and the end
if 10 messages are comming
then there will be lots of simultan executoon inside the actor
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 23:00 UTC
in case of snapshot actor this shouldn't be a problem
Zetanova
@Zetanova
Nov 03 2015 23:00 UTC
if this execution has some side effect, it is most likly a race condition
sure it is
if an PA is taking two snapshots
at the same time
it is allready possible that the first is saved after the second
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 23:02 UTC
if you have events: a-1, a-2, a-3, a-4 and snapshots at the moment of a-1 and a-3, for the sake of consistency it doesn't matter which snapshot will it receive
if it will receive snapshot a-1, it will startup at point of a-1 and recover from events a-2 to the end of the stream
if it will receive snapshot a-3 it will use only event a-4 and above to recover
Zetanova
@Zetanova
Nov 03 2015 23:05 UTC
thats clear in the Snapshot store
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 23:05 UTC
or you are using words snapshots and events interchangeably
Zetanova
@Zetanova
Nov 03 2015 23:06 UTC
I removed the lock i insered on PendingOperations
because i thought it is not required
but its in parallel execution because of this PipeTo
Bartosz Sypytkowski
@Horusiath
Nov 03 2015 23:09 UTC
but if you're talking about event batches, this also shouldn't happen, as persistent actor won't emit second batch of messages to the journal until it receives confirmation about successfully stored first one
Zetanova
@Zetanova
Nov 03 2015 23:10 UTC
then its fine
Horusiath @Horusiath enough for today, time to sleep
Zetanova
@Zetanova
Nov 03 2015 23:13 UTC
gn8