MWAA Airflow "Executor reports task instance <TaskInstance: ... [queued]> finished (success) although the task says its queued." Causing task failure - airflow

Running AWS Airflow Managed (2.2.2) service with Celery, multiple schedulers, and noticing a lot of tasks that use Sensors (time-based reschedule sensors) seem be marked as failed even though some of them continue to run until completion.
The Sensor Operator is fairly simple API-checker that polls API every 5 min until it receives a certain response.
We have an on_failure_handler written which captures all of these as they happen and sends slack notification.
Generally seeing the following sequence of logs in CloudWatch (no worker logs for some reason available):
{
"#timestamp": "2023-01-19 10:57:39.371",
"#message": "[\u001b[34m2023-01-19 10:57:38,924\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m563}} INFO\u001b[0m - TaskInstance Finished: dag_id=custom_dag, task_id=task_xyz, run_id=run_123, run_start_date=2023-01-19 10:50:17.473702+00:00, run_end_date=2023-01-19 10:57:31.030716+00:00, run_duration=433.557014, state=failed, executor_state=success, try_number=1, max_tries=0, job_id=5942262, pool=default_pool, queue=airflow-celery-f742a6b6-c8cc-4a29-81a0-eb81cc44e889, priority_weight=7, operator=CustomSensorOperator\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:39.122",
"#message": "[\u001b[34m2023-01-19 10:57:38,863\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m510}} INFO\u001b[0m - Executor reports execution of custom_dag.task_xyz run_id=run_123 exited with status success for try_number 1\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:32.718",
"#message": "[2023-01-19 10:57:32,718] {{taskinstance.py:1029}} INFO - Dependencies not met for <TaskInstance: custom_dag.task_xyz run_123 [failed]>, dependency 'Task Instance State' FAILED: Task is in the 'failed' state which is not a valid state for execution. The task must be cleared in order to be run.",
"#logStream": "custom_dag/task_xyz/2023-01-19T07_41_27+00_00/1.log"
},
{
# THIS CAUSES TASK INSTANCE TO FAIL EVEN THROUGH ITS STILL RUNNING
"#timestamp": "2023-01-19 10:57:31.730",
"#message": "[\u001b[34m2023-01-19 10:57:30,661\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m572}} ERROR\u001b[0m - Executor reports task instance <TaskInstance: custom_dag.task_xyz run_123 [queued]> finished (success) although the task says its queued. (Info: None) Was the task killed externally?\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-3-8.ec2.internal_1674030934.1519198.log"
},
{
"#timestamp": "2023-01-19 10:57:31.719",
"#message": "[\u001b[34m2023-01-19 10:57:30,661\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m563}} INFO\u001b[0m - TaskInstance Finished: dag_id=custom_dag, task_id=task_xyz, run_id=run_123, run_start_date=2023-01-19 10:50:17.473702+00:00, run_end_date=2023-01-19 10:50:18.224642+00:00, run_duration=0.75094, state=queued, executor_state=success, try_number=1, max_tries=0, job_id=5942262, pool=default_pool, queue=airflow-celery-f742a6b6-c8cc-4a29-81a0-eb81cc44e889, priority_weight=7, operator=CustomSensorOperator\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-3-8.ec2.internal_1674030934.1519198.log"
},
{
"#timestamp": "2023-01-19 10:57:30.740",
"#message": "[\u001b[34m2023-01-19 10:57:30,580\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m510}} INFO\u001b[0m - Executor reports execution of custom_dag.task_xyz run_id=run_123 exited with status success for try_number 1\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-3-8.ec2.internal_1674030934.1519198.log"
},
{
"#timestamp": "2023-01-19 10:57:27.854",
"#message": "[\u001b[34m2023-01-19 10:57:27,612\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m538}} INFO\u001b[0m - Setting external_id for <TaskInstance: custom_dag.task_xyz run_123 [queued]> to c244ff79-0e92-4c3d-8c89-0440af154848\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:27.544",
"#message": "[\u001b[34m2023-01-19 10:57:27,465\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m510}} INFO\u001b[0m - Executor reports execution of custom_dag.task_xyz run_id=run_123 exited with status queued for try_number 1\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
# THIS IS THE SUSPECIOUS SETTING OF THE TASK TO STATE SUCCESS
"#timestamp": "2023-01-19 10:57:26.361",
"#message": "\t<TaskInstance: custom_dag.task_xyz run_123 [queued]> in state SUCCESS\n",
"#logStream": "scheduler_console_ip-10-1-3-8.ec2.internal_1674030934.1519198.log"
},
{
"#timestamp": "2023-01-19 10:57:26.054",
"#message": "[\u001b[34m2023-01-19 10:57:25,349\u001b[0m] {{\u001b[34mbase_executor.py:\u001b[0m82}} INFO\u001b[0m - Adding to queue: ['airflow', 'tasks', 'run', 'custom_dag', 'task_xyz', 'run_123', '--local', '--subdir', 'DAGS_FOLDER/custom_dag.py']\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:26.042",
"#message": "[\u001b[34m2023-01-19 10:57:25,349\u001b[0m] {{\u001b[34mscheduler_job.py:\u001b[0m450}} INFO\u001b[0m - Sending TaskInstanceKey(dag_id='custom_dag', task_id='task_xyz', run_id='run_123', try_number=1) to executor with priority 7 and queue airflow-celery-f742a6b6-c8cc-4a29-81a0-eb81cc44e889\u001b[0m\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:25.796",
"#message": "\t<TaskInstance: custom_dag.task_xyz run_123 [scheduled]>\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
{
"#timestamp": "2023-01-19 10:57:25.542",
"#message": "[2023-01-19 10:57:25,516: INFO/ForkPoolWorker-3] Executing command in Celery: ['airflow', 'tasks', 'run', 'custom_dag', 'task_xyz', 'run_123', '--local', '--subdir', 'DAGS_FOLDER/custom_dag.py']\n",
"#logStream": "worker_console_ip-10-1-3-191.ec2.internal_1674110783.438406.log"
},
{
"#timestamp": "2023-01-19 10:57:25.425",
"#message": "\t<TaskInstance: custom_dag.task_xyz run_123 [scheduled]>\n",
"#logStream": "scheduler_console_ip-10-1-2-43.ec2.internal_1673666911.1179407.log"
},
There are a couple of times when the task is set to error, handler triggered, but the scheduler continues to check the task instance until it actually completes successfully, but the failure state is persisted in the database.
I suspect that the one scheduler message that marks the task as [queued] in state SUCCESS is what is causing the error, but I can't identify why this is happening, or the root cause. All the tasks are manually triggered through an API and are not scheduled - so I do not think the pickling and backfill solutions proposed would help.
I am not entirely sure if this is a scheduler interval issue; but if it is, what could be causing it?
Based on the logStream it almost seems as though two different schedules are competing to set task state.
Checked logs to try and find root cause, but nothing indicative. Have not yet restarted scheduler since MWAA requires taking down all of Airflow for 20-30 min which is not ideal at the moment.

Related

Ansible: selecting dict element by extra var

I am trying to create a playbook to set up log collecting daemons. I have a dict with the parameters to set up (used in templates). Someting like this
logservers:
prod:
ipaddress: 10.10.44.79
envname: "Productive servers"
other_data: "important prod data"
test:
ipaddress: 10.20.44.79
envname: "Testing servers"
other_data: "data for testing"
dev:
ipaddress: 10.30.44.79
envname: "Developement servers"
other_data: "developers data"
Is it possible to use an extra var, like -e env=prod on running the playbook and use this tho select "prod" element from the dict when templating?
Or, what is the method to achieve this in Ansible?
And a last bit: I would need this for a fairly old dist of Ansible to work on (2.4)
there are lot of ways to do that:
one way is to use a new variable server which has the data wanted following the extra var:
- name: configure app servers
hosts: localhost
vars:
logservers:
prod:
ipaddress: 10.10.44.79
envname: "Productive servers"
other_data: "important prod data"
test:
ipaddress: 10.20.44.79
envname: "Testing servers"
other_data: "data for testing"
dev:
ipaddress: 10.30.44.79
envname: "Developement servers"
other_data: "developers data"
server: "{{ logservers[env] }}"
tasks:
- name: display "{{ env }}"
debug:
msg: "{{ server }}"
you launch the playbook:
ansible-playbook play.yml -e env=dev
result:
TASK [display "dev"] ****************************************************************
ok: [localhost] => {
"msg": {
"envname": "Developement servers",
"ipaddress": "10.30.44.79"
"other_data": "developers data"
}
}
you launch the playbook:
ansible-playbook play.yml -e env=prod
result:
TASK [display "prod"] ***************************************************************
ok: [localhost] => {
"msg": {
"envname": "Productive servers",
"ipaddress": "10.10.44.79"
"other_data": "important prod data"
}
}

flutter app with firebase crashes on hot reload

Hey all I am having some problems with flutter and firebase after receiving a new update. If i try to hot reload the app then it will just crash. Below is the code that seems to be causing the problem and I also have the result of what happens when I run flutter run --verbose. Thanks for the help.
Code that seems to be causing the problem:
import 'package:CodingLog/model/dataSettings.dart';
import 'package:CodingLog/notifier/dataSettings_notifier.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
getMainDataSettings(MainDataSettingsNotifier mainDataSettingsNotifier) async {
await Firebase.initializeApp();
QuerySnapshot snapshot = await FirebaseFirestore.instance
.collection('mainDataSettings')
.get();
List<MainDataSettings> _mainDataSettingsList = [];
snapshot.docs.forEach((document) {
MainDataSettings mainDataSettings = MainDataSettings.fromMap(document.data());
_mainDataSettingsList.add(mainDataSettings);
});
mainDataSettingsNotifier.mainDataSettingsList = _mainDataSettingsList;
print('getting data - 1');
}
Pubspec file:
dependencies:
flutter:
sdk: flutter
charts_flutter: ^0.8.1
image_picker: ^0.6.7+7
rflutter_alert: ^1.0.3
flutter_datetime_picker: ^1.3.8
date_format: ^1.0.8
flutter_swiper:
intl: ^0.16.1
flutter_statusbarcolor: ^0.2.3
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2
provider: ^4.3.2+2
uuid: ^2.2.2
This is the output of running flutter run --verbose:
[+35434 ms] Starting incremental build...
[ +2 ms] Skipping target: gen_localizations
[ +1 ms] complete
[ +2 ms] Performing hot restart...
[ +12 ms] Scanned through 511 files in 6ms
[ ] Syncing files to device iPhone 8...
[ ] Scanning asset files
[ +1 ms] <- reset
[ ] Compiling dart to kernel with 2 updated files
[ ] <- recompile package:CodingLog/main.dart 7866d41d-8028-433a-9dfd-406bda335575
[ ] package:CodingLog/screens/data.dart
[ ] package:CodingLog/screens/feed.dart
[ ] <- 7866d41d-8028-433a-9dfd-406bda335575
[ +273 ms] Updating files
[ +405 ms] DevFS: Sync finished
[ ] Syncing files to device iPhone 8... (completed in 681ms)
[ ] Synced 29.0MB.
[ ] <- accept
[ +124 ms] Hot restart performed in 814ms.
[ ] Performing hot restart... (completed in 820ms)
[ ] Restarted application in 826ms.
[ +569 ms] Service protocol connection closed.
[ +1 ms] Lost connection to device.
[ +5 ms] DevFS: Deleting filesystem on the device
(file:///Users/masonhorder/Library/Developer/CoreSimulator/Devices/BB743712-8AB1-49E7-BB29-AC39EB2DE70E/data/Containers/Data/Application/066B0BC0-5C67-4DA7-A3DE-
713CCDC32E0E/tmp/CodingLogyN4gn4/CodingLog/)
[ +260 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[ +7 ms] "flutter run" took 918,916ms.
[ +143 ms] ensureAnalyticsSent: 135ms
[ +2 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ +5 ms] Shutdown hooks complete

unrestorable checkpoint error when selection.AbstractCashSelection.unconsumedCashStatesForSpending - Coin selection failed

whenever coin selection fails, "unrestorable checkpoint" exception is thrown.
I am testing out scheduled event functionality, when an IOU is created, an event is scheduled to do payment at a specific time. from the error logs (see below), whenever coin selection fails, unrestorable checkpoint" exception is thrown, but the process continues to run, retries until coin selection is successful.
The exception stack doesn't provide info on where the error could be, how can I debug this?
#Suspendable
public List<StateAndRef<Cash.State>> getFunds(Set<AbstractParty> issuers, Amount<Currency> amt) {
try {
AbstractCashSelection db = AbstractCashSelection.Companion.getInstance( () -> {
try {
return this.serviceHub.jdbcSession().getMetaData();
}catch(Exception e) {
throw new RuntimeException("getFunds error", e);
}
});
List<StateAndRef<Cash.State>> funds = db.unconsumedCashStatesForSpending(this.serviceHub, amt, issuers, null, this.flowRunId, new HashSet<OpaqueBytes>());
funds.forEach(s -> {
states.put(StateAndRefSerializer.getRef(s), s);
});
return funds;
}catch(Exception e) {
throw new FlowException("getFunds error", e);
}
}
Error from log file:
INFO ] 2019-07-21T20:52:07,683Z [Node thread-1]
IOU_nextScheduledActivity.info - com.example.iou.autopaymentImplis
scheduled at 2019-07-21T20:52:07.678Z,
flowRef=com.example.iou.autopaymentImpl {actor_id=internalShell,
actor_owning_identity=O=charlie, L=New York, C=US,
actor_store_id=NODE_CONFIG, fiber-id=10000002,
flow-id=0eebd34b-92be-4af5-a650-2d49675702c3,
invocation_id=35bd0d5c-ea00-4a7d-972d-ff353bb9d2ec,
invocation_timestamp=2019-07-21T20:51:57.700Z, origin=internalShell,
session_id=13825f94-0f7c-4df7-80e2-c73511031bc7,
session_timestamp=2019-07-21T20:51:57.304Z, thread-id=229,
tx_id=D0EDC810EF00AFC9E99494F2DEF50AD040F439DAE3FC554BBC7698B9DCBA6073}
[INFO ] 2019-07-21T20:52:07,699Z [Node thread-1]
corda.flow.notariseAndRecord - Recorded transaction locally
successfully. {actor_id=internalShell,
actor_owning_identity=O=charlie, L=New York, C=US,
actor_store_id=NODE_CONFIG, fiber-id=10000002,
flow-id=0eebd34b-92be-4af5-a650-2d49675702c3,
invocation_id=35bd0d5c-ea00-4a7d-972d-ff353bb9d2ec,
invocation_timestamp=2019-07-21T20:51:57.700Z, origin=internalShell,
session_id=13825f94-0f7c-4df7-80e2-c73511031bc7,
session_timestamp=2019-07-21T20:51:57.304Z, thread-id=229,
tx_id=D0EDC810EF00AFC9E99494F2DEF50AD040F439DAE3FC554BBC7698B9DCBA6073}
[INFO ] 2019-07-21T20:52:07,840Z [pool-6-thread-1]
IOU_nextScheduledActivity.info - com.example.iou.autopaymentImplis
scheduled at 2019-07-21T20:52:07.839Z,
flowRef=com.example.iou.autopaymentImpl [INFO ]
2019-07-21T20:52:07,891Z [Node thread-1] corda.flow.call - autopayment
is triggered by a schedulable event {fiber-id=10000003,
flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:07,897Z [Node thread-1] corda.flow.info - flow
autopayment is started {fiber-id=10000003,
flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:07,912Z [Node thread-1] corda.flow.info - autopayment
is completed {fiber-id=10000003,
flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:07,915Z [Node thread-1]
corda.flow.createSubflowObject - autopayment to invoke flow
com.charlie.iou.flows.SettleIOUInitiatorImpl {fiber-id=10000003,
flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:07,922Z [Node thread-1] corda.flow.info - flow
SettleIOU startred {fiber-id=10000003,
flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:08,062Z [Node thread-1] corda.flow.lambda$eval$3 -
txbuilder::build commands, cmd=Move,
keys=["GfHq2tTVk9z4eXgyGKLLbMNy9c7hZ3XmrUEpRayxezT7VanQYX7c61RPCedL","GfHq2tTVk9z4eXgyQbQ5fnon7qDegNzvJ4s71djeDtZVSfoA466yXun6CLcK","GfHq2tTVk9z4eXgyV2oK18JdGAUozHXddWjBCFoMMKhMz5taj1qUyVYWBBfi"]
{fiber-id=10000003, flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:08,063Z [Node thread-1] corda.flow.eval -
txbuilder::build commands, cmd=com.example.iou.SettleIOU,
keys=["GfHq2tTVk9z4eXgyQbQ5fnon7qDegNzvJ4s71djeDtZVSfoA466yXun6CLcK","GfHq2tTVk9z4eXgySdF6Vz2jjYaaUP61nQVBgMJUAvmnhhWGA34bUwC9CaVn","GfHq2tTVk9z4eXgyV2oK18JdGAUozHXddWjBCFoMMKhMz5taj1qUyVYWBBfi"]
{fiber-id=10000003, flow-id=c8d1be17-aa32-4a73-b031-fff2707ed877,
invocation_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
invocation_timestamp=2019-07-21T20:52:07.842Z, origin=Scheduler,
session_id=09dbdf92-55cb-4bcc-8ce9-5eae3103a740,
session_timestamp=2019-07-21T20:52:07.842Z, thread-id=229} [INFO ]
2019-07-21T20:52:08,337Z [Node thread-1] corda.flow.call - Party
O=bob, L=New York, C=US received the transaction.
{actor_id=internalShell, actor_owning_identity=O=charlie, L=New York,
C=US, actor_store_id=NODE_CONFIG, fiber-id=10000002,
flow-id=0eebd34b-92be-4af5-a650-2d49675702c3,
invocation_id=35bd0d5c-ea00-4a7d-972d-ff353bb9d2ec,
invocation_timestamp=2019-07-21T20:51:57.700Z, origin=internalShell,
session_id=13825f94-0f7c-4df7-80e2-c73511031bc7,
session_timestamp=2019-07-21T20:51:57.304Z, thread-id=229,
tx_id=D0EDC810EF00AFC9E99494F2DEF50AD040F439DAE3FC554BBC7698B9DCBA6073}
[INFO ] 2019-07-21T20:52:08,338Z [Node thread-1] corda.flow.call - All
parties received the transaction successfully.
In our recent release of the TokenSDK 1.1, we have officially introduced the token-selection pack.
Here is the link for the binary file: https://ci-artifactory.corda.r3cev.com/artifactory/webapp/#/artifacts/browse/tree/General/corda-lib/com/r3/corda/lib/tokens/tokens-selection
And here is an example of how to import the dependencies to your project: https://github.com/corda/samples-java/blob/master/Accounts/worldcupticketbooking/build.gradle#L120
And here is how you use it:
Pair<List<StateAndRef<FungibleToken>>, List<FungibleToken>> inputsAndOutputs =
tokenSelection.generateMove(Arrays.asList(partyAndAmount), buyerAccount, new TokenQueryBy(), getRunId().getUuid());

how to check the output of airflow test?

I tried the airflow tutorial DAG, and it works with scheduler, I can see the logs generated by scheduled run. But if I use command line test, I didn't see the output:
airflow test my_tutorial_2 templated 2018-09-08
[2018-09-10 15:41:43,121] {__init__.py:51} INFO - Using executor SequentialExecutor
[2018-09-10 15:41:43,281] {models.py:258} INFO - Filling up the DagBag from /Users/xiang/Documents/BigData/airflow/dags
[2018-09-10 15:41:43,338] {example_kubernetes_operator.py:54} WARNING - Could not import KubernetesPodOperator: No module named 'kubernetes'
[2018-09-10 15:41:43,339] {example_kubernetes_operator.py:55} WARNING - Install kubernetes dependencies with: pip install airflow['kubernetes']
That is all the output, and my output is not there.
The airflow version is:
▶ pip list
Package Version
---------------- ---------
alembic 0.8.10
apache-airflow 1.10.0
If you use Ariflow v1.10, you can set the propagate attribute of taskinstance logger to True, then the log record will be propagated to root logger, which use console handler, and printed to sys.stdout.
Add ti.log.propagate = True
after line 589 to site-packages/airflow/bin/cli.py could do this trick.
I've since found that whilst setting 'console' as a handler for the airflow.task logger allows you to see the output of 'airflow test' commands, it also seems to cause 'airflow run' commands to enter an infinite loop and run out of memory. I would therefore only do this in an environment where you only want to run 'airflow test' commands
Why it does this I don't know yet, and whether there's a way to accomplish this question without breaking 'airflow run' is unclear to me
The default logging config for Airflow 1.10.0 has the following loggers available:
'loggers': {
'airflow.processor': {
'handlers': ['processor'],
'level': LOG_LEVEL,
'propagate': False,
},
'airflow.task': {
'handlers': ['task'],
'level': LOG_LEVEL,
'propagate': False,
},
'flask_appbuilder': {
'handler': ['console'],
'level': FAB_LOG_LEVEL,
'propagate': True,
}
},
and the airflow.task logger (which is the logger used when running your task) uses the 'task' handler:
'handlers': {
'console': {
'class': 'airflow.utils.log.logging_mixin.RedirectStdHandler',
'formatter': 'airflow',
'stream': 'sys.stdout'
},
'task': {
'class': 'airflow.utils.log.file_task_handler.FileTaskHandler',
'formatter': 'airflow',
'base_log_folder': os.path.expanduser(BASE_LOG_FOLDER),
'filename_template': FILENAME_TEMPLATE,
},
'processor': {
'class': 'airflow.utils.log.file_processor_handler.FileProcessorHandler',
'formatter': 'airflow',
'base_log_folder': os.path.expanduser(PROCESSOR_LOG_FOLDER),
'filename_template': PROCESSOR_FILENAME_TEMPLATE,
},
},
which (unless changed) will only write the output of the task to a log file. If you want to see the output in stdout as well, then you need add the console handler to the list of handlers used by the airflow.task logger:
'airflow.task': {
'handlers': ['task', 'console'],
'level': LOG_LEVEL,
'propagate': False,
},
This can be done by either setting up a custom logging configuration class, which overrides the default configuration, or by editing the default settings file
wherever_you_installed_airflow/site-packages/airflow/config_templates/airflow_local_settings.py
I ran into this problem as well with AirFlow 1.10.0. As Louis Genasi mentioned, airflow run would go into a death spiral with default settings and console handler. I suspect there may be a bug with the default logging class in 1.10.0.
I got around the issue by changing the logging handler to Python's logging.StreamHandler (which appears to be the default in Airflow < 1.10.0):
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'airflow',
'stream': 'ext://sys.stdout'
},
'loggers': {
'airflow.processor': {
'handlers': ['console'],
'level': LOG_LEVEL,
'propagate': False,
},
'airflow.task': {
'handlers': ['console'],
'level': LOG_LEVEL,
'propagate': False,
},
'flask_appbuilder': {
'handler': ['console'],
'level': FAB_LOG_LEVEL,
'propagate': True,
}
},
'root': {
'handlers': ['console'],
'level': LOG_LEVEL,
}

Using Try.on causes infinite loop/waiting in mock network in Corda 3.2?

I am migrating from v 3.0 to v 3.2 and a lot of my unit test uses Try.on to assert some expected result. It was working before in v3.0 but after v3.2 it gets stuck in a infinite wait on the unit test in mock network.
#Test
fun `Issue non-anonymous obligation successfully with non null remark`() {
// Throw null pointer
val result = Try.on {
issueObligation(a, b, 1000.POUNDS, anonymous = false, remark = null)
network.waitQuiescent()
}
assert(result.isFailure)
// If I don't run this subsequent transaction, the test runs successfully.
// Somehow, any transaction after a Try.on will get stuck.
// Should issue successfully.
issueObligation(a, b, 1000.POUNDS, anonymous = false, remark = "Valid")
network.waitQuiescent()
}
Stacktrace where by the console will be stuck in infinite wait.
[WARN ] 11:15:45,055 [Mock node 1 thread] (FlowStateMachineImpl.kt:111) flow.[2c41b166-041a-4ec8-87dd-896e3712415e].run - Terminated by unexpected exception {}
java.lang.IllegalArgumentException: Invalid string.
at net.corda.examples.obligation.flows.IssueObligation$Initiator.call(IssueObligation.kt:44) ~[classes/:?]
at net.corda.examples.obligation.flows.IssueObligation$Initiator.call(IssueObligation.kt:21) ~[classes/:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-3.2-corda.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-3.2-corda.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_151]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_151]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_151]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-3.2-corda.jar:?]
[INFO ] 11:15:45,474 [Mock node 1 thread] (FlowStateMachineImpl.kt:432) flow.[77bea7fa-402f-4527-8388-d910faea6342].initiateSession - Initiating flow session with party O=Mock Company 2, L=London, C=GB. Session id for tracing purposes is SessionId(toLong=7175264157685997907). {}
[INFO ] 11:15:45,570 [Mock node 2 thread] (StateMachineManagerImpl.kt:367) statemachine.StateMachineManagerImpl.onSessionInit - Accepting flow session from party O=Mock Company 1, L=London, C=GB. Session id for tracing purposes is SessionId(toLong=7175264157685997907). {invocation_id=18195f36-850b-4fec-9794-9e57c16f9155, invocation_timestamp=2018-08-03T04:15:45.557Z, session_id=18195f36-850b-4fec-9794-9e57c16f9155, session_timestamp=2018-08-03T04:15:45.557Z}
[INFO ] 11:15:45,747 [Mock node 1 thread] (FlowStateMachineImpl.kt:432) flow.[77bea7fa-402f-4527-8388-d910faea6342].initiateSession - Initiating flow session with party O=Notary Service, L=Zurich, C=CH. Session id for tracing purposes is SessionId(toLong=-6165721234712091944). {}
[INFO ] 11:15:45,772 [Mock node 0 thread] (StateMachineManagerImpl.kt:367) statemachine.StateMachineManagerImpl.onSessionInit - Accepting flow session from party O=Mock Company 1, L=London, C=GB. Session id for tracing purposes is SessionId(toLong=-6165721234712091944). {invocation_id=c7c9d70d-e73a-4724-912a-e7f3d5080e57, invocation_timestamp=2018-08-03T04:15:45.770Z, session_id=c7c9d70d-e73a-4724-912a-e7f3d5080e57, session_timestamp=2018-08-03T04:15:45.770Z}
[INFO ] 11:15:45,868 [Mock node 1 thread] (HibernateConfiguration.kt:47) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Creating session factory for schemas: [ObligationSchemaV1(name=net.corda.examples.obligation.ObligationSchema, version=1)] {}
[INFO ] 11:15:45,875 [Mock node 1 thread] (ConnectionProviderInitiator.java:122) internal.ConnectionProviderInitiator.initiateService - HHH000130: Instantiating explicit connection provider: net.corda.nodeapi.internal.persistence.HibernateConfiguration$NodeDatabaseConnectionProvider {}
[INFO ] 11:15:45,876 [Mock node 1 thread] (Dialect.java:157) dialect.Dialect. - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect {}
[INFO ] 11:15:45,881 [Mock node 1 thread] (BasicTypeRegistry.java:148) type.BasicTypeRegistry.register - HHH000270: Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7a7698f4 {}
[INFO ] 11:15:45,894 [Mock node 1 thread] (DdlTransactionIsolatorNonJtaImpl.java:47) connections.access.getIsolatedConnection - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess#736e95ad] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. {}
[INFO ] 11:15:45,909 [Mock node 1 thread] (HibernateConfiguration.kt:64) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Created session factory for schemas: [ObligationSchemaV1(name=net.corda.examples.obligation.ObligationSchema, version=1)] {}
[INFO ] 11:15:45,916 [Mock node 1 thread] (HibernateConfiguration.kt:47) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Creating session factory for schemas: [VaultSchemaV1(name=net.corda.node.services.vault.VaultSchema, version=1)] {}
[INFO ] 11:15:45,923 [Mock node 1 thread] (ConnectionProviderInitiator.java:122) internal.ConnectionProviderInitiator.initiateService - HHH000130: Instantiating explicit connection provider: net.corda.nodeapi.internal.persistence.HibernateConfiguration$NodeDatabaseConnectionProvider {}
[INFO ] 11:15:45,924 [Mock node 1 thread] (Dialect.java:157) dialect.Dialect. - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect {}
[INFO ] 11:15:45,927 [Mock node 1 thread] (BasicTypeRegistry.java:148) type.BasicTypeRegistry.register - HHH000270: Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7a7698f4 {}
[INFO ] 11:15:45,953 [Mock node 1 thread] (DdlTransactionIsolatorNonJtaImpl.java:47) connections.access.getIsolatedConnection - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess#318fb15] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. {}
[INFO ] 11:15:45,994 [Mock node 1 thread] (HibernateConfiguration.kt:64) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Created session factory for schemas: [VaultSchemaV1(name=net.corda.node.services.vault.VaultSchema, version=1)] {}
[INFO ] 11:15:46,003 [Mock node 1 thread] (FlowStateMachineImpl.kt:432) flow.[77bea7fa-402f-4527-8388-d910faea6342].initiateSession - Initiating flow session with party O=Mock Company 2, L=London, C=GB. Session id for tracing purposes is SessionId(toLong=-2453204714770107984). {}
[INFO ] 11:15:46,027 [Mock node 2 thread] (StateMachineManagerImpl.kt:367) statemachine.StateMachineManagerImpl.onSessionInit - Accepting flow session from party O=Mock Company 1, L=London, C=GB. Session id for tracing purposes is SessionId(toLong=-2453204714770107984). {invocation_id=ec8f9d18-73ef-4739-a0cd-84202e590df9, invocation_timestamp=2018-08-03T04:15:46.026Z, session_id=ec8f9d18-73ef-4739-a0cd-84202e590df9, session_timestamp=2018-08-03T04:15:46.026Z}
[INFO ] 11:15:46,084 [Mock node 2 thread] (HibernateConfiguration.kt:47) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Creating session factory for schemas: [ObligationSchemaV1(name=net.corda.examples.obligation.ObligationSchema, version=1)] {}
[INFO ] 11:15:46,099 [Mock node 2 thread] (ConnectionProviderInitiator.java:122) internal.ConnectionProviderInitiator.initiateService - HHH000130: Instantiating explicit connection provider: net.corda.nodeapi.internal.persistence.HibernateConfiguration$NodeDatabaseConnectionProvider {}
[INFO ] 11:15:46,100 [Mock node 2 thread] (Dialect.java:157) dialect.Dialect. - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect {}
[INFO ] 11:15:46,107 [Mock node 2 thread] (BasicTypeRegistry.java:148) type.BasicTypeRegistry.register - HHH000270: Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7a7698f4 {}
[INFO ] 11:15:46,115 [Mock node 2 thread] (DdlTransactionIsolatorNonJtaImpl.java:47) connections.access.getIsolatedConnection - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess#606d0355] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. {}
[INFO ] 11:15:46,129 [Mock node 2 thread] (HibernateConfiguration.kt:64) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Created session factory for schemas: [ObligationSchemaV1(name=net.corda.examples.obligation.ObligationSchema, version=1)] {}
[INFO ] 11:15:46,130 [Mock node 2 thread] (HibernateConfiguration.kt:47) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Creating session factory for schemas: [VaultSchemaV1(name=net.corda.node.services.vault.VaultSchema, version=1)] {}
[INFO ] 11:15:46,134 [Mock node 2 thread] (ConnectionProviderInitiator.java:122) internal.ConnectionProviderInitiator.initiateService - HHH000130: Instantiating explicit connection provider: net.corda.nodeapi.internal.persistence.HibernateConfiguration$NodeDatabaseConnectionProvider {}
[INFO ] 11:15:46,135 [Mock node 2 thread] (Dialect.java:157) dialect.Dialect. - HHH000400: Using dialect: org.hibernate.dialect.H2Dialect {}
[INFO ] 11:15:46,136 [Mock node 2 thread] (BasicTypeRegistry.java:148) type.BasicTypeRegistry.register - HHH000270: Type registration [materialized_blob] overrides previous : org.hibernate.type.MaterializedBlobType#7a7698f4 {}
[INFO ] 11:15:46,157 [Mock node 2 thread] (DdlTransactionIsolatorNonJtaImpl.java:47) connections.access.getIsolatedConnection - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess#6b0f595c] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. {}
[INFO ] 11:15:46,175 [Mock node 2 thread] (HibernateConfiguration.kt:64) persistence.HibernateConfiguration.makeSessionFactoryForSchemas - Created session factory for schemas: [VaultSchemaV1(name=net.corda.node.services.vault.VaultSchema, version=1)] {}
This appears to be a bug in Corda 3.2. It is being tracked here: https://github.com/corda/corda/issues/3741.

Resources