Commit 0f3737f
committed
This PR fixes UNPREPARED handling in the Python driver execution path for prepared statements.
### Problem
When the server returned UNPREPARED (PreparedQueryNotFound) during an EXECUTE, the driver could fail to recover in some valid cases (cache miss, race, coordinator restart, id mismatch edge cases), even when the in-flight request still had enough PreparedStatement context to recover.
### Expected behavior
If the driver still has the original PreparedStatement context, it should:
1. issue PREPARE,
2. then retry the original EXECUTE,
regardless of why the coordinator no longer recognizes the prepared id.
### What this PR changes
In ResponseFuture PreparedQueryNotFound handling:
1. Cache the in-flight self.prepared_statement first (when present).
2. Attempt lookup by the returned UNPREPARED id from cluster._prepared_statements.
3. Reprepare using the resolved statement.
4. If returned-id lookup fails:
- fallback to in-flight context if available,
- otherwise fail as unknown prepared statement.
This preserves correctness while improving recovery in real-world coordinator invalidation/race/restart scenarios.
### Tests
Added/updated unit coverage in tests/unit/test_response_future.py:
- validates reprepare path for PreparedQueryNotFound,
- validates fallback to in-flight context,
- validates preference for statement resolved by returned UNPREPARED id when available.
Fixes: scylladb/scylladb#276571 parent 1ec7f66 commit 0f3737f
2 files changed
Lines changed: 76 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4714 | 4714 | | |
4715 | 4715 | | |
4716 | 4716 | | |
| 4717 | + | |
| 4718 | + | |
4717 | 4719 | | |
4718 | | - | |
4719 | | - | |
4720 | | - | |
4721 | | - | |
4722 | | - | |
4723 | | - | |
| 4720 | + | |
| 4721 | + | |
4724 | 4722 | | |
4725 | 4723 | | |
4726 | | - | |
| 4724 | + | |
4727 | 4725 | | |
4728 | 4726 | | |
4729 | | - | |
4730 | | - | |
| 4727 | + | |
4731 | 4728 | | |
4732 | 4729 | | |
4733 | | - | |
4734 | | - | |
4735 | | - | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
4736 | 4736 | | |
4737 | 4737 | | |
4738 | | - | |
| 4738 | + | |
4739 | 4739 | | |
4740 | 4740 | | |
4741 | 4741 | | |
| |||
4746 | 4746 | | |
4747 | 4747 | | |
4748 | 4748 | | |
4749 | | - | |
4750 | | - | |
| 4749 | + | |
| 4750 | + | |
4751 | 4751 | | |
4752 | | - | |
| 4752 | + | |
4753 | 4753 | | |
4754 | 4754 | | |
4755 | 4755 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
624 | 684 | | |
625 | 685 | | |
626 | 686 | | |
| |||
0 commit comments