Skip to content

Commit 6dbb4e8

Browse files
committed
store/postgres: Log messages about lock acquisition on subgraph logger
1 parent 7a32901 commit 6dbb4e8

File tree

7 files changed

+19
-10
lines changed

7 files changed

+19
-10
lines changed

core/src/subgraph/registrar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn create_subgraph_version(
682682
if deployment_exists {
683683
store.apply_entity_operations(ops, None)?
684684
} else {
685-
store.create_subgraph_deployment(&manifest.id, ops)?;
685+
store.create_subgraph_deployment(logger, &manifest.id, ops)?;
686686
}
687687

688688
debug!(

core/tests/interfaces.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ fn insert_and_query(
2424
data_sources: vec![],
2525
};
2626

27+
let logger = Logger::root(slog::Discard, o!());
28+
2729
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, Default::default(), 1)
2830
.create_operations_replace(&subgraph_id);
29-
STORE.create_subgraph_deployment(&subgraph_id, ops).unwrap();
31+
STORE
32+
.create_subgraph_deployment(&logger, &subgraph_id, ops)
33+
.unwrap();
3034

3135
let insert_ops = entities
3236
.into_iter()
@@ -41,7 +45,6 @@ fn insert_and_query(
4145

4246
STORE.apply_entity_operations(insert_ops.collect(), None)?;
4347

44-
let logger = Logger::root(slog::Discard, o!());
4548
let resolver = StoreResolver::new(&logger, STORE.clone());
4649

4750
let options = QueryExecutionOptions {

graph/src/components/store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ pub trait Store: Send + Sync + 'static {
10081008
/// version
10091009
fn create_subgraph_deployment(
10101010
&self,
1011+
subgraph_logger: &Logger,
10111012
subgraph_id: &SubgraphDeploymentId,
10121013
ops: Vec<EntityOperation>,
10131014
) -> Result<(), StoreError>;

graphql/tests/query.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ lazy_static! {
1313
static ref TEST_SUBGRAPH_ID: SubgraphDeploymentId = {
1414
// Also populate the store when the ID is first accessed.
1515
let id = SubgraphDeploymentId::new("graphqlTestsQuery").unwrap();
16-
STORE.create_subgraph_deployment(&id, vec![]).unwrap();
16+
let logger = Logger::root(slog::Discard, o!());
17+
STORE.create_subgraph_deployment(&logger, &id, vec![]).unwrap();
1718
insert_test_entities(&**STORE, id.clone());
1819
id
1920
};

mock/src/store.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ impl Store for MockStore {
331331

332332
fn create_subgraph_deployment(
333333
&self,
334+
_logger: &Logger,
334335
_subgraph_id: &SubgraphDeploymentId,
335336
ops: Vec<EntityOperation>,
336337
) -> Result<(), StoreError> {
@@ -492,6 +493,7 @@ impl Store for FakeStore {
492493

493494
fn create_subgraph_deployment(
494495
&self,
496+
_logger: &Logger,
495497
_subgraph_id: &SubgraphDeploymentId,
496498
_ops: Vec<EntityOperation>,
497499
) -> Result<(), StoreError> {

store/postgres/src/store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ impl StoreTrait for Store {
10231023

10241024
fn create_subgraph_deployment(
10251025
&self,
1026+
subgraph_logger: &Logger,
10261027
subgraph_id: &SubgraphDeploymentId,
10271028
ops: Vec<EntityOperation>,
10281029
) -> Result<(), StoreError> {
@@ -1075,9 +1076,8 @@ impl StoreTrait for Store {
10751076
// it was because we timed out on the lock and try again.
10761077
if start.elapsed() >= Duration::from_secs(LOCK_TIMEOUT) {
10771078
debug!(
1078-
self.logger,
1079-
"could not acquire lock for creation of subgraph {}, trying again in {}s",
1080-
&subgraph_id,
1079+
subgraph_logger,
1080+
"Could not acquire lock for subgraph creation, trying again in {}s",
10811081
delay.as_secs()
10821082
);
10831083
std::thread::sleep(delay);

store/postgres/tests/store.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn insert_test_data(store: Arc<DieselStore>) {
117117
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, *TEST_BLOCK_0_PTR, 1)
118118
.create_operations(&*TEST_SUBGRAPH_ID);
119119
store
120-
.create_subgraph_deployment(&TEST_SUBGRAPH_ID, ops)
120+
.create_subgraph_deployment(&*LOGGER, &TEST_SUBGRAPH_ID, ops)
121121
.unwrap();
122122

123123
let test_entity_1 = create_test_entity(
@@ -1868,7 +1868,9 @@ fn entity_changes_are_fired_and_forwarded_to_subscriptions() {
18681868
// Create SubgraphDeploymentEntity
18691869
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, *TEST_BLOCK_0_PTR, 1)
18701870
.create_operations(&subgraph_id);
1871-
store.create_subgraph_deployment(&subgraph_id, ops).unwrap();
1871+
store
1872+
.create_subgraph_deployment(&*LOGGER, &subgraph_id, ops)
1873+
.unwrap();
18721874

18731875
// Create store subscriptions
18741876
let meta_subscription =
@@ -2186,7 +2188,7 @@ fn create_subgraph_deployment_tolerates_locks() {
21862188
barrier.wait();
21872189
let start = std::time::Instant::now();
21882190
store
2189-
.create_subgraph_deployment(&subgraph_id, vec![])
2191+
.create_subgraph_deployment(&*LOGGER, &subgraph_id, vec![])
21902192
.expect("Subgraph creation failed");
21912193
assert!(start.elapsed() >= Duration::from_secs(BLOCK_TIME));
21922194
Ok(())

0 commit comments

Comments
 (0)