Thank you very much for your advice!
1. A_db, db_A, yes they are the same thing.
2. Index property for the view - Refresh: Auto, after first use, Discard: if inactive for 45 days, and restrict initial index build was unchecked.
3. I'm not familiar with indexer task...
4. The agent might be executed in DatabaseA - I will specify the db, instead of db=session.CurrentDatabase just to eliminate this possibility.
5. I believe doc is pointing to the proper document since it returned the correct values always.
One thing I noticed today is, the docs with problems have $ConflictAction = "1". Could it cause the issue?
I will re-write the code as you recommended. If you or anyone can advise me about $ConflictAction field, I would appreciate a lot!
Thank you very much again!